-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Pyright reports redeclaration when using types.DynamicClassAttribute after typeshed change #9620
Comments
Pyright (and other type checkers) have significant special casing for I might reconsider this in the future if there's significant signal from pyright users, but I'm not sure what prompted the change in typeshed, but it's not clear to me that this change is a net benefit to users. |
Fair enough. Mypy has a list of property-like classes (currently
To be clear, the motivation for the typeshed change is accuracy to runtime, but it's just a proposed change, not one that's already occurred. I don't think anyone has interest in making |
I'm not a javascript or typescript programmer, but I took a look at problem anyway. This change fixes this for pyright, without causing any failures in the test suite: --- a/packages/pyright-internal/src/analyzer/typeEvaluator.ts
+++ b/packages/pyright-internal/src/analyzer/typeEvaluator.ts
@@ -17035,7 +17035,7 @@ export function createTypeEvaluator(
classFlags |= ClassTypeFlags.TypingExtensionClass;
}
- if (node.d.name.d.value === 'property') {
+ if (node.d.name.d.value === 'property' || node.d.name.d.value === 'DynamicClassAttribute') {
classFlags |= ClassTypeFlags.PropertyClass;
} Would you be willing to consider this as a MR? It seems easy enough to me, but like I said I'm not a typescript programmer and I'm not familiar with the pyright code base, so I don't know if I'm missing anything. |
No, this is not a complete fix. I'm not interested in supporting additional special cases here. |
Describe the bug
Currently, typeshed declares DynamicClassAttribute as an alias of property:
I'd like to update this to define DynamicClassAttribute as it's own class. The new mypy 1.14.0 supports this change, but pyright is generating
reportRedeclaration
errors when declaring setters and deleters if this change is made.Code or Screenshots
See the typeshed MR with the change and a test showing the pyright errors: python/typeshed#13276
test case:
The text was updated successfully, but these errors were encountered: