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

AttributeError in parsing Python 3.10 parsing pattern matching with keyword arguments #634

Closed
tirkarthi opened this issue May 17, 2021 · 3 comments

Comments

@tirkarthi
Copy link

This doesn't happen with positional only argument matches but keyword argument pattern matching as below throws error.

import dataclasses


@dataclasses.dataclass()
class C(object):
    a: int
    b: int


c = C(1, 2)
match c:
    case C(a=a, b=b):
        found = True

Traceback

pyflakes /tmp/test_pattern_matching.py
Traceback (most recent call last):
  File "/root/checked_repos/attrs/.env/bin/pyflakes", line 8, in <module>
    sys.exit(main())
  File "/root/checked_repos/attrs/.env/lib/python3.10/site-packages/pyflakes/api.py", line 210, in main
    warnings = checkRecursive(args, reporter)
  File "/root/checked_repos/attrs/.env/lib/python3.10/site-packages/pyflakes/api.py", line 155, in checkRecursive
    warnings += checkPath(sourcePath, reporter)
  File "/root/checked_repos/attrs/.env/lib/python3.10/site-packages/pyflakes/api.py", line 99, in checkPath
    return check(codestr, filename, reporter)
  File "/root/checked_repos/attrs/.env/lib/python3.10/site-packages/pyflakes/api.py", line 74, in check
    w = checker.Checker(tree, file_tokens=file_tokens, filename=filename)
  File "/root/checked_repos/attrs/.env/lib/python3.10/site-packages/pyflakes/checker.py", line 904, in __init__
    self.handleChildren(tree)
  File "/root/checked_repos/attrs/.env/lib/python3.10/site-packages/pyflakes/checker.py", line 1359, in handleChildren
    self.handleNode(node, tree)
  File "/root/checked_repos/attrs/.env/lib/python3.10/site-packages/pyflakes/checker.py", line 1406, in handleNode
    handler(node)
  File "/root/checked_repos/attrs/.env/lib/python3.10/site-packages/pyflakes/checker.py", line 1166, in _unknown_handler
    self.handleChildren(node)
  File "/root/checked_repos/attrs/.env/lib/python3.10/site-packages/pyflakes/checker.py", line 1359, in handleChildren
    self.handleNode(node, tree)
  File "/root/checked_repos/attrs/.env/lib/python3.10/site-packages/pyflakes/checker.py", line 1406, in handleNode
    handler(node)
  File "/root/checked_repos/attrs/.env/lib/python3.10/site-packages/pyflakes/checker.py", line 1166, in _unknown_handler
    self.handleChildren(node)
  File "/root/checked_repos/attrs/.env/lib/python3.10/site-packages/pyflakes/checker.py", line 1359, in handleChildren
    self.handleNode(node, tree)
  File "/root/checked_repos/attrs/.env/lib/python3.10/site-packages/pyflakes/checker.py", line 1406, in handleNode
    handler(node)
  File "/root/checked_repos/attrs/.env/lib/python3.10/site-packages/pyflakes/checker.py", line 1166, in _unknown_handler
    self.handleChildren(node)
  File "/root/checked_repos/attrs/.env/lib/python3.10/site-packages/pyflakes/checker.py", line 1359, in handleChildren
    self.handleNode(node, tree)
  File "/root/checked_repos/attrs/.env/lib/python3.10/site-packages/pyflakes/checker.py", line 1402, in handleNode
    node._pyflakes_depth = self.nodeDepth
AttributeError: 'str' object has no attribute '_pyflakes_depth'
@asottile
Copy link
Member

match support is not at all implemented yet -- if you want to move that along please review #630

@tirkarthi
Copy link
Author

Sorry, search failed me. Please feel free to close it or as #630 is implemented. Thanks.

@asottile
Copy link
Member

asottile commented Oct 5, 2021

via #630

@asottile asottile closed this as completed Oct 5, 2021
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