Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getting "AttributeError: 'NoneType' object has no attribute 'statement'" for small piece of code #2526

Comments

@wdv4758h
Copy link

Steps to reproduce

I have strip the code to make it easier to reproduce.

  1. get this small piece of code
def f(*args):
    from multiprocessing import Process
    args = (42, *args)
    process = Process(target=f, args=args)
  1. run pylint
pylint -E test.py 

Current behavior

pylint crash in an exception

Traceback (most recent call last):
  File "/home/wdv4758h/py/venv/bin/pylint", line 11, in <module>
    sys.exit(run_pylint())
  File "/home/wdv4758h/py/venv/lib/python3.6/site-packages/pylint/__init__.py", line 20, in run_pylint
    Run(sys.argv[1:])
  File "/home/wdv4758h/py/venv/lib/python3.6/site-packages/pylint/lint.py", line 1595, in __init__
    linter.check(args)
  File "/home/wdv4758h/py/venv/lib/python3.6/site-packages/pylint/lint.py", line 925, in check
    self._do_check(files_or_modules)
  File "/home/wdv4758h/py/venv/lib/python3.6/site-packages/pylint/lint.py", line 1058, in _do_check
    self.check_astroid_module(ast_node, walker, rawcheckers, tokencheckers)
  File "/home/wdv4758h/py/venv/lib/python3.6/site-packages/pylint/lint.py", line 1141, in check_astroid_module
    walker.walk(ast_node)
  File "/home/wdv4758h/py/venv/lib/python3.6/site-packages/pylint/utils.py", line 1269, in walk
    self.walk(child)
  File "/home/wdv4758h/py/venv/lib/python3.6/site-packages/pylint/utils.py", line 1269, in walk
    self.walk(child)
  File "/home/wdv4758h/py/venv/lib/python3.6/site-packages/pylint/utils.py", line 1269, in walk
    self.walk(child)
  File "/home/wdv4758h/py/venv/lib/python3.6/site-packages/pylint/utils.py", line 1266, in walk
    cb(astroid)
  File "/home/wdv4758h/py/venv/lib/python3.6/site-packages/pylint/checkers/typecheck.py", line 1087, in visit_call
    has_no_context_positional_variadic = _no_context_variadic_positional(node)
  File "/home/wdv4758h/py/venv/lib/python3.6/site-packages/pylint/checkers/typecheck.py", line 533, in _no_context_variadic_positional
    return _no_context_variadic(node, scope.args.vararg, astroid.Starred, variadics)
  File "/home/wdv4758h/py/venv/lib/python3.6/site-packages/pylint/checkers/typecheck.py", line 560, in _no_context_variadic
    inferred_statement = inferred.statement()
  File "/home/wdv4758h/py/venv/lib/python3.6/site-packages/astroid/node_classes.py", line 451, in statement
    return self.parent.statement()
AttributeError: 'NoneType' object has no attribute 'statement'

Expected behavior

At least don't have exception

pylint --version output

pylint 2.2.0-dev
astroid 2.0.4
Python 3.6.5 (default, Apr  1 2018, 05:46:30)
[GCC 7.3.0]

tested with current master 20694325dde16377dd5e295ccdd82dffa68ce7aa and serveral stable releases

@PCManticore
Copy link
Contributor

This is fixed in astroid's master, thanks for creating an issue!

@wdv4758h
Copy link
Author

wow, that's fast

We just discover this issue with our company codebase today 😛

clrpackages pushed a commit to clearlinux-pkgs/astroid that referenced this issue Nov 26, 2018
…result result of a class with an uninferable ``__call__`` method.

Christoph Reiter (1):
      brain_gi: use Exception as a base class for classes inheriting from Exception

Claudiu Popa (53):
      Add support for `argparse.Namespace`
      Simplify the code now that every class is newstyle class
      `async` functions are now inferred as `AsyncGenerator` when inferring their call result.
      Update the PR template to be more user friendly
      Filter out ``Uninferable`` when inferring the call result result of a class with an uninferable ``__call__`` method.
      Mark this release as a dev release. Close #608
      Disable lint error
      Add digest_size parameter to hashlib.blake2b and blake2s
      Correct line numbering for f-strings for complex embedded expressions
      Remove test depending on mechanize, we'll most likely not install every library we have brain tips for
      Use skipif instead of the missing skipunless and remove test for pygtk
      pytest why are you being so weird? add missing reason keyword argument
      Pass parameters by keyword name when inferring sequences.
      ``threading.Lock.acquire`` has the ``timeout`` parameter now.
      unused-variable is now unused-import
      wildcard-import is no longer emitted on __init__ files
      Switch to latest pylint's from Github
      Remove the absolute to relative path transform for coverage, which is no longer needed as tests are not installed with the package anymore
      Use the correct coverage file and make sure to delete the correct coverage file
      Use --append and drop the use of .envname
      Rename asspath to assign_path to be more indicative of what it actually means
      Add the pre-commit hook
      Initial formatting of astroid
      Add black step in tox.ini and Travis, as well as the badge
      Switch to stages for travis jobs
      Change the line endings of the pylint config file
      Let formatting be handled by black
      Use copy_context where it makes sense
      Simplify the creation of extra_context for _infer_call
      Remove the restore_path() method
      Replace copy.copy() with a simple set() call
      Replace checks against None and Uninferable to boolean checks
      Replace a nested for loop with itertools.product
      Remove unneeded comment
      Use a generator expression for _multiply_seq_by_int
      Use itertools.chain to join multiple generators together
      Remove some unneeded comments and use yield from
      Use None as a sentinel
      Add some caching to the transforms and skip non nodes in visit_generic
      Use generators for string joining instead of creating temporary lists
      Cache the result of get_assign_nodes
      Remove Python 2 branches
      YES is gone, we're using Uninferable for quite some time now
      Use yield from
      Update some leftover docstrings
      Lose an indentation level in ancestors() by continuing if recursing wasn't passed
      Disable useless-supression for now
      Replace a nested for loop with a product() call
      Pass a parent in raw_building when building a new Function or Class
      Reuse the cls variable inferred earlier
      Revert "Pass a parent in raw_building when building a new Function or Class"
      Don't call inference in the functools transform
      Prepare 2.1.0

Daniel Martin (1):
      Multiple "value" or "slice" values on subscript inference.

David Poirier (1):
      fix hashlib.blake2* signatures

HQupgradeHQ (1):
      text

Jeff Widman (1):
      Fix typo

Serhiy Storchaka (1):
      Reflect AST changes in Python 3.8.

wgehalo (1):
      Add blake2s to hashing algorithims.

What's New in astroid 2.1.0?
============================
Release Date: 2018-11-25

   * ``threading.Lock.acquire`` has the ``timeout`` parameter now.

     Close pylint-dev/pylint#2457

   * Pass parameters by keyword name when inferring sequences.

     Close pylint-dev/pylint#2526

   * Correct line numbering for f-strings for complex embedded expressions

     When a f-string contained a complex expression, such as an attribute access,

(NEWS truncated at 15 lines)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment