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

MatchAs object has no attribute assigned_stmts #4685

Closed
cheesycod opened this issue Jul 7, 2021 · 2 comments · Fixed by #4686
Closed

MatchAs object has no attribute assigned_stmts #4685

cheesycod opened this issue Jul 7, 2021 · 2 comments · Fixed by #4686
Assignees
Labels
Crash 💥 A bug that makes pylint crash Needs astroid update Needs an astroid update (probably a release too) before being mergable python 3.10

Comments

@cheesycod
Copy link

cheesycod commented Jul 7, 2021

No

Steps to reproduce

Try doing pylint on this (no idea what lines are causing it tho: https://github.com/Fates-List/FatesList/blob/main/modules/core/system.py)

Current behavior

pylint crashes with MatchAs object has no attribute assigned_stmts

Result of pylint a.py:

************* Module modules.core.system
Exception on node <Compare l.318 at 0x7f4e15e8e380> in file '/home/meow/FatesList/modules/core/system.py'
Traceback (most recent call last):
  File "/home/meow/flvenv/bin/pylint", line 8, in <module>
    sys.exit(run_pylint())
  File "/home/meow/flvenv/lib64/python3.10/site-packages/pylint/__init__.py", line 24, in run_pylint
    PylintRun(sys.argv[1:])
  File "/home/meow/flvenv/lib64/python3.10/site-packages/pylint/lint/run.py", line 384, in __init__
    linter.check(args)
  File "/home/meow/flvenv/lib64/python3.10/site-packages/pylint/lint/pylinter.py", line 973, in check
    self._check_files(
  File "/home/meow/flvenv/lib64/python3.10/site-packages/pylint/lint/pylinter.py", line 1007, in _check_files
    self._check_file(get_ast, check_astroid_module, name, filepath, modname)
  File "/home/meow/flvenv/lib64/python3.10/site-packages/pylint/lint/pylinter.py", line 1033, in _check_file
    check_astroid_module(ast_node)
  File "/home/meow/flvenv/lib64/python3.10/site-packages/pylint/lint/pylinter.py", line 1170, in check_astroid_module
    retval = self._check_astroid_module(
  File "/home/meow/flvenv/lib64/python3.10/site-packages/pylint/lint/pylinter.py", line 1215, in _check_astroid_module
    walker.walk(ast_node)
  File "/home/meow/flvenv/lib64/python3.10/site-packages/pylint/utils/ast_walker.py", line 77, in walk
    self.walk(child)
  File "/home/meow/flvenv/lib64/python3.10/site-packages/pylint/utils/ast_walker.py", line 77, in walk
    self.walk(child)
  File "/home/meow/flvenv/lib64/python3.10/site-packages/pylint/utils/ast_walker.py", line 77, in walk
    self.walk(child)
  [Previous line repeated 3 more times]
  File "/home/meow/flvenv/lib64/python3.10/site-packages/pylint/utils/ast_walker.py", line 74, in walk
    callback(astroid)
  File "/home/meow/flvenv/lib64/python3.10/site-packages/pylint/checkers/base.py", line 2536, in visit_compare
    self._check_callable_comparison(node)
  File "/home/meow/flvenv/lib64/python3.10/site-packages/pylint/checkers/base.py", line 2518, in _check_callable_comparison
    sum(
  File "/home/meow/flvenv/lib64/python3.10/site-packages/pylint/checkers/base.py", line 2521, in <genexpr>
    if isinstance(utils.safe_infer(operand), bare_callables)
  File "/home/meow/flvenv/lib64/python3.10/site-packages/pylint/checkers/utils.py", line 1175, in safe_infer
    value = next(infer_gen)
  File "/home/meow/flvenv/lib64/python3.10/site-packages/astroid/node_classes.py", line 353, in infer
    yield from self._infer(context, **kwargs)
  File "/home/meow/flvenv/lib64/python3.10/site-packages/astroid/decorators.py", line 136, in raise_if_nothing_inferred
    yield next(generator)
  File "/home/meow/flvenv/lib64/python3.10/site-packages/astroid/decorators.py", line 100, in wrapped
    res = next(generator)
  File "/home/meow/flvenv/lib64/python3.10/site-packages/astroid/bases.py", line 144, in _infer_stmts
    for inferred in stmt.infer(context=context):
  File "/home/meow/flvenv/lib64/python3.10/site-packages/astroid/node_classes.py", line 367, in infer
    for i, result in enumerate(generator):
  File "/home/meow/flvenv/lib64/python3.10/site-packages/astroid/decorators.py", line 136, in raise_if_nothing_inferred
    yield next(generator)
  File "/home/meow/flvenv/lib64/python3.10/site-packages/astroid/decorators.py", line 97, in wrapped
    generator = _func(node, context, **kwargs)
  File "/home/meow/flvenv/lib64/python3.10/site-packages/astroid/inference.py", line 860, in infer_assign
    stmts = list(self.assigned_stmts(context=context))
  File "/home/meow/flvenv/lib64/python3.10/site-packages/astroid/protocols.py", line 308, in assend_assigned_stmts
    return self.parent.assigned_stmts(node=self, context=context)
AttributeError: 'MatchAs' object has no attribute 'assigned_stmts'

Expected behavior

pylint --version output

Result of pylint --version output:

pylint 2.9.4-dev0
astroid 2.6.3-dev0
Python 3.10.0b3 (default, Jun 17 2021, 00:00:00) [GCC 11.1.1 20210531 (Red Hat 11.1.1-3)]
@Pierre-Sassoulas
Copy link
Member

Thank you for opening the issue, I can reproduce the crash.

@cdce8p cdce8p self-assigned this Jul 7, 2021
@cdce8p
Copy link
Member

cdce8p commented Jul 7, 2021

I can reproduce it as well. This seems to be enough:

msg = 42

match msg:
    case _ as var:
        if var != 2:
            pass

@Pierre-Sassoulas Pierre-Sassoulas added the Needs astroid update Needs an astroid update (probably a release too) before being mergable label Jul 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Crash 💥 A bug that makes pylint crash Needs astroid update Needs an astroid update (probably a release too) before being mergable python 3.10
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants