Skip to content

Commit

Permalink
Remove unused constructor _namedtuple_compat._make(). #321
Browse files Browse the repository at this point in the history
  • Loading branch information
lemon24 committed Nov 5, 2023
1 parent a215e48 commit c8606cb
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 17 deletions.
10 changes: 0 additions & 10 deletions src/reader/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,6 @@ class _namedtuple_compat:

# TODO: can we get rid of _namedtuple_compat?

@classmethod
def _make(cls, iterable: Iterable[Any]) -> Self:
iterable = tuple(iterable)
attrs_len = len(dataclasses.fields(cls)) # type: ignore[arg-type]
if len(iterable) != attrs_len:
raise TypeError(
'Expected %d arguments, got %d' % (attrs_len, len(iterable))
)
return cls(*iterable)

def _replace(self, **kargs: Any) -> Self:
return dataclasses.replace(self, **kargs) # type: ignore[type-var,misc]

Expand Down
7 changes: 0 additions & 7 deletions tests/test_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,7 @@ class Object(_namedtuple_compat):
one: int
two: int = None

assert Object._make((1, 2)) == Object(1, 2)
with pytest.raises(TypeError):
Object._make((1,))
with pytest.raises(TypeError):
Object._make((1, 2, 3))

assert Object(1, 1)._replace(two=2) == Object(1, 2)

assert Object(1, 2)._asdict() == {'one': 1, 'two': 2}


Expand Down

0 comments on commit c8606cb

Please sign in to comment.