astroid icon indicating copy to clipboard operation
astroid copied to clipboard

Decouple FunctionDef from Lambda

Open PCManticore opened this issue 9 years ago • 2 comments

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

PCManticore avatar Dec 12 '15 17:12 PCManticore

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)

jacobtylerwalls avatar May 01 '22 14:05 jacobtylerwalls

But contrary to the top of the issue, do not necessarily make Lambda inherit from FunctionDef.

jacobtylerwalls avatar May 01 '22 14:05 jacobtylerwalls

Fixed in #2115, thanks @DanielNoord!

jacobtylerwalls avatar Apr 23 '23 15:04 jacobtylerwalls