Closed tungol closed 1 month ago
Thanks for reporting. I'm going to take a look today or tomorrow. I hope that's easy to fix.
Thanks for the tiny example. I can easily reproduce as described.
I wonder if this is an unintended use of the loader API. Moving loader = load_pytd.create_loader(options, [])
inside the for loop fixes the issue.
I still want to debug why exactly this error is happening, though. I don't think it should.
Argh. I tried running the typeshed tests with a new loader for each file. Took way too long. Then tried a new loader for each file but at least caching builtins and typing base modules. Still way too slow. I guess we will have to fix this in pytype somehow.
I might have a fix: #1804. I need to do some more testing tomorrow to ensure that this doesn't cause a regression elsewhere. But it looks promising.
We just published https://pypi.org/project/pytype/2024.10.11/
I tested that with your PR on typeshed and confirmed that the tests pass.
Nice! I appreciate it.
In https://github.com/python/typeshed/pull/12745 , I created a circular dependency which caused pytype to generate an
Unreplaced NamedType
error. It triggers when ParamSpec is used. Interestingly, it only triggers if the file containing the ParamSpec is processed first. If the processing order is reversed, there's no error.I isolated a minimal reproduction, which is available here: https://github.com/tungol/pytype-error-reproduction
When the script in that repo is run, I get this output:
I wasn't able to reproduce the error with .py files instead if .pyi files, but I also didn't try too hard, so I don't know for sure if that's a critical part of the error or not.