-
Notifications
You must be signed in to change notification settings - Fork 142
Closed
astral-sh/ruff
#18431Labels
bugSomething isn't workingSomething isn't workinggood first issueGood for newcomersGood for newcomershelp wantedContributions especially welcomeContributions especially welcomeruntime semanticsAccurate modeling of how Python's semantics work at runtimeAccurate modeling of how Python's semantics work at runtime
Description
Summary
ty currently emits a false-positive diagnostic on this snippet:
from typing import reveal_type
x = lambda y: y
# error[unresolved-attribute] Type `(y) -> Unknown` has no attribute `__code__`
reveal_type(x.__code__) # revealed: Unknownhttps://play.ty.dev/84a1b067-9670-4463-82ce-0fc025997c91
All lambda functions are instances of types.FunctionType, so all attributes available on types.FunctionType instances should also be available on lambdas.
Following astral-sh/ruff#18242 this is easy to fix: we just need to change this line so that it calls CallableType::function_like() rather than CallableType::single() (and add some tests).
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workinggood first issueGood for newcomersGood for newcomershelp wantedContributions especially welcomeContributions especially welcomeruntime semanticsAccurate modeling of how Python's semantics work at runtimeAccurate modeling of how Python's semantics work at runtime