Skip to content

Commit

Permalink
Merge pull request #30 from DavidCEllis/relax_init_kw_only
Browse files Browse the repository at this point in the history
Allow for attributes to be both kw_only and not in init.
  • Loading branch information
DavidCEllis authored Nov 5, 2024
2 parents 6910b40 + 6e1dfff commit eac5657
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 20 deletions.
5 changes: 0 additions & 5 deletions src/ducktools/classbuilder/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -654,11 +654,6 @@ def validate_field(self):
f"{cls_name} cannot define both a default value and a default factory."
)

if self.kw_only and not self.init:
raise AttributeError(
f"{cls_name} cannot be keyword only if it is not in init."
)

@classmethod
def from_field(cls, fld, /, **kwargs):
"""
Expand Down
6 changes: 0 additions & 6 deletions tests/prefab/shared/examples/fails/creation_1.py

This file was deleted.

9 changes: 0 additions & 9 deletions tests/prefab/shared/test_creation.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,15 +144,6 @@ def test_skipped_annotated_classvars(self):


class TestExceptions:
def test_kw_not_in_init(self):
with pytest.raises(AttributeError) as e_info:
from fails.creation_1 import Construct

assert (
e_info.value.args[0]
== "Attribute cannot be keyword only if it is not in init."
)

def test_positional_after_kw_error(self):
with pytest.raises(SyntaxError) as e_info:
from fails.creation_2 import FailSyntax
Expand Down

0 comments on commit eac5657

Please sign in to comment.