-
Notifications
You must be signed in to change notification settings - Fork 286
pytype hangs on alias from another module inside class #612
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
Comments
I believe we currently only allow aliases inside a class to another member of the same class, due to some parser limitations. But the parser usually prints a sensible error message instead of hanging forever, so at the least that should be fixed. |
I discovered this limitation while working on python/typeshed#4275. One temporary solution would be if pytype would just treating those aliases as |
Rewriting
as
seems to work. (which leads to the question: could pytype just automatically do this rewrite behind the scenes?) |
Not sure if pytype has more permissive rules around |
I ran into possibly the same problem with a class from the same module. Minimal repro (.pyi file) class Foo:
def meth(self) -> None: ...
class Bar:
meth = Foo.meth When trying to resolve this aliasing, pytype gets stuck into this infinite while loop in
I haven't tried to figure out what this loop is supposed to do yet so I don't know how to fix this. Being able to do this kind of aliasing would allow me to get rid of some copy/pasta in stub files that I'm currently working on. |
Thanks for tracking that down! I think I'll try just putting in a type of |
What is currently the preferred way to say "
Edit: If the |
We can't resolve these properly, but for some reason people have been trying to use them a lot in typeshed recently, so let's set these aliases to Any for now. For #612. PiperOrigin-RevId: 323060647
pytype 2020.07.24 contains a workaround that allows arbitrary aliases as class attributes; let me know if something isn't working. |
Please consider the following stub file:
When checking this with pytype (2020.06.01), pytype hangs indefinitely, while consuming 100% CPU time.
The text was updated successfully, but these errors were encountered: