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

AttributeError: 'NoneType' object has no attribute 'lineno' #450

Closed
mirrorrim opened this issue Jan 18, 2019 · 3 comments
Closed

AttributeError: 'NoneType' object has no attribute 'lineno' #450

mirrorrim opened this issue Jan 18, 2019 · 3 comments
Assignees
Labels
bug Something isn't working pr-merged

Comments

@mirrorrim
Copy link

Bug report

What's wrong

When I run flake8 with wemake-python-styleguide 0.6.2, I see exception traceback.
Something simular to #423

traceback

multiprocessing.pool.RemoteTraceback: 
"""
Traceback (most recent call last):
  File "/usr/lib/python3.7/multiprocessing/pool.py", line 121, in worker
    result = (True, func(*args, **kwds))
  File "/home/developer2/.local/share/virtualenvs/backend-0eAQt0K2/lib/python3.7/site-packages/flake8/checker.py", line 682, in _run_checks
    return checker.run_checks()
  File "/home/developer2/.local/share/virtualenvs/backend-0eAQt0K2/lib/python3.7/site-packages/flake8/checker.py", line 612, in run_checks
    self.run_ast_checks()
  File "/home/developer2/.local/share/virtualenvs/backend-0eAQt0K2/lib/python3.7/site-packages/flake8/checker.py", line 520, in run_ast_checks
    for (line_number, offset, text, check) in runner:
  File "/home/developer2/.local/share/virtualenvs/backend-0eAQt0K2/lib/python3.7/site-packages/wemake_python_styleguide/checker.py", line 178, in run
    yield from self._run_checks(self.visitors)
  File "/home/developer2/.local/share/virtualenvs/backend-0eAQt0K2/lib/python3.7/site-packages/wemake_python_styleguide/checker.py", line 166, in _run_checks
    visitor.run()
  File "/home/developer2/.local/share/virtualenvs/backend-0eAQt0K2/lib/python3.7/site-packages/wemake_python_styleguide/visitors/base.py", line 140, in run
    self.visit(self.tree)
  File "/usr/lib/python3.7/ast.py", line 262, in visit
    return visitor(node)
  File "/usr/lib/python3.7/ast.py", line 270, in generic_visit
    self.visit(item)
  File "/usr/lib/python3.7/ast.py", line 262, in visit
    return visitor(node)
  File "/home/developer2/.local/share/virtualenvs/backend-0eAQt0K2/lib/python3.7/site-packages/wemake_python_styleguide/visitors/ast/statements.py", line 237, in visit_ClassDef
    self.generic_visit(node)
  File "/usr/lib/python3.7/ast.py", line 270, in generic_visit
    self.visit(item)
  File "/usr/lib/python3.7/ast.py", line 262, in visit
    return visitor(node)
  File "/home/developer2/.local/share/virtualenvs/backend-0eAQt0K2/lib/python3.7/site-packages/wemake_python_styleguide/visitors/ast/statements.py", line 231, in visit_any_function
    self.generic_visit(node)
  File "/usr/lib/python3.7/ast.py", line 270, in generic_visit
    self.visit(item)
  File "/usr/lib/python3.7/ast.py", line 262, in visit
    return visitor(node)
  File "/usr/lib/python3.7/ast.py", line 272, in generic_visit
    self.visit(value)
  File "/usr/lib/python3.7/ast.py", line 262, in visit
    return visitor(node)
  File "/home/developer2/.local/share/virtualenvs/backend-0eAQt0K2/lib/python3.7/site-packages/wemake_python_styleguide/visitors/ast/statements.py", line 219, in visit_collection
    self._check_indentation(node, elements, extra_lines=1)
  File "/home/developer2/.local/share/virtualenvs/backend-0eAQt0K2/lib/python3.7/site-packages/wemake_python_styleguide/visitors/ast/statements.py", line 206, in _check_indentation
    extra_lines,
  File "/home/developer2/.local/share/virtualenvs/backend-0eAQt0K2/lib/python3.7/site-packages/wemake_python_styleguide/visitors/ast/statements.py", line 171, in _check_first_element
    if statement.lineno == node.lineno and not extra_lines:
AttributeError: 'NoneType' object has no attribute 'lineno'
"""

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/developer2/.local/share/virtualenvs/backend-0eAQt0K2/bin/flake8", line 11, in <module>
    sys.exit(main())
  File "/home/developer2/.local/share/virtualenvs/backend-0eAQt0K2/lib/python3.7/site-packages/flake8/main/cli.py", line 16, in main
    app.run(argv)
  File "/home/developer2/.local/share/virtualenvs/backend-0eAQt0K2/lib/python3.7/site-packages/flake8/main/application.py", line 412, in run
    self._run(argv)
  File "/home/developer2/.local/share/virtualenvs/backend-0eAQt0K2/lib/python3.7/site-packages/flake8/main/application.py", line 400, in _run
    self.run_checks()
  File "/home/developer2/.local/share/virtualenvs/backend-0eAQt0K2/lib/python3.7/site-packages/flake8/main/application.py", line 318, in run_checks
    self.file_checker_manager.run()
  File "/home/developer2/.local/share/virtualenvs/backend-0eAQt0K2/lib/python3.7/site-packages/flake8_per_file_ignores.py", line 33, in run
    orig_run(self)
  File "/home/developer2/.local/share/virtualenvs/backend-0eAQt0K2/lib/python3.7/site-packages/flake8/checker.py", line 338, in run
    self.run_parallel()
  File "/home/developer2/.local/share/virtualenvs/backend-0eAQt0K2/lib/python3.7/site-packages/flake8/checker.py", line 302, in run_parallel
    for ret in pool_map:
  File "/usr/lib/python3.7/multiprocessing/pool.py", line 774, in next
    raise value
AttributeError: 'NoneType' object has no attribute 'lineno'

Code sample that causes this issue

class Mapper:
    @property
    def section(self):
        return {
            **self.phone,
            **self.workdays
        }

System information

flake8 information

{
  "dependencies": [
    {
      "dependency": "setuptools",
      "version": "40.6.2"
    }
  ],
  "platform": {
    "python_implementation": "CPython",
    "python_version": "3.7.1",
    "system": "Linux"
  },
  "plugins": [
    {
      "is_local": false,
      "plugin": "flake8-bandit",
      "version": "v1.0.2"
    },
    {
      "is_local": false,
      "plugin": "flake8-broken-line",
      "version": "0.1.0"
    },
    {
      "is_local": false,
      "plugin": "flake8-bugbear",
      "version": "18.8.0"
    },
    {
      "is_local": false,
      "plugin": "flake8-comprehensions",
      "version": "1.4.1"
    },
    {
      "is_local": false,
      "plugin": "flake8-debugger",
      "version": "3.1.0"
    },
    {
      "is_local": false,
      "plugin": "flake8-docstrings",
      "version": "1.3.0, pydocstyle: 3.0.0"
    },
    {
      "is_local": false,
      "plugin": "flake8-eradicate",
      "version": "0.1.1"
    },
    {
      "is_local": false,
      "plugin": "flake8-print",
      "version": "3.1.0"
    },
    {
      "is_local": false,
      "plugin": "flake8-string-format",
      "version": "0.2.3"
    },
    {
      "is_local": false,
      "plugin": "flake8-type-annotations",
      "version": "0.1.0"
    },
    {
      "is_local": false,
      "plugin": "flake8_builtins",
      "version": "1.4.1"
    },
    {
      "is_local": false,
      "plugin": "flake8_coding",
      "version": "1.3.1"
    },
    {
      "is_local": false,
      "plugin": "flake8_commas",
      "version": "2.0.0"
    },
    {
      "is_local": false,
      "plugin": "flake8_isort",
      "version": "2.3"
    },
    {
      "is_local": false,
      "plugin": "flake8_pep3101",
      "version": "1.2.1"
    },
    {
      "is_local": false,
      "plugin": "flake8_quotes",
      "version": "1.0.0"
    },
    {
      "is_local": false,
      "plugin": "logging-format",
      "version": "0.5.0"
    },
    {
      "is_local": false,
      "plugin": "mccabe",
      "version": "0.6.1"
    },
    {
      "is_local": false,
      "plugin": "naming",
      "version": "0.7.0"
    },
    {
      "is_local": false,
      "plugin": "per-file-ignores",
      "version": "0.6"
    },
    {
      "is_local": false,
      "plugin": "pycodestyle",
      "version": "2.4.0"
    },
    {
      "is_local": false,
      "plugin": "pyflakes",
      "version": "2.0.0"
    },
    {
      "is_local": false,
      "plugin": "wemake-python-styleguide",
      "version": "0.6.2"
    }
  ],
  "version": "3.6.0"
}
@sobolevn sobolevn self-assigned this Jan 18, 2019
@sobolevn sobolevn added the bug Something isn't working label Jan 18, 2019
@sobolevn
Copy link
Member

@mirrorrim thanks for your report. New version with the fix will be released soon.

sobolevn added a commit that referenced this issue Jan 18, 2019
@sobolevn sobolevn mentioned this issue Jan 18, 2019
@helpr helpr bot added the pr-available label Jan 18, 2019
sobolevn added a commit that referenced this issue Jan 18, 2019
* Version 0.6.2

* Version 0.6.3, closes #450
@helpr helpr bot added pr-merged and removed pr-available labels Jan 18, 2019
@sobolevn
Copy link
Member

@mirrorrim please, test how 0.6.3 works for you. Any bugs are welcome! 👍

@mirrorrim
Copy link
Author

It works now, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working pr-merged
Projects
None yet
Development

No branches or pull requests

3 participants
@sobolevn @mirrorrim and others