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

Crash with new min/max refactoring checker #4379

Closed
cdce8p opened this issue Apr 19, 2021 · 0 comments · Fixed by #4380
Closed

Crash with new min/max refactoring checker #4379

cdce8p opened this issue Apr 19, 2021 · 0 comments · Fixed by #4380
Assignees
Labels
Blocker 🙅 Blocks the next release Crash 💥 A bug that makes pylint crash
Milestone

Comments

@cdce8p
Copy link
Member

cdce8p commented Apr 19, 2021

Steps to reproduce

Given a file a.py:

var = 1
if var == -1:
    var = None

Current behavior

Result of pylint a.py:

Traceback (most recent call last):
  File "/../pylint/venv-39_link/bin/pylint", line 33, in <module>
    sys.exit(load_entry_point('pylint', 'console_scripts', 'pylint')())
  File "/../pylint/pylint/__init__.py", line 24, in run_pylint
    PylintRun(sys.argv[1:])
  File "/../pylint/pylint/lint/run.py", line 358, in __init__
    linter.check(args)
  File "/../pylint/pylint/lint/pylinter.py", line 873, in check
    self._check_files(
  File "/../pylint/pylint/lint/pylinter.py", line 907, in _check_files
    self._check_file(get_ast, check_astroid_module, name, filepath, modname)
  File "/../pylint/pylint/lint/pylinter.py", line 933, in _check_file
    check_astroid_module(ast_node)
  File "/../pylint/pylint/lint/pylinter.py", line 1067, in check_astroid_module
    retval = self._check_astroid_module(
  File "/../pylint/pylint/lint/pylinter.py", line 1112, in _check_astroid_module
    walker.walk(ast_node)
  File "/../pylint/pylint/utils/ast_walker.py", line 77, in walk
    self.walk(child)
  File "/../pylint/pylint/utils/ast_walker.py", line 74, in walk
    callback(astroid)
  File "/../pylint/pylint/checkers/refactoring/refactoring_checker.py", line 622, in visit_if
    self._check_consider_using_min_max_builtin(node)
  File "/../pylint/pylint/checkers/refactoring/refactoring_checker.py", line 680, in _check_consider_using_min_max_builtin
    right_statement_value = right_statement.value
AttributeError: 'UnaryOp' object has no attribute 'value'

Expected behavior

No crash.

pylint --version output

pylint 2.8.0.dev1
astroid 2.5.3
Python 3.9.4 (v3.9.4:1f2e3088f3, Apr  4 2021, 12:32:44) 
[Clang 6.0 (clang-600.0.57)]

--
Related to #4359
/CC: @Pierre-Sassoulas, @Qwiddle13, @manderj

I'll open a MR for it shortly.

@cdce8p cdce8p added Blocker 🙅 Blocks the next release Crash 💥 A bug that makes pylint crash labels Apr 19, 2021
@cdce8p cdce8p self-assigned this Apr 19, 2021
@Pierre-Sassoulas Pierre-Sassoulas added this to the 2.8.0 milestone Apr 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Blocker 🙅 Blocks the next release Crash 💥 A bug that makes pylint crash
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants