Skip to content
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

Remove confusing instance variable example in cheat sheet #15441

Merged
merged 1 commit into from
Jun 15, 2023

Conversation

atallahade
Copy link
Contributor

The mypy cheat sheet documentation provides an example on how to type instance and class attributes. However, it shows that an attribute with a default value in the class body is an instance variable, and I don't think this is correct. I understand that strings are immutable, which makes the example valid in the end, but I don't believe this is a great practice to define instance variables with a value outside of the init method.

Please let me know if you disagree or would prefer to change the comment rather than deleting the example.

@ikonst
Copy link
Contributor

ikonst commented Jun 15, 2023

LGTM. I don't see any value in that example, and agree it's a dubious practice especially when people then carry it into mutable types.

@hauntsaninja hauntsaninja merged commit cfec717 into python:master Jun 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants