Skip to content

Commit f3f9ad3

Browse files
committed
Enable warn_unused_ignores and drop stale type: ignore comments
The mypy-typemap fork no longer needs these ignores; turn on warn_unused_ignores so future drift is caught.
1 parent 9aeec1d commit f3f9ad3

5 files changed

Lines changed: 15 additions & 13 deletions

File tree

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,3 +75,6 @@ include = ["pyproject.toml", "typemap/**/*.py", "typemap_extensions/**/*.py", "t
7575

7676
[tool.ruff.format]
7777
quote-style = "preserve"
78+
79+
[tool.mypy]
80+
warn_unused_ignores = true

typemap/type_eval/_eval_call.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def _get_bound_type_args_from_bound_args(
8787
and tv.__bound__
8888
and typing_extensions.is_typeddict(tv.__bound__)
8989
):
90-
tp = typing.TypedDict(f"**{param.name}", bound.kwargs) # type: ignore[misc, operator]
90+
tp = typing.TypedDict(f"**{param.name}", bound.kwargs) # type: ignore[misc]
9191
vars[tv] = tp
9292
# trivial type[T] bindings
9393
elif (

typemap/type_eval/_eval_operators.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ def _create_updated_class(
357357
bases = tuple(
358358
b.alias_type()
359359
if b.cls is not typing.Generic
360-
else typing.Generic[t.__type_params__] # type: ignore[index]
360+
else typing.Generic[t.__type_params__]
361361
for b in box.bases
362362
)
363363

@@ -696,9 +696,9 @@ def _callable_type_to_method(name, typ, ctx):
696696
# Override the receiver type with type[Self].
697697
if name == "__init_subclass__" and isinstance(cls, typing.TypeVar):
698698
# For __init_subclass__ generic on cls: T, keep type[T]
699-
cls_typ = type[cls] # type: ignore[name-defined]
699+
cls_typ = type[cls]
700700
else:
701-
cls_typ = type[typing.Self] # type: ignore[name-defined]
701+
cls_typ = type[typing.Self]
702702
cls_param = Param[typing.Literal["cls"], cls_typ, quals]
703703
typ = typing.Callable[Params[cls_param, *param_list], ret]
704704
elif head is staticmethod:

typemap/type_eval/_eval_typing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ def _eval_ty_or_list(obj):
460460

461461

462462
@_eval_types_impl.register
463-
def _eval_union(obj: typing.Union, ctx: EvalContext): # type: ignore
463+
def _eval_union(obj: typing.Union, ctx: EvalContext):
464464
args: typing.Sequence[typing.Any] = obj.__args__
465465
new_args = tuple(_eval_types(arg, ctx) for arg in args)
466466
return typing.Union[new_args]

typemap/type_eval/_typing_inspect.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def is_special_form(t: Any, form: Any) -> bool:
3535
Returns:
3636
True if t is the special form or a generic alias with that origin
3737
"""
38-
return t is form or (is_generic_alias(t) and get_origin(t) is form) # type: ignore [comparison-overlap]
38+
return t is form or (is_generic_alias(t) and get_origin(t) is form)
3939

4040

4141
def is_generic_alias(t: Any) -> TypeGuard[GenericAlias]:
@@ -44,7 +44,7 @@ def is_generic_alias(t: Any) -> TypeGuard[GenericAlias]:
4444

4545
def is_valid_type_arg(t: Any) -> bool:
4646
return isinstance(t, type) or (
47-
is_generic_alias(t) and get_origin(t) is not Unpack # type: ignore [comparison-overlap]
47+
is_generic_alias(t) and get_origin(t) is not Unpack
4848
)
4949

5050

@@ -84,7 +84,7 @@ def is_type_var_or_tuple(t: Any) -> bool:
8484
def is_type_var_tuple_unpack(t: Any) -> TypeGuard[GenericAlias]:
8585
return (
8686
is_generic_alias(t)
87-
and get_origin(t) is Unpack # type: ignore [comparison-overlap]
87+
and get_origin(t) is Unpack
8888
and is_type_var_tuple(get_args(t)[0])
8989
)
9090

@@ -98,7 +98,7 @@ def is_generic_type_alias(t: Any) -> TypeGuard[GenericAlias]:
9898

9999

100100
def is_annotated(t: Any) -> TypeGuard[Annotated[Any, ...]]:
101-
return is_generic_alias(t) and get_origin(t) is Annotated # type: ignore [comparison-overlap]
101+
return is_generic_alias(t) and get_origin(t) is Annotated
102102

103103

104104
def is_forward_ref(t: Any) -> TypeGuard[ForwardRef]:
@@ -121,9 +121,8 @@ def contains_forward_refs(t: Any) -> bool:
121121

122122

123123
def is_union_type(t: Any) -> TypeGuard[UnionType]:
124-
return (
125-
(is_generic_alias(t) and get_origin(t) is Union) # type: ignore [comparison-overlap]
126-
or isinstance(t, UnionType)
124+
return (is_generic_alias(t) and get_origin(t) is Union) or isinstance(
125+
t, UnionType
127126
)
128127

129128

@@ -132,7 +131,7 @@ def is_optional_type(t: Any) -> TypeGuard[UnionType]:
132131

133132

134133
def is_literal(t: Any) -> bool:
135-
return is_generic_alias(t) and get_origin(t) is Literal # type: ignore [comparison-overlap]
134+
return is_generic_alias(t) and get_origin(t) is Literal
136135

137136

138137
def get_head(t: Any) -> type | None:

0 commit comments

Comments
 (0)