Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pytype error related to private recursive typealias #1858

Open
tungol opened this issue Jan 1, 2025 · 0 comments
Open

Pytype error related to private recursive typealias #1858

tungol opened this issue Jan 1, 2025 · 0 comments

Comments

@tungol
Copy link

tungol commented Jan 1, 2025

I got a pytype error on my typeshed MR python/typeshed#13349. Here's the relevant pipeline: https://github.com/python/typeshed/actions/runs/12565160822/job/35029069626?pr=13349

The error is: pytype.pytd.visitors.SymbolLookupError: Couldn't find _ElementCallable in xml.etree.cElementTree

Where _ElementCallable is a recursive typealias defined and used in xml/etree/ElementTree.pyi

_ElementCallable: TypeAlias = Callable[..., Element[_ElementCallable]]

and xml/etree/cElementTree.pyi where the error occurs is just

from xml.etree.ElementTree import *

There's no problem reported for xml.etree.ElementTree, and no error if the import in cElementTree is removed. There's also no error if _ElementCallable is redefined to not be recursive.

It seems like pytype is trying to analyze something imported that uses _ElementCallable, encountering the variable name inside that, and then failing because _ElementCallable itself isn't imported and it can't look it up within the context of cElementTree.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant