-
-
Notifications
You must be signed in to change notification settings - Fork 306
Open
Labels
Needs PRThis issue is accepted, sufficiently specified and now needs an implementationThis issue is accepted, sufficiently specified and now needs an implementationdecorators
Description
Using astroid 3.3.5
import astroid
module = astroid.parse(
"""
def decorate(obj=None):
if obj is None:
return lambda x: decorate(x)
if isinstance(obj, property):
return property()
return obj
@decorate()
def func() -> str:
return 'foo'
x = func()
"""
)
func = module.body[1]
print(func)
print(func.inferred()[0])
Astroid incorrectly infers this function as Property.func
.
This causes the final line x = func()
to emit an error under pylint:
E1111: Assigning result of a function call, where the function has no return (assignment-from-no-return)
If you change to:
@decorate
def func() -> str:
return 'foo'
Astroid correctly infers this as FunctionDef.func
.
This is a minimized repro of the error reported here dagster-io/dagster#24009
akostyagin
Metadata
Metadata
Assignees
Labels
Needs PRThis issue is accepted, sufficiently specified and now needs an implementationThis issue is accepted, sufficiently specified and now needs an implementationdecorators