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
kw_only
default
__attrs_pre_init__
The following code raises SyntaxError
from attrs import define, field @define class A: a: int = field(kw_only=True, default=3) def __attrs_pre_init__(self, _): pass
Traceback (most recent call last): File "/home/user/attrs_pre_init.py", line 4, in <module> @define ^^^^^^ File "/home/user/.venv/lib/python3.12/site-packages/attr/_next_gen.py", line 153, in define return wrap(maybe_cls) ^^^^^^^^^^^^^^^ File "/home/user/.venv/lib/python3.12/site-packages/attr/_next_gen.py", line 144, in wrap return do_it(cls, True) ^^^^^^^^^^^^^^^^ File "/home/user/.venv/lib/python3.12/site-packages/attr/_next_gen.py", line 90, in do_it return attrs( ^^^^^^ File "/home/user/.venv/lib/python3.12/site-packages/attr/_make.py", line 1715, in attrs return wrap(maybe_cls) ^^^^^^^^^^^^^^^ File "/home/user/.venv/lib/python3.12/site-packages/attr/_make.py", line 1694, in wrap builder.add_init() File "/home/user/.venv/lib/python3.12/site-packages/attr/_make.py", line 1090, in add_init _make_init( File "/home/user/.venv/lib/python3.12/site-packages/attr/_make.py", line 2181, in _make_init init = _make_method( ^^^^^^^^^^^^^ File "/home/user/.venv/lib/python3.12/site-packages/attr/_make.py", line 345, in _make_method _compile_and_eval(script, globs, locs, filename) File "/home/user/.venv/lib/python3.12/site-packages/attr/_make.py", line 317, in _compile_and_eval bytecode = compile(script, filename, "exec") ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "<attrs generated init __main__.A>", line 2 self.__attrs_pre_init__(a=attr_dict['a'].default=a=attr_dict['a'].default) ^ SyntaxError: invalid syntax
The text was updated successfully, but these errors were encountered:
Fix crash when __pre_init__, kw_only, and defaults come together
178c9d7
Fixes #1284
0094089
09161fc
Successfully merging a pull request may close this issue.
The following code raises SyntaxError
The text was updated successfully, but these errors were encountered: