Skip to content

Commit 0f467c6

Browse files
committed
Remove some unnecessary casts to Any
1 parent 456dcbd commit 0f467c6

File tree

3 files changed

+4
-5
lines changed

3 files changed

+4
-5
lines changed

mypy/fastparse.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -351,8 +351,7 @@ def parse_type_comment(
351351
else:
352352
extra_ignore = TYPE_IGNORE_PATTERN.match(type_comment)
353353
if extra_ignore:
354-
# Typeshed has a non-optional return type for group!
355-
tag: str | None = cast(Any, extra_ignore).group(1)
354+
tag: str | None = extra_ignore.group(1)
356355
ignored: list[str] | None = parse_type_ignore_tag(tag)
357356
if ignored is None:
358357
if errors is not None:

mypy/semanal.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5810,7 +5810,7 @@ def _get_node_for_class_scoped_import(
58105810
# mypyc is absolutely convinced that `symbol_node` narrows to a Var in the following,
58115811
# when it can also be a FuncBase. Once fixed, `f` in the following can be removed.
58125812
# See also https://github.com/mypyc/mypyc/issues/892
5813-
f = cast(Any, lambda x: x)
5813+
f = cast(Callable[[object], Any], lambda x: x)
58145814
if isinstance(f(symbol_node), (Decorator, FuncBase, Var)):
58155815
# For imports in class scope, we construct a new node to represent the symbol and
58165816
# set its `info` attribute to `self.type`.

mypyc/codegen/literals.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,13 @@ def record_literal(self, value: LiteralValue) -> None:
5555
tuple_literals = self.tuple_literals
5656
if value not in tuple_literals:
5757
for item in value:
58-
self.record_literal(cast(Any, item))
58+
self.record_literal(cast(LiteralValue, item))
5959
tuple_literals[value] = len(tuple_literals)
6060
elif isinstance(value, frozenset):
6161
frozenset_literals = self.frozenset_literals
6262
if value not in frozenset_literals:
6363
for item in value:
64-
self.record_literal(cast(Any, item))
64+
self.record_literal(cast(LiteralValue, item))
6565
frozenset_literals[value] = len(frozenset_literals)
6666
else:
6767
assert False, "invalid literal: %r" % value

0 commit comments

Comments
 (0)