astroid
astroid copied to clipboard
Decouple FunctionDef from Lambda
They share some common code through inheritance such as display_type and scope_lookup, leading to a weird ontology where a Lambda is an ancestor of a FunctionDef, while they should be in fact switched.
>>> node = FunctionDef()
>>> isinstance(node, Lambda) # should be false
>>> node = Lambda()
>>> isinstance(node, FunctionDef) # should be true
Consider merging 95f8a87 in astroid 3.0 after auditing uses of isinstance(x, nodes.Lambda) which will behave differently (see e.g. https://github.com/PyCQA/pylint/pull/6479)
But contrary to the top of the issue, do not necessarily make Lambda inherit from FunctionDef.
Fixed in #2115, thanks @DanielNoord!