Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Crash when annotating a method with **kwargs #96

Open
ilevkivskyi opened this issue Nov 28, 2019 · 0 comments
Open

Crash when annotating a method with **kwargs #96

ilevkivskyi opened this issue Nov 28, 2019 · 0 comments
Labels

Comments

@ilevkivskyi
Copy link
Contributor

Trying to annotate this code:

class C:
    def test_xx(self,
                a=1,
                b=1,
                c=1,
                d=1,
                **kwargs):
        pass

triggers a crash with following traceback:

Traceback (most recent call last):
  [...snip...]
  File "/lib/python3.7/lib2to3/refactor.py", line 282, in refactor
    self.refactor_file(dir_or_file, write, doctests_only)
  File "/lib/python3.7/site-packages/pyannotate_tools/annotations/__main__.py", line 57, in refactor_file
    filename, write=write, doctests_only=doctests_only)
  File "/lib/python3.7/lib2to3/refactor.py", line 728, in refactor_file
    *args, **kwargs)
  File "/lib/python3.7/lib2to3/refactor.py", line 335, in refactor_file
    tree = self.refactor_string(input, filename)
  File "/lib/python3.7/lib2to3/refactor.py", line 367, in refactor_string
    self.refactor_tree(tree, name)
  File "/lib/python3.7/lib2to3/refactor.py", line 441, in refactor_tree
    new = fixer.transform(node, results)
  File "/lib/python3.7/site-packages/pyannotate_tools/fixes/fix_annotate.py", line 181, in transform
    self.add_py2_annot(argtypes, restype, node, results)
  File "/lib/python3.7/site-packages/pyannotate_tools/fixes/fix_annotate.py", line 276, in add_py2_annot
    self.insert_long_form(node, results, argtypes)
  File "/lib/python3.7/site-packages/pyannotate_tools/fixes/fix_annotate.py", line 342, in insert_long_form
    assert not argtypes, argtypes
AssertionError: ['**Any']

Couple notes on triggering the crash:

  • It must be a method, not function
  • The signature must be long
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant