-
Notifications
You must be signed in to change notification settings - Fork 768
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
Pylance does not recognize typing.Final #1574
Comments
Thanks for the bug report. It wasn't immediately clear to me whether this was a bug based on the Python documentation. It took a bit of digging and experimentation to convince myself that the current behavior in Pylance is indeed incorrect. PEP 591 (which introduced
And PEP 557, which introduced
Consistent with these two statements, Pylance assumed that your use of However, after some experimentation, I've confirmed that there is apparently an implied exception to the PEP 591 rule for dataclasses. This exception isn't spelled out in any PEP, and I suspect that it was simply an oversight when dataclass was implemented. In any event, it's too late to change the behavior now without introducing a backward compatibility problem, so we're stuck with the inconsistency. I've updated the dataclass logic in Pylance to add this exception so the behavior is consistent with the runtime support for dataclass. |
Hi Eric, thanks for the super quick response, fix and explanation. Very much appreciated. How often are releases of There is another issue I want to bring to your attention but I cannot reproduce it in isolation and unfortunately I cannot share my code with you as it's intellectual property. Another error occurs when using the
I removed use of this decorator from my code as I don't really need it. This seems like a bug to me but I cannot be sure. The code producing this issue looks a little similar to the below (but this only has the issue described above that you have now fixed):
The error shows on the |
We typically release a new version once a week on or about Wednesday. The error message above seems to reference a type variable |
There are no uses of I will wait for the new release of |
This issue has been fixed in version 2021.7.5, which we've just released. You can find the changelog here: https://github.com/microsoft/pylance-release/blob/main/CHANGELOG.md#202175-22-july-2021 |
Environment data
Pylance v2021.7.4
Expected behaviour
No error as in the following case when Final is omitted:
and second case
Actual behaviour
Error:
No parameter named "name" PylancereportGeneralTypeIssues
(constant) name: str
occurs due to the presence of Final as in the following case:
and second case
Error:
Expected 0 positional arguments Pylance(reportGeneralTypeIssues)
These are clearly false-positives and not expected behavior.
Code Snippet / Additional information
Contents of pyrightconfig.json file:
The text was updated successfully, but these errors were encountered: