diff --git a/astroid/nodes/scoped_nodes.py b/astroid/nodes/scoped_nodes.py index 38d234d26..f9b4a6ed9 100644 --- a/astroid/nodes/scoped_nodes.py +++ b/astroid/nodes/scoped_nodes.py @@ -69,7 +69,7 @@ from astroid.interpreter.dunder_lookup import lookup from astroid.interpreter.objectmodel import ClassModel, FunctionModel, ModuleModel from astroid.manager import AstroidManager -from astroid.nodes import Const, node_classes +from astroid.nodes import Arguments, Const, node_classes ITER_METHODS = ("__iter__", "__getitem__") EXCEPTION_BASE_CLASSES = frozenset({"Exception", "BaseException"}) @@ -1190,7 +1190,6 @@ def type(self): :returns: 'method' if this is a method, 'function' otherwise. :rtype: str """ - # pylint: disable=no-member if self.args.arguments and self.args.arguments[0].name == "self": if isinstance(self.parent.scope(), ClassDef): return "method" @@ -1214,11 +1213,8 @@ def __init__(self, lineno=None, col_offset=None, parent=None): :type: dict(str, NodeNG) """ - self.args = [] - """The arguments that the function takes. - - :type: Arguments or list - """ + self.args: Arguments + """The arguments that the function takes.""" self.body = [] """The contents of the function body. @@ -1228,11 +1224,10 @@ def __init__(self, lineno=None, col_offset=None, parent=None): super().__init__(lineno, col_offset, parent) - def postinit(self, args, body): + def postinit(self, args: Arguments, body): """Do some setup after initialisation. :param args: The arguments that the function takes. - :type args: Arguments :param body: The contents of the function body. :type body: list(NodeNG) @@ -1276,10 +1271,6 @@ def argnames(self): :returns: The names of the arguments. :rtype: list(str) """ - # pylint: disable=no-member; github.com/pycqa/astroid/issues/291 - # args is in fact redefined later on by postinit. Can't be changed - # to None due to a strong interaction between Lambda and FunctionDef. - if self.args.arguments: # maybe None with builtin functions names = _rec_get_names(self.args.arguments) else: @@ -1319,10 +1310,6 @@ def scope_lookup(self, node, name, offset=0): globals or builtin). :rtype: tuple(str, list(NodeNG)) """ - # pylint: disable=no-member; github.com/pycqa/astroid/issues/291 - # args is in fact redefined later on by postinit. Can't be changed - # to None due to a strong interaction between Lambda and FunctionDef. - if node in self.args.defaults or node in self.args.kw_defaults: frame = self.parent.frame() # line offset to avoid that def func(f=func) resolve the default @@ -1440,7 +1427,7 @@ def __init__(self, name=None, doc=None, lineno=None, col_offset=None, parent=Non # pylint: disable=arguments-differ; different than Lambdas def postinit( self, - args, + args: Arguments, body, decorators=None, returns=None, @@ -1450,7 +1437,6 @@ def postinit( """Do some setup after initialisation. :param args: The arguments that the function takes. - :type args: Arguments or list :param body: The contents of the function body. :type body: list(NodeNG)