Skip to content

Commit

Permalink
Clean up dead code
Browse files Browse the repository at this point in the history
  • Loading branch information
Tinche committed Dec 1, 2024
1 parent d4c20d2 commit 2fe721e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 12 deletions.
9 changes: 1 addition & 8 deletions src/cattrs/gen/_generics.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,7 @@ def generate_mapping(cl: type, old_mapping: dict[str, type] = {}) -> dict[str, t
origin = get_origin(cl)

if origin is not None:
# To handle the cases where classes in the typing module are using
# the GenericAlias structure but aren't a Generic and hence
# end up in this function but do not have an `__parameters__`
# attribute. These classes are interface types, for example
# `typing.Hashable`.
parameters = getattr(get_origin(cl), "__parameters__", None)
if parameters is None:
return dict(old_mapping)
parameters = origin.__parameters__

for p, t in zip(parameters, get_args(cl)):
if isinstance(t, TypeVar):
Expand Down
6 changes: 2 additions & 4 deletions tests/test_converter_inheritance.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import collections
import typing
from typing import Hashable, Iterable, Reversible

import pytest
from attrs import define
Expand Down Expand Up @@ -41,9 +41,7 @@ class B(A):
assert converter.structure({"i": 1}, B) == B(2)


@pytest.mark.parametrize(
"typing_cls", [typing.Hashable, typing.Iterable, typing.Reversible]
)
@pytest.mark.parametrize("typing_cls", [Hashable, Iterable, Reversible])
def test_inherit_typing(converter: BaseConverter, typing_cls):
"""Stuff from typing.* resolves to runtime to collections.abc.*.
Expand Down

0 comments on commit 2fe721e

Please sign in to comment.