from typing import Any, Final
CONSTANT: Final = 2015
def good(result: dict[str, Any]) -> None:
code = 'asdf'
if isinstance(result, dict):
code = result.get('code', code)
reveal_type(code) # N: Revealed type is "Any"
if code == CONSTANT:
reveal_type(code) # N: Revealed type is "Any"
def bad(result: Any) -> None:
code = 'asdf'
if isinstance(result, dict):
code = result.get('code', code)
reveal_type(code) # N: Revealed type is "builtins.str"
if code == CONSTANT:
reveal_type(code) # N: Revealed type is "builtins.str"
Based on real world code for rotki
This feels a little inconsistent / violating of gradual typing
Not exactly sure what if anything we should do, though
Found this via #20660 which makes --warn-unreachable flag raise a diagnostic on the second comparison
Based on real world code for rotki
This feels a little inconsistent / violating of gradual typing
Not exactly sure what if anything we should do, though
Found this via #20660 which makes
--warn-unreachableflag raise a diagnostic on the second comparison