Skip to content

Commit

Permalink
Update suppressions for mypy 1.7.1
Browse files Browse the repository at this point in the history
  • Loading branch information
mthuurne committed Dec 4, 2023
1 parent d45e3c9 commit 693c980
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/dataclass_binder/_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def _collect_type(field_type: type, context: str) -> type | Binder[Any]:
return field_type
elif field_type is type:
# https://github.com/python/mypy/issues/13026
return cast(type, type[Any]) # type: ignore[index]
return cast(type, type[Any]) # type: ignore[misc]
elif hasattr(field_type, "__class_getitem__"):
raise TypeError(f"Field '{context}' needs type argument(s)")
else:
Expand Down Expand Up @@ -100,13 +100,13 @@ def _collect_type(field_type: type, context: str) -> type | Binder[Any]:
raise TypeError(f"type[...] annotation for '{context}' must have exactly one type argument") from None
bases = get_args(arg) if get_origin(arg) in (UnionType, Union) else (arg,)
if Any in bases:
return cast(type, type[Any]) # type: ignore[index]
return cast(type, type[Any]) # type: ignore[misc]
# Convert 'type[A | B]' to 'type[A] | type[B]'.
collected_types = []
for base in bases:
if not isinstance(base, type):
raise TypeError(f"type[...] annotation for '{context}' must have a type as its argument")
collected_types.append(type[base]) # type: ignore[index]
collected_types.append(type[base]) # type: ignore[misc]
return reduce(operator.__or__, collected_types)
else:
raise TypeError(f"Field '{context}' has unsupported generic type '{origin.__name__}'")
Expand Down Expand Up @@ -432,7 +432,7 @@ def _bind_to_class(self, toml_dict: Mapping[str, Any], instance: T | None, conte
if instance is None:
return self._dataclass(**parsed)
else:
return replace(instance, **parsed) # type: ignore[type-var, misc]
return replace(instance, **parsed) # type: ignore[type-var]

def format_toml(self) -> Iterator[str]:
"""
Expand Down

0 comments on commit 693c980

Please sign in to comment.