We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Bug Report
I think this is somewhat related to #11923, not positive though.
Mypy doesn't seem to recognize dataclass attributes defined in __post_init__ and I'm not sure if this is expected/intentional:
__post_init__
import dataclasses @dataclasses.dataclass class A: def __post_init__(self): self.a = dict(foo=["a"]) def blah(self): self.a["foo"].append("a")
Expected Behavior
I would expect that this should be fine as the __post_init__ should have enough information for mypy to recognize that the attribute is defined.
Actual Behavior
In member "foo" of class "A": error: "object" has no attribute "append" [attr-defined] self.a["foo"].append("a")
Your Environment
pyproject.toml
[tool.mypy] warn_unused_configs = true warn_unused_ignores = true install_types = true non_interactive = true check_untyped_defs = true show_error_codes = true show_error_context = true pretty = true color_output = true
The text was updated successfully, but these errors were encountered:
Bleh, I can't reproduce this as it looks like there's something else going on. I'll re-open once I have a better MWE
Sorry, something went wrong.
No branches or pull requests
Bug Report
I think this is somewhat related to #11923, not positive though.
Mypy doesn't seem to recognize dataclass attributes defined in
__post_init__
and I'm not sure if this is expected/intentional:Expected Behavior
I would expect that this should be fine as the
__post_init__
should have enough information for mypy to recognize that the attribute is defined.Actual Behavior
Your Environment
pyproject.toml
:The text was updated successfully, but these errors were encountered: