From b323833f58b9216c4d2432f33c61f0c852483df1 Mon Sep 17 00:00:00 2001 From: cpopa Date: Mon, 5 May 2014 16:55:27 +0300 Subject: Fix a potential AttributeError when checking for constructor arguments. --- checkers/typecheck.py | 2 +- test/input/func_arguments.py | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/checkers/typecheck.py b/checkers/typecheck.py index 4cb406f..79774de 100644 --- a/checkers/typecheck.py +++ b/checkers/typecheck.py @@ -98,7 +98,7 @@ def _determine_callable(callable_obj): except astroid.NotFoundError: new = None - if not new or new.parent.name == 'object': + if not new or new.parent.scope().name == 'object': try: # Use the last definition of __init__. callable_obj = callable_obj.local_attr('__init__')[-1] diff --git a/test/input/func_arguments.py b/test/input/func_arguments.py index 1c27ef2..b607699 100644 --- a/test/input/func_arguments.py +++ b/test/input/func_arguments.py @@ -81,3 +81,20 @@ def method_tests(): demo.decorated_method() DemoClass.decorated_method(demo) +# Test a regression (issue #234) +import sys + +# pylint: disable=too-few-public-methods +class Text(object): + """ Regression """ + + if sys.version_info > (3,): + def __new__(cls): + """ empty """ + return object.__new__(cls) + else: + def __new__(cls): + """ empty """ + return object.__new__(cls) + +Text() -- cgit v1.2.1