Skip to content

Commit

Permalink
Fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
Tinche committed Jan 12, 2025
1 parent 089a3d1 commit 972e6cb
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/cattrs/gen/_shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
from ..fns import raise_error

if TYPE_CHECKING:
from collections.abc import Mapping
from ..converters import BaseConverter

T = TypeVar("T")


def find_structure_handler(
a: Attribute, type: Any, c: BaseConverter, prefer_attrs_converters: bool = False
) -> StructureHook | None:
Expand Down Expand Up @@ -69,7 +69,9 @@ def handler(v, _, _h=handler):
def get_fields_annotated_by(cls: type, annotation_type: type[T] | T) -> dict[str, T]:
type_hints = get_type_hints(cls, include_extras=True)
# Support for both AttributeOverride and AttributeOverride()
annotation_type_ = annotation_type if isinstance(annotation_type, type) else type(annotation_type)
annotation_type_ = (
annotation_type if isinstance(annotation_type, type) else type(annotation_type)
)

# First pass of filtering to get only fields with annotations
fields_with_annotations = (
Expand All @@ -88,4 +90,8 @@ def get_fields_annotated_by(cls: type, annotation_type: type[T] | T) -> dict[str
)

# We still might have some `None` values from previous filtering.
return {field_name: annotation for field_name, annotation in fields_with_specific_annotation if annotation}
return {
field_name: annotation
for field_name, annotation in fields_with_specific_annotation
if annotation
}

0 comments on commit 972e6cb

Please sign in to comment.