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

NameInferenceError #4215

Closed
owillebo opened this issue Mar 8, 2021 · 2 comments · Fixed by #4216
Closed

NameInferenceError #4215

owillebo opened this issue Mar 8, 2021 · 2 comments · Fixed by #4216

Comments

@owillebo
Copy link

owillebo commented Mar 8, 2021

Steps to reproduce

lint following code;

if len(dont_care[0]):
    pass

Current behavior

pylint crashes;

************* Module bug

bug.py:1:0: [C0114] Missing module docstring (missing-module-docstring)
Traceback (most recent call last):
  File "c:\program files\python39\lib\runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "c:\program files\python39\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Program Files\Python39\Scripts\pylint.exe\__main__.py", line 7, in <module>
  File "c:\program files\python39\lib\site-packages\pylint\__init__.py", line 22, in run_pylint
    PylintRun(sys.argv[1:])
  File "c:\program files\python39\lib\site-packages\pylint\lint\run.py", line 358, in __init__
    linter.check(args)
  File "c:\program files\python39\lib\site-packages\pylint\lint\pylinter.py", line 862, in check
    self._check_files(
  File "c:\program files\python39\lib\site-packages\pylint\lint\pylinter.py", line 896, in _check_files
    self._check_file(get_ast, check_astroid_module, name, filepath, modname)
  File "c:\program files\python39\lib\site-packages\pylint\lint\pylinter.py", line 922, in _check_file
    check_astroid_module(ast_node)
  File "c:\program files\python39\lib\site-packages\pylint\lint\pylinter.py", line 1054, in check_astroid_module
    retval = self._check_astroid_module(
  File "c:\program files\python39\lib\site-packages\pylint\lint\pylinter.py", line 1099, in _check_astroid_module
    walker.walk(ast_node)
  File "c:\program files\python39\lib\site-packages\pylint\utils\ast_walker.py", line 75, in walk
    self.walk(child)
  File "c:\program files\python39\lib\site-packages\pylint\utils\ast_walker.py", line 75, in walk
    self.walk(child)
  File "c:\program files\python39\lib\site-packages\pylint\utils\ast_walker.py", line 72, in walk
    callback(astroid)
  File "c:\program files\python39\lib\site-packages\pylint\checkers\refactoring\len_checker.py", line 76, in visit_call
    instance = next(len_arg.infer())
  File "c:\program files\python39\lib\site-packages\astroid\node_classes.py", line 366, in infer
    yield from self._infer(context, **kwargs)
  File "c:\program files\python39\lib\site-packages\astroid\decorators.py", line 135, in raise_if_nothing_inferred
    yield next(generator)
  File "c:\program files\python39\lib\site-packages\astroid\decorators.py", line 99, in wrapped
    res = next(generator)
  File "c:\program files\python39\lib\site-packages\astroid\inference.py", line 368, in infer_subscript
    for value in self.value.infer(context):
  File "c:\program files\python39\lib\site-packages\astroid\node_classes.py", line 380, in infer
    for i, result in enumerate(generator):
  File "c:\program files\python39\lib\site-packages\astroid\decorators.py", line 135, in raise_if_nothing_inferred
    yield next(generator)
  File "c:\program files\python39\lib\site-packages\astroid\decorators.py", line 96, in wrapped
    generator = _func(node, context, **kwargs)
  File "c:\program files\python39\lib\site-packages\astroid\inference.py", line 201, in infer_name
    raise exceptions.NameInferenceError(
astroid.exceptions.NameInferenceError: 'dont_care' not found in <Module.bug l.0 at 0x1a3f69f5310>.

Expected behavior

Just print some warnings.

pylint --version output

pylint 2.7.2
astroid 2.5.1
Python 3.9.2 (tags/v3.9.2:1a79785, Feb 19 2021, 13:44:55) [MSC v.1928 64 bit (AMD64)]

@cdce8p
Copy link
Member

cdce8p commented Mar 8, 2021

I've opened #4216 to fix it

@owillebo
Copy link
Author

owillebo commented Mar 8, 2021

See for consequential damage of this issue #4165.

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

Successfully merging a pull request may close this issue.

2 participants