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

Pylint crashes on disable=invalid-name on NewTypes #1389

Closed
quodlibetor opened this issue Mar 21, 2017 · 0 comments
Closed

Pylint crashes on disable=invalid-name on NewTypes #1389

quodlibetor opened this issue Mar 21, 2017 · 0 comments
Assignees
Milestone

Comments

@quodlibetor
Copy link
Contributor

, ### Steps to reproduce
I can't actually reproduce this without my exact code, but the structure looks like:

from typing import Dict, NamedTuple, NewType, Set

UserId = NewType('UserId', str)  # pylint: disable=invalid-name
PlaceId = NewType('PlaceId', str)  # pylint: disable=invalid-name


class Bar(NamedTuple):
    place: PlaceId
    name: str


class Foo(NamedTuple):
    user: Dict[UserId, Set[Bar]]

without the disable=invalid-name this succeeds fine, but with it I get:

Traceback (most recent call last):
  File "$project"/bin/pylint", line 11, in <module>
    sys.exit(run_pylint())
  File "$project"/lib/python3.6/site-packages/pylint/__init__.py", line 13, in run_pylint
    Run(sys.argv[1:])
  File "$project"/lib/python3.6/site-packages/pylint/lint.py", line 1300, in __init__
    linter.check(args)
  File "$project"/lib/python3.6/site-packages/pylint/lint.py", line 726, in check
    self._do_check(files_or_modules)
  File "$project"/lib/python3.6/site-packages/pylint/lint.py", line 855, in _do_check
    self.check_astroid_module(ast_node, walker, rawcheckers, tokencheckers)
  File "$project"/lib/python3.6/site-packages/pylint/lint.py", line 934, in check_astroid_module
    walker.walk(ast_node)
  File "$project"/lib/python3.6/site-packages/pylint/utils.py", line 973, in walk
    self.walk(child)
  File "$project"/lib/python3.6/site-packages/pylint/utils.py", line 970, in walk
    cb(astroid)
  File "$project"/lib/python3.6/site-packages/pylint/checkers/classes.py", line 536, in visit_classdef
    self._check_bases_classes(node)
  File "$project"/lib/python3.6/site-packages/pylint/checkers/classes.py", line 1125, in _check_bases_classes
    unimplemented_abstract_methods(node, is_abstract).items(),
  File "$project"/lib/python3.6/site-packages/pylint/checkers/utils.py", line 552, in unimplemented_abstract_methods
    infered = safe_infer(obj)
  File "$project"/lib/python3.6/site-packages/pylint/checkers/utils.py", line 773, in safe_infer
    value = next(inferit)
  File "$project"/lib/python3.6/site-packages/astroid/decorators.py", line 85, in wrapped
    res = next(generator)
  File "$project"/lib/python3.6/site-packages/astroid/bases.py", line 93, in _infer_stmts
    context.lookupname = stmt._infer_name(frame, name)
AttributeError: 'NoneType' object has no attribute '_infer_name'

Current behavior

Expected behavior

pylint --version output

pylint is an unmodified version of d78e013 , astroid is 313c0c3 , python is:
Python 3.6.0 (default, Mar 1 2017, 17:08:51)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants