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

TypeError: '<' not supported between instances of 'int' and 'NoneType' #5982

Closed
roman-verchikov opened this issue Mar 25, 2022 · 1 comment · Fixed by #5988
Closed

TypeError: '<' not supported between instances of 'int' and 'NoneType' #5982

roman-verchikov opened this issue Mar 25, 2022 · 1 comment · Fixed by #5988
Assignees
Labels
Astroid Related to astroid Crash 💥 A bug that makes pylint crash Regression
Milestone

Comments

@roman-verchikov
Copy link

roman-verchikov commented Mar 25, 2022

Bug description

Steps to reproduce

  1. Create python file test.py with contents:
from __future__ import annotations

from collections import namedtuple


class SomeClass(namedtuple("SomeClass", [])):
    def method(self) -> SomeClass:
        pass
  1. Run pylint against it:
$ pylint -d C0114,C0115,C0116 test.py

Expected

  • pylint succeeds
  • worked as expected with pylint==2.12.2 and earlier versions of pylint

Actual

Exception on node <Name.SomeClass l.7 at 0x112389a10> in file '/private/tmp/pylintfail/crash_pylint.py'
Traceback (most recent call last):
  File "/private/tmp/pylintfail/.venv/lib/python3.7/site-packages/pylint/utils/ast_walker.py", line 73, in walk
    callback(astroid)
  File "/private/tmp/pylintfail/.venv/lib/python3.7/site-packages/pylint/checkers/variables.py", line 1362, in visit_name
    self._undefined_and_used_before_checker(node, stmt)
  File "/private/tmp/pylintfail/.venv/lib/python3.7/site-packages/pylint/checkers/variables.py", line 1405, in _undefined_and_used_before_checker
    node, stmt, frame, current_consumer, i, base_scope_type
  File "/private/tmp/pylintfail/.venv/lib/python3.7/site-packages/pylint/checkers/variables.py", line 1595, in _check_consumer
    is_recursive_klass,
  File "/private/tmp/pylintfail/.venv/lib/python3.7/site-packages/pylint/checkers/variables.py", line 1866, in _is_variable_violation
    maybe_before_assign = _detect_global_scope(node, frame, defframe)
  File "/private/tmp/pylintfail/.venv/lib/python3.7/site-packages/pylint/checkers/variables.py", line 262, in _detect_global_scope
    return frame.lineno < defframe.lineno
TypeError: '<' not supported between instances of 'int' and 'NoneType'
************* Module crash_pylint
crash_pylint.py:1:0: F0001: Fatal error while checking 'crash_pylint.py'. Please open an issue in our bug tracker so we address this. There is a pre-filled template that you can use in '/Users/name/Library/Caches/pylint/pylint-crash-2022-03-25-14.txt'. (fatal)

------------------------------------------------------------------
Your code has been rated at 0.00/10 (previous run: 0.00/10, +0.00)

Configuration

No response

Command used

pylint -d C0114,C0115,C0116 test.py

Pylint output

Exception on node <Name.SomeClass l.7 at 0x112389a10> in file '/private/tmp/pylintfail/crash_pylint.py'
Traceback (most recent call last):
  File "/private/tmp/pylintfail/.venv/lib/python3.7/site-packages/pylint/utils/ast_walker.py", line 73, in walk
    callback(astroid)
  File "/private/tmp/pylintfail/.venv/lib/python3.7/site-packages/pylint/checkers/variables.py", line 1362, in visit_name
    self._undefined_and_used_before_checker(node, stmt)
  File "/private/tmp/pylintfail/.venv/lib/python3.7/site-packages/pylint/checkers/variables.py", line 1405, in _undefined_and_used_before_checker
    node, stmt, frame, current_consumer, i, base_scope_type
  File "/private/tmp/pylintfail/.venv/lib/python3.7/site-packages/pylint/checkers/variables.py", line 1595, in _check_consumer
    is_recursive_klass,
  File "/private/tmp/pylintfail/.venv/lib/python3.7/site-packages/pylint/checkers/variables.py", line 1866, in _is_variable_violation
    maybe_before_assign = _detect_global_scope(node, frame, defframe)
  File "/private/tmp/pylintfail/.venv/lib/python3.7/site-packages/pylint/checkers/variables.py", line 262, in _detect_global_scope
    return frame.lineno < defframe.lineno
TypeError: '<' not supported between instances of 'int' and 'NoneType'
************* Module crash_pylint
crash_pylint.py:1:0: F0001: Fatal error while checking 'crash_pylint.py'. Please open an issue in our bug tracker so we address this. There is a pre-filled template that you can use in '/Users/name/Library/Caches/pylint/pylint-crash-2022-03-25-14.txt'. (fatal)

------------------------------------------------------------------
Your code has been rated at 0.00/10 (previous run: 0.00/10, +0.00)

Expected behavior

pylint succeeds

Pylint version

pylint 2.13.0
astroid 2.11.1
Python 3.7.10 (default, Apr  2 2021, 10:55:19) 
[Clang 12.0.0 (clang-1200.0.32.29)]

OS / Environment

No response

Additional dependencies

No response

@roman-verchikov roman-verchikov added the Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling label Mar 25, 2022
@Pierre-Sassoulas Pierre-Sassoulas added Regression Crash 💥 A bug that makes pylint crash and removed Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling labels Mar 25, 2022
@Pierre-Sassoulas Pierre-Sassoulas added this to the 2.13.1 milestone Mar 25, 2022
@jacobtylerwalls
Copy link
Member

jacobtylerwalls commented Mar 26, 2022

Thanks for the report, I bisected it to d30592a5d27ca801aae36248ed169ae3dee5f4c9 in astroid

@DanielNoord would you be interested to take a look?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Astroid Related to astroid Crash 💥 A bug that makes pylint crash Regression
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants