pylint raises `AttributeError` exception on `functool` import

Created on 20 Sep 2016  Â·  10Comments  Â·  Source: PyCQA/pylint

summary

When functool imported, pylint tries to access visit_joinedstr in TreeRebuilder3k (astroid: rebuild.py).

Apparently, the node points to line 286 col 20 (I presume, in the functool.py -- please disregard this paragraph otherwise):

        args.extend(f"{k}={v!r}" for (k, v) in self.keywords.items())
                   ^^^

I also created astroid issue #362 (sorry for noise, I am not sure what is the best place).

Steps to reproduce

  1. Create test.py:
#!/usr/bin/env python3

import functools
  1. run pylint:
> pylint test.py

Current behavior

No config file found, using default configuration
************* Module test
C:  1, 0: Missing module docstring (missing-docstring)
Traceback (most recent call last):
  File "/usr/local/bin/pylint", line 11, in <module>
    sys.exit(run_pylint())
  File "/usr/local/lib/python3.6/site-packages/pylint/__init__.py", line 13, in run_pylint
    Run(sys.argv[1:])
  File "/usr/local/lib/python3.6/site-packages/pylint/lint.py", line 1310, in __init__
    linter.check(args)
  File "/usr/local/lib/python3.6/site-packages/pylint/lint.py", line 732, in check
    self._do_check(files_or_modules)
  File "/usr/local/lib/python3.6/site-packages/pylint/lint.py", line 863, in _do_check
    self.check_astroid_module(ast_node, walker, rawcheckers, tokencheckers)
  File "/usr/local/lib/python3.6/site-packages/pylint/lint.py", line 944, in check_astroid_module
    walker.walk(ast_node)
  File "/usr/local/lib/python3.6/site-packages/pylint/utils.py", line 944, in walk
    self.walk(child)
  File "/usr/local/lib/python3.6/site-packages/pylint/utils.py", line 941, in walk
    cb(astroid)
  File "/usr/local/lib/python3.6/site-packages/pylint/checkers/variables.py", line 1037, in visit_import
    module = next(node.infer_name_module(parts[0]))
  File "/usr/local/lib/python3.6/site-packages/astroid/context.py", line 49, in cache_generator
    for result in generator:
  File "/usr/local/lib/python3.6/site-packages/astroid/bases.py", line 302, in wrapped
    for res in _func(node, context, **kwargs):
  File "/usr/local/lib/python3.6/site-packages/astroid/inference.py", line 123, in infer_import
    yield self.do_import_module(name)
  File "/usr/local/lib/python3.6/site-packages/astroid/mixins.py", line 129, in do_import_module
    relative_only=level and level >= 1)
  File "/usr/local/lib/python3.6/site-packages/astroid/scoped_nodes.py", line 492, in import_module
    return MANAGER.ast_from_module_name(absmodname)
  File "/usr/local/lib/python3.6/site-packages/astroid/manager.py", line 136, in ast_from_module_name
    return self.ast_from_file(filepath, modname, fallback=False)
  File "/usr/local/lib/python3.6/site-packages/astroid/manager.py", line 86, in ast_from_file
    return AstroidBuilder(self).file_build(filepath, modname)
  File "/usr/local/lib/python3.6/site-packages/astroid/builder.py", line 141, in file_build
    module = self._data_build(data, modname, path)
  File "/usr/local/lib/python3.6/site-packages/astroid/builder.py", line 185, in _data_build
    module = builder.visit_module(node, modname, node_file, package)
  File "/usr/local/lib/python3.6/site-packages/astroid/rebuilder.py", line 154, in visit_module
    newnode.body = [self.visit(child, newnode) for child in node.body]
  File "/usr/local/lib/python3.6/site-packages/astroid/rebuilder.py", line 154, in <listcomp>
    newnode.body = [self.visit(child, newnode) for child in node.body]
  File "/usr/local/lib/python3.6/site-packages/astroid/rebuilder.py", line 167, in visit
    return visit_method(node, parent, assign_ctx)
  File "/usr/local/lib/python3.6/site-packages/astroid/rebuilder.py", line 957, in visit_classdef
    newnode = super(TreeRebuilder3k, self).visit_classdef(node, parent, assign_ctx)
  File "/usr/local/lib/python3.6/site-packages/astroid/rebuilder.py", line 357, in visit_classdef
    for child in node.body]
  File "/usr/local/lib/python3.6/site-packages/astroid/rebuilder.py", line 357, in <listcomp>
    for child in node.body]
  File "/usr/local/lib/python3.6/site-packages/astroid/rebuilder.py", line 167, in visit
    return visit_method(node, parent, assign_ctx)
  File "/usr/local/lib/python3.6/site-packages/astroid/rebuilder.py", line 543, in visit_functiondef
    assign_ctx=assign_ctx)
  File "/usr/local/lib/python3.6/site-packages/astroid/rebuilder.py", line 528, in _visit_functiondef
    for child in node.body]
  File "/usr/local/lib/python3.6/site-packages/astroid/rebuilder.py", line 528, in <listcomp>
    for child in node.body]
  File "/usr/local/lib/python3.6/site-packages/astroid/rebuilder.py", line 167, in visit
    return visit_method(node, parent, assign_ctx)
  File "/usr/local/lib/python3.6/site-packages/astroid/rebuilder.py", line 447, in visit_expr
    newnode.value = self.visit(node.value, newnode, assign_ctx)
  File "/usr/local/lib/python3.6/site-packages/astroid/rebuilder.py", line 167, in visit
    return visit_method(node, parent, assign_ctx)
  File "/usr/local/lib/python3.6/site-packages/astroid/rebuilder.py", line 315, in visit_call
    for child in node.args]
  File "/usr/local/lib/python3.6/site-packages/astroid/rebuilder.py", line 315, in <listcomp>
    for child in node.args]
  File "/usr/local/lib/python3.6/site-packages/astroid/rebuilder.py", line 167, in visit
    return visit_method(node, parent, assign_ctx)
  File "/usr/local/lib/python3.6/site-packages/astroid/rebuilder.py", line 549, in visit_generatorexp
    newnode.elt = self.visit(node.elt, newnode, assign_ctx)
  File "/usr/local/lib/python3.6/site-packages/astroid/rebuilder.py", line 165, in visit
    visit_method = getattr(self, visit_name)
AttributeError: 'TreeRebuilder3k' object has no attribute 'visit_joinedstr'

Expected behavior

No exception.

pylint --version output

> pylint --version
No config file found, using default configuration
pylint 1.6.4, 
astroid 1.4.8
Python 3.6.0b1 (default, Sep 19 2016, 19:24:15) 
[GCC 4.9.1]

Most helpful comment

I'm still getting this - looks like a fix was merged, but hasn't been released yet. Now that python 3.6 is official, is there another release coming soon?

All 10 comments

https://github.com/PyCQA/astroid/pull/365 will likely fix this when it lands. This problem is caused because we don't support Python 3.6 yet, it is probably going to happen soon, but no need to have this issue opened until then.

I'm still getting this - looks like a fix was merged, but hasn't been released yet. Now that python 3.6 is official, is there another release coming soon?

installing Astroid from git helps indeed; however not-callable check started to behave differently for me after that, i am still trying to understand is that an expected behavior or not

UPD: seems it's not:

$ cat test_lib.py ; pylint test_lib.py | head
def lower_strings(string_list):
    return [s.lower() for s in string_list]
************* Module test_lib
E:  2,12: s.lower is not callable (not-callable)

+1

I am still getting this today with pylint==1.6.4 and astroid==1.4.9.

The fix from https://github.com/PyCQA/astroid/pull/365 was merged on Oct 24 and Astroid 1.4.9 was released on Dec 18. I would have expected it to be included.

It will be included with Pylint 2.0 and astroid 1.5.

@PCManticore any idea when those will come? (just an estimation - days or weeks or months or years)

When the planned release is ready for shipping. I can't really estimate it,
since I can't fully focus on the project lately, but once we finish all the
issues from the 2.0 milestone, we will launch it.

On Jan 19, 2017 10:30 AM, "Valentin Iovene" notifications@github.com
wrote:

@PCManticore https://github.com/PCManticore any idea when those will
come? (just an estimation - days or weeks or months or years)

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/PyCQA/pylint/issues/1113#issuecomment-273711154, or mute
the thread
https://github.com/notifications/unsubscribe-auth/AAbWpqLnW06K2HeWR9JxYBigwBY0aSE5ks5rTx8SgaJpZM4KB5wI
.

Which versions do you suggest if Python 3.6.0 is not supported?

@DSupuran-USPM Python 2.7, 3.3, 3.4, and 3.5 are supported.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

DGalt picture DGalt  Â·  3Comments

elirnm picture elirnm  Â·  3Comments

Hubro picture Hubro  Â·  3Comments

mrginglymus picture mrginglymus  Â·  3Comments

pylint-bot picture pylint-bot  Â·  3Comments