You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
build_scope decides whether a callable has a receiver by exact string membership against
unparsed decorator text (codeanalyzer/dataflow/access_paths.py:255-257):
decorators= {ast.unparse(d) fordinfunc.decorator_list}
ifparams[0] in ("self", "cls") and"staticmethod"notindecorators:
scope.self_name=params[0]
Only the bare spelling staticmethod is recognised. Any other spelling of the same builtin — @builtins.staticmethod, or from builtins import staticmethod as sm — fails the membership
test, so a static method gets a receiver it does not have, and scope.self_name is later added
as a definition (access_paths.py:472-473), producing a spurious def in the L3/L4 dataflow.
Problem
build_scopedecides whether a callable has a receiver by exact string membership againstunparsed decorator text (
codeanalyzer/dataflow/access_paths.py:255-257):Only the bare spelling
staticmethodis recognised. Any other spelling of the same builtin —@builtins.staticmethod, orfrom builtins import staticmethod as sm— fails the membershiptest, so a static method gets a receiver it does not have, and
scope.self_nameis later addedas a definition (
access_paths.py:472-473), producing a spurious def in the L3/L4 dataflow.Verified on
a0b94ff:Scope boundary
The receiver-binding predicate only. Does not restructure the decorator schema (#128), and does
not touch
classmethodorpropertyhandling.Goals
staticmethodby resolved identity, not by unparsed spellingself_name is Nonefor each spellingCaveats and known risks
selforcls; a staticmethod with a normalfirst parameter name is unaffected.
qualified_name, which Jedi already computes and storesin
accessed_symbols; Structured decorator representation: PyDecorator on callable, class, attribute, parameter #128 would make it directly available on the decorator.Definition of done
@builtins.staticmethod def f(self, x)yieldsself_name is Noneself_name is None@staticmethodand undecorated methods keep their current behaviour