basedpyright's reportInvalidCast rule detects casts that are likely a mistake by validating that the types overlap:
from typing import cast
cast(str, 1)
Conversion of type `Literal[1]` to type `str` may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to `object` first.
(typescript also does the same thing)
it would be nice if pyrefly had a rule for this as well
basedpyright's
reportInvalidCastrule detects casts that are likely a mistake by validating that the types overlap:(typescript also does the same thing)
it would be nice if pyrefly had a rule for this as well