You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With a cast() in a lambda, --warn-redundant-cast tells me to remove the cast, but then I get a different error if I actually do so. This is a regression in 0.790.
$ cat tmp/matchcast.py
from typing import cast, Match, Pattern
def _get_nodes(key: str, rgx: Pattern[str]) -> None:
matches = rgx.fullmatch(key)
if matches is None:
return
sorted(
matches.groupdict().items(),
key=lambda g: cast(Match[str], matches).start(g[0]),
)
$ mypy --warn-redundant-casts tmp/matchcast.py
tmp/matchcast.py:11: error: Redundant cast to "Match[str]"
Found 1 error in 1 file (checked 1 source file)
And if I remove the cast:
$ mypy --warn-redundant-casts tmp/matchcast.py
tmp/matchcast.py:11: error: Item "None" of "Optional[Match[str]]" has no attribute "start"
Found 1 error in 1 file (checked 1 source file)
Your Environment
Mypy version used: 0.790
Mypy command-line flags: --warn-redundant-casts
Python version used: 3.6
Operating system and version: Ubuntu
The text was updated successfully, but these errors were encountered:
With a
cast()
in a lambda,--warn-redundant-cast
tells me to remove the cast, but then I get a different error if I actually do so. This is a regression in 0.790.And if I remove the cast:
Your Environment
--warn-redundant-casts
The text was updated successfully, but these errors were encountered: