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

Allow for attributes to be both kw_only and not in init. #30

Merged
merged 1 commit into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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