-
Notifications
You must be signed in to change notification settings - Fork 216
Closed
astral-sh/ruff
#17643Labels
attribute accessInstance attributes, class attributes, etc.Instance attributes, class attributes, etc.narrowingrelated to flow-sensitive type narrowingrelated to flow-sensitive type narrowing
Milestone
Description
Currently, red-knot only supports narrowing on a name expression like x but not on attributes (foo.x) or subscripts (foo[0]).
For example the following is a false negative as detected in astral-sh/ruff#16888 (comment):
from typing import Callable, Optional
class Config:
formatting_function: Optional[Callable[[], None]] = None
def process(config: Config):
reveal_type(config.formatting_function) # revealed: () -> None | None
if config.formatting_function:
# red-knot: Object of type `None` is not callable [lint:call-non-callable]
config.formatting_function()Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
attribute accessInstance attributes, class attributes, etc.Instance attributes, class attributes, etc.narrowingrelated to flow-sensitive type narrowingrelated to flow-sensitive type narrowing