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

Incorrect usage of slots and class attribute #19

Open
bergkvist opened this issue Sep 22, 2023 · 0 comments
Open

Incorrect usage of slots and class attribute #19

bergkvist opened this issue Sep 22, 2023 · 0 comments

Comments

@bergkvist
Copy link

Problem:

_is_leaf: Optional[bool] = None
_left: Optional[Node] = None
_right: Optional[Node] = None
__slots__ = '_root', '_src', '_is_leaf', '_left', '_right'

Error:

ValueError: '_is_leaf' in __slots__ conflicts with class variable

If you set the default values to None in __init__ instead, it will fix the problem.

Python 3.6, 3.7, 3.8, 3.9, 3.10, 3.11 all complain about __slots__ conflicts when you give attributes a default value.

See: python/cpython#106067

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

No branches or pull requests

1 participant