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

Exception with Literal[""] #10

Closed
Dreamsorcerer opened this issue Jun 28, 2020 · 1 comment
Closed

Exception with Literal[""] #10

Dreamsorcerer opened this issue Jun 28, 2020 · 1 comment
Labels
bug Something isn't working

Comments

@Dreamsorcerer
Copy link

Dreamsorcerer commented Jun 28, 2020

An exception is thrown if running flake8 and it finds an empty string in a Literal definition.

To Reproduce
I wrote the test for it, so see that:
#11

Output:

Traceback (most recent call last):
  File "/home/ubuntu/.local/bin/flake8", line 8, in <module>
    sys.exit(main())
  File "/home/ubuntu/.local/lib/python3.8/site-packages/flake8/main/cli.py", line 22, in main
    app.run(argv)
  File "/home/ubuntu/.local/lib/python3.8/site-packages/flake8/main/application.py", line 360, in run
    self._run(argv)
  File "/home/ubuntu/.local/lib/python3.8/site-packages/flake8/main/application.py", line 348, in _run
    self.run_checks()
  File "/home/ubuntu/.local/lib/python3.8/site-packages/flake8/main/application.py", line 262, in run_checks
    self.file_checker_manager.run()
  File "/home/ubuntu/.local/lib/python3.8/site-packages/flake8/checker.py", line 334, in run
    self.run_serial()
  File "/home/ubuntu/.local/lib/python3.8/site-packages/flake8/checker.py", line 318, in run_serial
    checker.run_checks()
  File "/home/ubuntu/.local/lib/python3.8/site-packages/flake8/checker.py", line 598, in run_checks
    self.run_ast_checks()
  File "/home/ubuntu/.local/lib/python3.8/site-packages/flake8/checker.py", line 505, in run_ast_checks
    for (line_number, offset, text, _) in runner:
  File "/home/ubuntu/.local/lib/python3.8/site-packages/flake8_annotations_complexity/checker.py", line 23, in run
    too_difficult_annotations = validate_annotations_in_ast_node(
  File "/home/ubuntu/.local/lib/python3.8/site-packages/flake8_annotations_complexity/ast_helpres.py", line 31, in validate_annotations_in_ast_node
    complexity = get_annotation_complexity(annotation)
  File "/home/ubuntu/.local/lib/python3.8/site-packages/flake8_annotations_complexity/ast_helpres.py", line 12, in get_annotation_complexity
    return 1 + get_annotation_complexity(annotation_node.slice.value)  # type: ignore
  File "/home/ubuntu/.local/lib/python3.8/site-packages/flake8_annotations_complexity/ast_helpres.py", line 8, in get_annotation_complexity
    annotation_node = ast.parse(annotation_node.s).body[0].value  # type: ignore
IndexError: list index out of range
@Dreamsorcerer Dreamsorcerer added the bug Something isn't working label Jun 28, 2020
@Melevir
Copy link
Contributor

Melevir commented Jun 28, 2020

Thanks for the report and for pr with test, it made my work much easier.

Fixed in version 0.0.5 of the plugin.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants