From 972e6cbde40e1f3508b57e3a550e2286c2079331 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tin=20Tvrtkovi=C4=87?= Date: Sun, 12 Jan 2025 22:51:48 +0100 Subject: [PATCH] Fix lint --- src/cattrs/gen/_shared.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/cattrs/gen/_shared.py b/src/cattrs/gen/_shared.py index fca7c87a..809e9b45 100644 --- a/src/cattrs/gen/_shared.py +++ b/src/cattrs/gen/_shared.py @@ -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: @@ -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 = ( @@ -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 + }