-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Generic types are reused / only bound once #7988
Comments
Possibly related. PyLance now fails to interpret the generic type of this @no_type_check
@staticmethod
def it(
spec: type[T] | None = None,
*,
spec_set: bool = True,
... I checked and the If I change to a brand new typevar the type hint changes to remove the Any but it still doesn't properly give the type. Expected value is You can see by the coloring it doesn't know what Library is MegaMock: |
@JamesHutchison, sorry but I don't understand your post. It's definitely not related to this issue. If you'd like to file a separate bug report, please open a new issue and include a minimal, self-contained code sample that demonstrates the problem you're seeing. Your code sample above is incomplete, so I'm not sure what it's trying to demonstrate. If you have questions about pylance language server features like semantic highlighting, the pylance-release project is a good place to post. |
Please consider the following code:
Shouldn't the last line above give an error since the two locks are swapped? Mypy does give an error, but pyright doesn't.
To get an error in pyright, one has to duplicate
f
:Unless this is expected behavior and mypy is wrong, the problem seems to be that in the code
there's just a single copy of
L1
andL2
involved. To get two independent instances, one has to basically create another function.The same happens in other contexts. Here's again some code I posted some time ago (that you didn't have time to read):
The point is that
adc1
, ...,adc4
are copies of the same function. I had to write the same function 4 times!I really hope this is a bug and not intended behavior!
The text was updated successfully, but these errors were encountered: