-
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
Pyright raises type error when supplying an attr field with both default and a validator #8133
Comments
…n argument expression with parentheses. This addresses part of #8133.
Thanks for the bug report. You've actually identified two separate bugs. The first is related to your observation that the behavior changes when you add parens. As you noted, this should have no impact on type evaluation. This bug was easy to address, and the fix will be in the next release. The second issue is more difficult to fix and is related to the way that pyright's constraint solver is designed. The constraint solver is responsible for "solving" type variables for a generic function call. The bug you've identified here is related to two other open issues: #5855 and #8048. This fix will likely take much longer. In the meantime, if you want to work around it, you can swap the order of the two arguments. Place the |
This doesn't actually fix the error. I was actually fixing it by using the parenthesis. I couldn't figure out a way to fix it other than with an ignore directive. |
Describe the bug
Pyright incorrectly reports an error when supplying both a validator and a default to
attrs.field
This does not seem to be a bug with the
attrs
package, as using mypy reports no issues.Code or Screenshots
Interestingly, if the validator is surrounded with parenthesis (which should have no effect), pyright reports no error:
VS Code extension or command-line
command-line, version 1.1.367
The text was updated successfully, but these errors were encountered: