Search code examples
pythonflake8

python: flake8 cannot find non exising method


If I do something like:

new_list = []
new_list.foo()

flake8 does not return an error for foo() method since it is not a 'list' method.

Is this normal or do I need to configure something?


Solution

  • flake8 does not handle the problem, but PyLint does - issues the no-member warning:

    $ pylint test.py
    No config file found, using default configuration
    ************* Module test
    C:  1, 0: Missing module docstring (missing-docstring)
    C:  1, 0: Invalid constant name "new_list" (invalid-name)
    E:  2, 0: Instance of 'list' has no 'foo' member (no-member)
    

    And, the built-in to PyCharm code analyzer would also warn about the unresolved attribute:

    enter image description here