pyright
pyright copied to clipboard
Pyright raises type error when supplying an attr field with both default and a validator
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
import attrs
@attrs.define
class Foo:
a: bool = attrs.field(default=False, validator=attrs.validators.instance_of(bool))
Interestingly, if the validator is surrounded with parenthesis (which should have no effect), pyright reports no error:
import attrs
@attrs.define
class Foo:
a: bool = attrs.field(default=False, validator=(attrs.validators.instance_of(bool)))
VS Code extension or command-line command-line, version 1.1.367