From 7e6e77afcd6678b2131a1c90e8db044ade66aca9 Mon Sep 17 00:00:00 2001 From: Lukas Juhrich Date: Thu, 25 Jan 2024 10:35:39 +0100 Subject: [PATCH] [typing] remove more superfluous typing suppressions mypy appearently got a bit better at narrowing and inference. --- ldap_sync/concepts/record.py | 2 +- pycroft/lib/user_deletion.py | 2 +- web/blueprints/finance/__init__.py | 2 +- web/table/lazy_join.py | 5 +---- 4 files changed, 4 insertions(+), 7 deletions(-) diff --git a/ldap_sync/concepts/record.py b/ldap_sync/concepts/record.py index a88003712..a22211186 100644 --- a/ldap_sync/concepts/record.py +++ b/ldap_sync/concepts/record.py @@ -34,7 +34,7 @@ def _canonicalize_to_list( if isinstance(value, list): return list(value) if value == "" or value == b"" or value is None: - return [] # type: ignore + return [] # str, byte, int – or unknown. But good fallback. return [value] # type: ignore diff --git a/pycroft/lib/user_deletion.py b/pycroft/lib/user_deletion.py index cb8c57536..39a60be2a 100644 --- a/pycroft/lib/user_deletion.py +++ b/pycroft/lib/user_deletion.py @@ -79,7 +79,7 @@ def get_archivable_members(session: Session) -> Sequence[ArchivableMemberInfo]: # …and use that to filter out the `do-not-archive` occurrences. .filter(CurrentProperty.property_name.is_(None)) .join(User, User.id == last_mem.c.user_id) - .filter(last_mem.c.mem_end < current_timestamp() - timedelta(days=14)) # type: ignore[no-untyped-call] + .filter(last_mem.c.mem_end < current_timestamp() - timedelta(days=14)) .order_by(last_mem.c.mem_end) .options(joinedload(User.hosts), # joinedload(User.current_memberships), joinedload(User.account, innerjoin=True), joinedload(User.room), diff --git a/web/blueprints/finance/__init__.py b/web/blueprints/finance/__init__.py index c6a52b960..7c21ffa96 100644 --- a/web/blueprints/finance/__init__.py +++ b/web/blueprints/finance/__init__.py @@ -603,7 +603,7 @@ def _create_field_list_and_matched_activities_dict( matched_activities[f"{prefix}-{str(activity.id)}"] = { 'purpose': activity.reference, 'name': activity.other_name, - prefix: entity, # type: ignore[misc] + prefix: entity, 'amount': activity.amount } field_list.append((str(activity.id), BooleanField(str(activity.id), default=True))) diff --git a/web/table/lazy_join.py b/web/table/lazy_join.py index c95e6dcdf..cf7e05711 100644 --- a/web/table/lazy_join.py +++ b/web/table/lazy_join.py @@ -98,10 +98,7 @@ def __init__(self, glue: str = "") -> None: self.glue = glue def __call__(self, func: DecoratedInType) -> DecoratedOutType: - # error: Argument 1 to "__call__" of "IdentityFunction" has incompatible type - # "Callable[_P, LazilyJoined]"; expected "Callable[_P, LazilyJoined]" [arg-type] - # …go home mypy, you're drunk! - @wraps(func) # type: ignore[arg-type] + @wraps(func) def wrapped(*a: _P.args, **kw: _P.kwargs) -> LazilyJoined: return LazilyJoined(func(*a, **kw), glue=self.glue)