pydantic / bump-pydantic

Convert Pydantic from V1 to V2 ♻
MIT License
323 stars 25 forks source link

Literal values "and" and "or" cause ParserSyntaxError #124

Closed gorilla-seb closed 1 year ago

gorilla-seb commented 1 year ago

Using the string value "and" or "or" for Literal causes a ParserSyntaxError

from typing import Literal
from pydantic import BaseModel

class Foo(BaseModel):
    bar: Literal["and"]
An error happened on test.py.
Traceback (most recent call last):
  File "/Users/sebastian/.local/pipx/venvs/bump-pydantic/lib/python3.10/site-packages/bump_pydantic/main.py", line 185, in run_codemods
    output_tree = transformer.transform_module(input_tree)
  File "/Users/sebastian/.local/pipx/venvs/bump-pydantic/lib/python3.10/site-packages/libcst/codemod/_codemod.py", line 108, in transform_module
    return self.transform_module_impl(tree_with_metadata)
  File "/Users/sebastian/.local/pipx/venvs/bump-pydantic/lib/python3.10/site-packages/libcst/codemod/_visitor.py", line 32, in transform_module_impl
    return tree.visit(self)
  File "/Users/sebastian/.local/pipx/venvs/bump-pydantic/lib/python3.10/site-packages/libcst/_nodes/module.py", line 90, in visit
    result = super(Module, self).visit(visitor)
  File "/Users/sebastian/.local/pipx/venvs/bump-pydantic/lib/python3.10/site-packages/libcst/_nodes/base.py", line 218, in visit
    should_visit_children = visitor.on_visit(self)
  File "/Users/sebastian/.local/pipx/venvs/bump-pydantic/lib/python3.10/site-packages/libcst/matchers/_visitors.py", line 511, in on_visit
    return CSTTransformer.on_visit(self, node)
  File "/Users/sebastian/.local/pipx/venvs/bump-pydantic/lib/python3.10/site-packages/libcst/_visitors.py", line 44, in on_visit
    retval = visit_func(node)
  File "/Users/sebastian/.local/pipx/venvs/bump-pydantic/lib/python3.10/site-packages/libcst/codemod/visitors/_remove_imports.py", line 300, in visit_Module
    node.visit(visitor)
  File "/Users/sebastian/.local/pipx/venvs/bump-pydantic/lib/python3.10/site-packages/libcst/_nodes/module.py", line 90, in visit
    result = super(Module, self).visit(visitor)
  File "/Users/sebastian/.local/pipx/venvs/bump-pydantic/lib/python3.10/site-packages/libcst/_nodes/base.py", line 218, in visit
    should_visit_children = visitor.on_visit(self)
  File "/Users/sebastian/.local/pipx/venvs/bump-pydantic/lib/python3.10/site-packages/libcst/matchers/_visitors.py", line 718, in on_visit
    return CSTVisitor.on_visit(self, node)
  File "/Users/sebastian/.local/pipx/venvs/bump-pydantic/lib/python3.10/site-packages/libcst/_visitors.py", line 123, in on_visit
    retval = visit_func(node)
  File "/Users/sebastian/.local/pipx/venvs/bump-pydantic/lib/python3.10/site-packages/libcst/codemod/visitors/_gather_unused_imports.py", line 71, in visit_Module
    node.visit(annotation_visitor)
  File "/Users/sebastian/.local/pipx/venvs/bump-pydantic/lib/python3.10/site-packages/libcst/_nodes/module.py", line 90, in visit
    result = super(Module, self).visit(visitor)
  File "/Users/sebastian/.local/pipx/venvs/bump-pydantic/lib/python3.10/site-packages/libcst/_nodes/base.py", line 227, in visit
    _CSTNodeSelfT, self._visit_and_replace_children(visitor)
  File "/Users/sebastian/.local/pipx/venvs/bump-pydantic/lib/python3.10/site-packages/libcst/_nodes/module.py", line 74, in _visit_and_replace_children
    body=visit_body_sequence(self, "body", self.body, visitor),
  File "/Users/sebastian/.local/pipx/venvs/bump-pydantic/lib/python3.10/site-packages/libcst/_nodes/internal.py", line 227, in visit_body_sequence
    return tuple(visit_body_iterable(parent, fieldname, children, visitor))
  File "/Users/sebastian/.local/pipx/venvs/bump-pydantic/lib/python3.10/site-packages/libcst/_nodes/internal.py", line 193, in visit_body_iterable
    new_child = child.visit(visitor)
  File "/Users/sebastian/.local/pipx/venvs/bump-pydantic/lib/python3.10/site-packages/libcst/_nodes/base.py", line 227, in visit
    _CSTNodeSelfT, self._visit_and_replace_children(visitor)
  File "/Users/sebastian/.local/pipx/venvs/bump-pydantic/lib/python3.10/site-packages/libcst/_nodes/statement.py", line 1931, in _visit_and_replace_children
    body=visit_required(self, "body", self.body, visitor),
  File "/Users/sebastian/.local/pipx/venvs/bump-pydantic/lib/python3.10/site-packages/libcst/_nodes/internal.py", line 81, in visit_required
    result = node.visit(visitor)
  File "/Users/sebastian/.local/pipx/venvs/bump-pydantic/lib/python3.10/site-packages/libcst/_nodes/base.py", line 227, in visit
    _CSTNodeSelfT, self._visit_and_replace_children(visitor)
  File "/Users/sebastian/.local/pipx/venvs/bump-pydantic/lib/python3.10/site-packages/libcst/_nodes/statement.py", line 697, in _visit_and_replace_children
    body=visit_body_sequence(self, "body", self.body, visitor),
  File "/Users/sebastian/.local/pipx/venvs/bump-pydantic/lib/python3.10/site-packages/libcst/_nodes/internal.py", line 227, in visit_body_sequence
    return tuple(visit_body_iterable(parent, fieldname, children, visitor))
  File "/Users/sebastian/.local/pipx/venvs/bump-pydantic/lib/python3.10/site-packages/libcst/_nodes/internal.py", line 193, in visit_body_iterable
    new_child = child.visit(visitor)
  File "/Users/sebastian/.local/pipx/venvs/bump-pydantic/lib/python3.10/site-packages/libcst/_nodes/base.py", line 227, in visit
    _CSTNodeSelfT, self._visit_and_replace_children(visitor)
  File "/Users/sebastian/.local/pipx/venvs/bump-pydantic/lib/python3.10/site-packages/libcst/_nodes/statement.py", line 442, in _visit_and_replace_children
    body=visit_sequence(self, "body", self.body, visitor),
  File "/Users/sebastian/.local/pipx/venvs/bump-pydantic/lib/python3.10/site-packages/libcst/_nodes/internal.py", line 177, in visit_sequence
    return tuple(visit_iterable(parent, fieldname, children, visitor))
  File "/Users/sebastian/.local/pipx/venvs/bump-pydantic/lib/python3.10/site-packages/libcst/_nodes/internal.py", line 159, in visit_iterable
    new_child = child.visit(visitor)
  File "/Users/sebastian/.local/pipx/venvs/bump-pydantic/lib/python3.10/site-packages/libcst/_nodes/base.py", line 227, in visit
    _CSTNodeSelfT, self._visit_and_replace_children(visitor)
  File "/Users/sebastian/.local/pipx/venvs/bump-pydantic/lib/python3.10/site-packages/libcst/_nodes/statement.py", line 1542, in _visit_and_replace_children
    annotation=visit_required(self, "annotation", self.annotation, visitor),
  File "/Users/sebastian/.local/pipx/venvs/bump-pydantic/lib/python3.10/site-packages/libcst/_nodes/internal.py", line 81, in visit_required
    result = node.visit(visitor)
  File "/Users/sebastian/.local/pipx/venvs/bump-pydantic/lib/python3.10/site-packages/libcst/_nodes/base.py", line 227, in visit
    _CSTNodeSelfT, self._visit_and_replace_children(visitor)
  File "/Users/sebastian/.local/pipx/venvs/bump-pydantic/lib/python3.10/site-packages/libcst/_nodes/expression.py", line 1673, in _visit_and_replace_children
    annotation=visit_required(self, "annotation", self.annotation, visitor),
  File "/Users/sebastian/.local/pipx/venvs/bump-pydantic/lib/python3.10/site-packages/libcst/_nodes/internal.py", line 81, in visit_required
    result = node.visit(visitor)
  File "/Users/sebastian/.local/pipx/venvs/bump-pydantic/lib/python3.10/site-packages/libcst/_nodes/base.py", line 227, in visit
    _CSTNodeSelfT, self._visit_and_replace_children(visitor)
  File "/Users/sebastian/.local/pipx/venvs/bump-pydantic/lib/python3.10/site-packages/libcst/_nodes/expression.py", line 1604, in _visit_and_replace_children
    slice=visit_sequence(self, "slice", self.slice, visitor),
  File "/Users/sebastian/.local/pipx/venvs/bump-pydantic/lib/python3.10/site-packages/libcst/_nodes/internal.py", line 177, in visit_sequence
    return tuple(visit_iterable(parent, fieldname, children, visitor))
  File "/Users/sebastian/.local/pipx/venvs/bump-pydantic/lib/python3.10/site-packages/libcst/_nodes/internal.py", line 159, in visit_iterable
    new_child = child.visit(visitor)
  File "/Users/sebastian/.local/pipx/venvs/bump-pydantic/lib/python3.10/site-packages/libcst/_nodes/base.py", line 227, in visit
    _CSTNodeSelfT, self._visit_and_replace_children(visitor)
  File "/Users/sebastian/.local/pipx/venvs/bump-pydantic/lib/python3.10/site-packages/libcst/_nodes/expression.py", line 1549, in _visit_and_replace_children
    slice=visit_required(self, "slice", self.slice, visitor),
  File "/Users/sebastian/.local/pipx/venvs/bump-pydantic/lib/python3.10/site-packages/libcst/_nodes/internal.py", line 81, in visit_required
    result = node.visit(visitor)
  File "/Users/sebastian/.local/pipx/venvs/bump-pydantic/lib/python3.10/site-packages/libcst/_nodes/base.py", line 227, in visit
    _CSTNodeSelfT, self._visit_and_replace_children(visitor)
  File "/Users/sebastian/.local/pipx/venvs/bump-pydantic/lib/python3.10/site-packages/libcst/_nodes/expression.py", line 1463, in _visit_and_replace_children
    value=visit_required(self, "value", self.value, visitor),
  File "/Users/sebastian/.local/pipx/venvs/bump-pydantic/lib/python3.10/site-packages/libcst/_nodes/internal.py", line 81, in visit_required
    result = node.visit(visitor)
  File "/Users/sebastian/.local/pipx/venvs/bump-pydantic/lib/python3.10/site-packages/libcst/_nodes/base.py", line 218, in visit
    should_visit_children = visitor.on_visit(self)
  File "/Users/sebastian/.local/pipx/venvs/bump-pydantic/lib/python3.10/site-packages/libcst/matchers/_visitors.py", line 718, in on_visit
    return CSTVisitor.on_visit(self, node)
  File "/Users/sebastian/.local/pipx/venvs/bump-pydantic/lib/python3.10/site-packages/libcst/_visitors.py", line 123, in on_visit
    retval = visit_func(node)
  File "/Users/sebastian/.local/pipx/venvs/bump-pydantic/lib/python3.10/site-packages/libcst/codemod/visitors/_gather_string_annotation_names.py", line 65, in visit_SimpleString
    self.handle_any_string(node)
  File "/Users/sebastian/.local/pipx/venvs/bump-pydantic/lib/python3.10/site-packages/libcst/codemod/visitors/_gather_string_annotation_names.py", line 74, in handle_any_string
    mod = cst.parse_module(value)
  File "/Users/sebastian/.local/pipx/venvs/bump-pydantic/lib/python3.10/site-packages/libcst/_parser/entrypoints.py", line 109, in parse_module
    result = _parse(
  File "/Users/sebastian/.local/pipx/venvs/bump-pydantic/lib/python3.10/site-packages/libcst/_parser/entrypoints.py", line 55, in _parse
    return parse(source_str)
libcst._exceptions.ParserSyntaxError: Syntax Error @ 1:1.
parser error: error at 1:3: expected one of (, *, +, -, ..., AWAIT, EOF, False, NUMBER, None, True, [, break, continue, lambda, match, not, pass, ~

and
^
kkirsche commented 1 year ago

I have encountered this as well with three other values of Literal:

  1. Literal["data:"]
An error happened on src/api/utilities/validators/data_url_validator.py.
Traceback (most recent call last):
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/bump_pydantic/main.py", line 185, in run_codemods
    output_tree = transformer.transform_module(input_tree)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/codemod/_command.py", line 87, in transform_module
    tree = self._instantiate_and_run(transform, tree)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/codemod/_command.py", line 57, in _instantiate_and_run
    return inst.transform_module(tree)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/codemod/_codemod.py", line 108, in transform_module
    return self.transform_module_impl(tree_with_metadata)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/codemod/_visitor.py", line 32, in transform_module_impl
    return tree.visit(self)
           ^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_nodes/module.py", line 90, in visit
    result = super(Module, self).visit(visitor)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_nodes/base.py", line 218, in visit
    should_visit_children = visitor.on_visit(self)
                            ^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/matchers/_visitors.py", line 511, in on_visit
    return CSTTransformer.on_visit(self, node)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_visitors.py", line 44, in on_visit
    retval = visit_func(node)
             ^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/codemod/visitors/_remove_imports.py", line 300, in visit_Module
    node.visit(visitor)
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_nodes/module.py", line 90, in visit
    result = super(Module, self).visit(visitor)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_nodes/base.py", line 218, in visit
    should_visit_children = visitor.on_visit(self)
                            ^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/matchers/_visitors.py", line 718, in on_visit
    return CSTVisitor.on_visit(self, node)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_visitors.py", line 123, in on_visit
    retval = visit_func(node)
             ^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/codemod/visitors/_gather_unused_imports.py", line 71, in visit_Module
    node.visit(annotation_visitor)
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_nodes/module.py", line 90, in visit
    result = super(Module, self).visit(visitor)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_nodes/base.py", line 227, in visit
    _CSTNodeSelfT, self._visit_and_replace_children(visitor)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_nodes/module.py", line 74, in _visit_and_replace_children
    body=visit_body_sequence(self, "body", self.body, visitor),
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_nodes/internal.py", line 227, in visit_body_sequence
    return tuple(visit_body_iterable(parent, fieldname, children, visitor))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_nodes/internal.py", line 193, in visit_body_iterable
    new_child = child.visit(visitor)
                ^^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_nodes/base.py", line 227, in visit
    _CSTNodeSelfT, self._visit_and_replace_children(visitor)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_nodes/statement.py", line 1931, in _visit_and_replace_children
    body=visit_required(self, "body", self.body, visitor),
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_nodes/internal.py", line 81, in visit_required
    result = node.visit(visitor)
             ^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_nodes/base.py", line 227, in visit
    _CSTNodeSelfT, self._visit_and_replace_children(visitor)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_nodes/statement.py", line 697, in _visit_and_replace_children
    body=visit_body_sequence(self, "body", self.body, visitor),
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_nodes/internal.py", line 227, in visit_body_sequence
    return tuple(visit_body_iterable(parent, fieldname, children, visitor))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_nodes/internal.py", line 193, in visit_body_iterable
    new_child = child.visit(visitor)
                ^^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_nodes/base.py", line 227, in visit
    _CSTNodeSelfT, self._visit_and_replace_children(visitor)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_nodes/statement.py", line 442, in _visit_and_replace_children
    body=visit_sequence(self, "body", self.body, visitor),
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_nodes/internal.py", line 177, in visit_sequence
    return tuple(visit_iterable(parent, fieldname, children, visitor))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_nodes/internal.py", line 159, in visit_iterable
    new_child = child.visit(visitor)
                ^^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_nodes/base.py", line 227, in visit
    _CSTNodeSelfT, self._visit_and_replace_children(visitor)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_nodes/statement.py", line 1542, in _visit_and_replace_children
    annotation=visit_required(self, "annotation", self.annotation, visitor),
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_nodes/internal.py", line 81, in visit_required
    result = node.visit(visitor)
             ^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_nodes/base.py", line 227, in visit
    _CSTNodeSelfT, self._visit_and_replace_children(visitor)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_nodes/expression.py", line 1673, in _visit_and_replace_children
    annotation=visit_required(self, "annotation", self.annotation, visitor),
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_nodes/internal.py", line 81, in visit_required
    result = node.visit(visitor)
             ^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_nodes/base.py", line 227, in visit
    _CSTNodeSelfT, self._visit_and_replace_children(visitor)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_nodes/expression.py", line 1604, in _visit_and_replace_children
    slice=visit_sequence(self, "slice", self.slice, visitor),
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_nodes/internal.py", line 177, in visit_sequence
    return tuple(visit_iterable(parent, fieldname, children, visitor))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_nodes/internal.py", line 159, in visit_iterable
    new_child = child.visit(visitor)
                ^^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_nodes/base.py", line 227, in visit
    _CSTNodeSelfT, self._visit_and_replace_children(visitor)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_nodes/expression.py", line 1549, in _visit_and_replace_children
    slice=visit_required(self, "slice", self.slice, visitor),
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_nodes/internal.py", line 81, in visit_required
    result = node.visit(visitor)
             ^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_nodes/base.py", line 227, in visit
    _CSTNodeSelfT, self._visit_and_replace_children(visitor)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_nodes/expression.py", line 1463, in _visit_and_replace_children
    value=visit_required(self, "value", self.value, visitor),
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_nodes/internal.py", line 81, in visit_required
    result = node.visit(visitor)
             ^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_nodes/base.py", line 218, in visit
    should_visit_children = visitor.on_visit(self)
                            ^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/matchers/_visitors.py", line 718, in on_visit
    return CSTVisitor.on_visit(self, node)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_visitors.py", line 123, in on_visit
    retval = visit_func(node)
             ^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/codemod/visitors/_gather_string_annotation_names.py", line 65, in visit_SimpleString
    self.handle_any_string(node)
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/codemod/visitors/_gather_string_annotation_names.py", line 74, in handle_any_string
    mod = cst.parse_module(value)
          ^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_parser/entrypoints.py", line 109, in parse_module
    result = _parse(
             ^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_parser/entrypoints.py", line 55, in _parse
    return parse(source_str)
           ^^^^^^^^^^^^^^^^^
libcst._exceptions.ParserSyntaxError: Syntax Error @ 1:1.
parser error: error at 1:5: expected one of +, -, ..., AWAIT, False, NAME, NUMBER, None, True, lambda, not, ~

data:
^
  1. Literal[".csv"]
An error happened on src/api/utilities/validators/csv_validator.py.
Traceback (most recent call last):
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/bump_pydantic/main.py", line 185, in run_codemods
    output_tree = transformer.transform_module(input_tree)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/codemod/_codemod.py", line 108, in transform_module
    return self.transform_module_impl(tree_with_metadata)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/codemod/_visitor.py", line 32, in transform_module_impl
    return tree.visit(self)
           ^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_nodes/module.py", line 90, in visit
    result = super(Module, self).visit(visitor)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_nodes/base.py", line 218, in visit
    should_visit_children = visitor.on_visit(self)
                            ^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/matchers/_visitors.py", line 511, in on_visit
    return CSTTransformer.on_visit(self, node)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_visitors.py", line 44, in on_visit
    retval = visit_func(node)
             ^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/codemod/visitors/_remove_imports.py", line 300, in visit_Module
    node.visit(visitor)
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_nodes/module.py", line 90, in visit
    result = super(Module, self).visit(visitor)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_nodes/base.py", line 218, in visit
    should_visit_children = visitor.on_visit(self)
                            ^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/matchers/_visitors.py", line 718, in on_visit
    return CSTVisitor.on_visit(self, node)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_visitors.py", line 123, in on_visit
    retval = visit_func(node)
             ^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/codemod/visitors/_gather_unused_imports.py", line 71, in visit_Module
    node.visit(annotation_visitor)
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_nodes/module.py", line 90, in visit
    result = super(Module, self).visit(visitor)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_nodes/base.py", line 227, in visit
    _CSTNodeSelfT, self._visit_and_replace_children(visitor)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_nodes/module.py", line 74, in _visit_and_replace_children
    body=visit_body_sequence(self, "body", self.body, visitor),
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_nodes/internal.py", line 227, in visit_body_sequence
    return tuple(visit_body_iterable(parent, fieldname, children, visitor))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_nodes/internal.py", line 193, in visit_body_iterable
    new_child = child.visit(visitor)
                ^^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_nodes/base.py", line 227, in visit
    _CSTNodeSelfT, self._visit_and_replace_children(visitor)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_nodes/statement.py", line 1931, in _visit_and_replace_children
    body=visit_required(self, "body", self.body, visitor),
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_nodes/internal.py", line 81, in visit_required
    result = node.visit(visitor)
             ^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_nodes/base.py", line 227, in visit
    _CSTNodeSelfT, self._visit_and_replace_children(visitor)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_nodes/statement.py", line 697, in _visit_and_replace_children
    body=visit_body_sequence(self, "body", self.body, visitor),
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_nodes/internal.py", line 227, in visit_body_sequence
    return tuple(visit_body_iterable(parent, fieldname, children, visitor))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_nodes/internal.py", line 193, in visit_body_iterable
    new_child = child.visit(visitor)
                ^^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_nodes/base.py", line 227, in visit
    _CSTNodeSelfT, self._visit_and_replace_children(visitor)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_nodes/statement.py", line 442, in _visit_and_replace_children
    body=visit_sequence(self, "body", self.body, visitor),
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_nodes/internal.py", line 177, in visit_sequence
    return tuple(visit_iterable(parent, fieldname, children, visitor))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_nodes/internal.py", line 159, in visit_iterable
    new_child = child.visit(visitor)
                ^^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_nodes/base.py", line 227, in visit
    _CSTNodeSelfT, self._visit_and_replace_children(visitor)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_nodes/statement.py", line 1542, in _visit_and_replace_children
    annotation=visit_required(self, "annotation", self.annotation, visitor),
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_nodes/internal.py", line 81, in visit_required
    result = node.visit(visitor)
             ^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_nodes/base.py", line 227, in visit
    _CSTNodeSelfT, self._visit_and_replace_children(visitor)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_nodes/expression.py", line 1673, in _visit_and_replace_children
    annotation=visit_required(self, "annotation", self.annotation, visitor),
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_nodes/internal.py", line 81, in visit_required
    result = node.visit(visitor)
             ^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_nodes/base.py", line 227, in visit
    _CSTNodeSelfT, self._visit_and_replace_children(visitor)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_nodes/expression.py", line 1604, in _visit_and_replace_children
    slice=visit_sequence(self, "slice", self.slice, visitor),
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_nodes/internal.py", line 177, in visit_sequence
    return tuple(visit_iterable(parent, fieldname, children, visitor))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_nodes/internal.py", line 159, in visit_iterable
    new_child = child.visit(visitor)
                ^^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_nodes/base.py", line 227, in visit
    _CSTNodeSelfT, self._visit_and_replace_children(visitor)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_nodes/expression.py", line 1549, in _visit_and_replace_children
    slice=visit_required(self, "slice", self.slice, visitor),
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_nodes/internal.py", line 81, in visit_required
    result = node.visit(visitor)
             ^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_nodes/base.py", line 227, in visit
    _CSTNodeSelfT, self._visit_and_replace_children(visitor)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_nodes/expression.py", line 1463, in _visit_and_replace_children
    value=visit_required(self, "value", self.value, visitor),
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_nodes/internal.py", line 81, in visit_required
    result = node.visit(visitor)
             ^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_nodes/base.py", line 218, in visit
    should_visit_children = visitor.on_visit(self)
                            ^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/matchers/_visitors.py", line 718, in on_visit
    return CSTVisitor.on_visit(self, node)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_visitors.py", line 123, in on_visit
    retval = visit_func(node)
             ^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/codemod/visitors/_gather_string_annotation_names.py", line 65, in visit_SimpleString
    self.handle_any_string(node)
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/codemod/visitors/_gather_string_annotation_names.py", line 74, in handle_any_string
    mod = cst.parse_module(value)
          ^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_parser/entrypoints.py", line 109, in parse_module
    result = _parse(
             ^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_parser/entrypoints.py", line 55, in _parse
    return parse(source_str)
           ^^^^^^^^^^^^^^^^^
libcst._exceptions.ParserSyntaxError: Syntax Error @ 1:1.
parser error: error at 1:1: expected one of (, *, +, -, ..., AWAIT, EOF, False, NAME, NUMBER, None, True, [, break, continue, lambda, match, not, pass, ~

.csv
^
  1. Literal["3mo", "6mo", "9mo", "12mo", "infinite", "never"]
An error happened on src/api/client/requests.py.
Traceback (most recent call last):
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/bump_pydantic/main.py", line 185, in run_codemods
    output_tree = transformer.transform_module(input_tree)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/codemod/_codemod.py", line 108, in transform_module
    return self.transform_module_impl(tree_with_metadata)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/codemod/_visitor.py", line 32, in transform_module_impl
    return tree.visit(self)
           ^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_nodes/module.py", line 90, in visit
    result = super(Module, self).visit(visitor)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_nodes/base.py", line 218, in visit
    should_visit_children = visitor.on_visit(self)
                            ^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/matchers/_visitors.py", line 511, in on_visit
    return CSTTransformer.on_visit(self, node)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_visitors.py", line 44, in on_visit
    retval = visit_func(node)
             ^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/codemod/visitors/_remove_imports.py", line 300, in visit_Module
    node.visit(visitor)
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_nodes/module.py", line 90, in visit
    result = super(Module, self).visit(visitor)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_nodes/base.py", line 218, in visit
    should_visit_children = visitor.on_visit(self)
                            ^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/matchers/_visitors.py", line 718, in on_visit
    return CSTVisitor.on_visit(self, node)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_visitors.py", line 123, in on_visit
    retval = visit_func(node)
             ^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/codemod/visitors/_gather_unused_imports.py", line 71, in visit_Module
    node.visit(annotation_visitor)
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_nodes/module.py", line 90, in visit
    result = super(Module, self).visit(visitor)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_nodes/base.py", line 227, in visit
    _CSTNodeSelfT, self._visit_and_replace_children(visitor)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_nodes/module.py", line 74, in _visit_and_replace_children
    body=visit_body_sequence(self, "body", self.body, visitor),
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_nodes/internal.py", line 227, in visit_body_sequence
    return tuple(visit_body_iterable(parent, fieldname, children, visitor))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_nodes/internal.py", line 193, in visit_body_iterable
    new_child = child.visit(visitor)
                ^^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_nodes/base.py", line 227, in visit
    _CSTNodeSelfT, self._visit_and_replace_children(visitor)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_nodes/statement.py", line 1931, in _visit_and_replace_children
    body=visit_required(self, "body", self.body, visitor),
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_nodes/internal.py", line 81, in visit_required
    result = node.visit(visitor)
             ^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_nodes/base.py", line 227, in visit
    _CSTNodeSelfT, self._visit_and_replace_children(visitor)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_nodes/statement.py", line 697, in _visit_and_replace_children
    body=visit_body_sequence(self, "body", self.body, visitor),
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_nodes/internal.py", line 227, in visit_body_sequence
    return tuple(visit_body_iterable(parent, fieldname, children, visitor))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_nodes/internal.py", line 193, in visit_body_iterable
    new_child = child.visit(visitor)
                ^^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_nodes/base.py", line 227, in visit
    _CSTNodeSelfT, self._visit_and_replace_children(visitor)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_nodes/statement.py", line 442, in _visit_and_replace_children
    body=visit_sequence(self, "body", self.body, visitor),
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_nodes/internal.py", line 177, in visit_sequence
    return tuple(visit_iterable(parent, fieldname, children, visitor))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_nodes/internal.py", line 159, in visit_iterable
    new_child = child.visit(visitor)
                ^^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_nodes/base.py", line 227, in visit
    _CSTNodeSelfT, self._visit_and_replace_children(visitor)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_nodes/statement.py", line 1542, in _visit_and_replace_children
    annotation=visit_required(self, "annotation", self.annotation, visitor),
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_nodes/internal.py", line 81, in visit_required
    result = node.visit(visitor)
             ^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_nodes/base.py", line 227, in visit
    _CSTNodeSelfT, self._visit_and_replace_children(visitor)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_nodes/expression.py", line 1673, in _visit_and_replace_children
    annotation=visit_required(self, "annotation", self.annotation, visitor),
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_nodes/internal.py", line 81, in visit_required
    result = node.visit(visitor)
             ^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_nodes/base.py", line 227, in visit
    _CSTNodeSelfT, self._visit_and_replace_children(visitor)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_nodes/expression.py", line 1604, in _visit_and_replace_children
    slice=visit_sequence(self, "slice", self.slice, visitor),
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_nodes/internal.py", line 177, in visit_sequence
    return tuple(visit_iterable(parent, fieldname, children, visitor))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_nodes/internal.py", line 159, in visit_iterable
    new_child = child.visit(visitor)
                ^^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_nodes/base.py", line 227, in visit
    _CSTNodeSelfT, self._visit_and_replace_children(visitor)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_nodes/expression.py", line 1549, in _visit_and_replace_children
    slice=visit_required(self, "slice", self.slice, visitor),
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_nodes/internal.py", line 81, in visit_required
    result = node.visit(visitor)
             ^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_nodes/base.py", line 227, in visit
    _CSTNodeSelfT, self._visit_and_replace_children(visitor)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_nodes/expression.py", line 1463, in _visit_and_replace_children
    value=visit_required(self, "value", self.value, visitor),
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_nodes/internal.py", line 81, in visit_required
    result = node.visit(visitor)
             ^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_nodes/base.py", line 218, in visit
    should_visit_children = visitor.on_visit(self)
                            ^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/matchers/_visitors.py", line 718, in on_visit
    return CSTVisitor.on_visit(self, node)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_visitors.py", line 123, in on_visit
    retval = visit_func(node)
             ^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/codemod/visitors/_gather_string_annotation_names.py", line 65, in visit_SimpleString
    self.handle_any_string(node)
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/codemod/visitors/_gather_string_annotation_names.py", line 74, in handle_any_string
    mod = cst.parse_module(value)
          ^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_parser/entrypoints.py", line 109, in parse_module
    result = _parse(
             ^^^^^^^
  File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/api-g3Hahb8t-py3.11/lib/python3.11/site-packages/libcst/_parser/entrypoints.py", line 55, in _parse
    return parse(source_str)
           ^^^^^^^^^^^^^^^^^
libcst._exceptions.ParserSyntaxError: Syntax Error @ 1:1.
parser error: error at 1:3: expected one of !=, %, &, (, *, **, +, ,, -, ., /, //, ;, <, <<, <=, ==, >, >=, >>, @, NEWLINE, [, ^, and, if, in, is, not, or, |

3mo
^
kkirsche commented 1 year ago

X-Ref: https://github.com/pydantic/bump-pydantic/issues/115

Kludex commented 1 year ago

This is not a bug on bump-pydantic. This is an issue on LibCST.

I think we can improve the error message here. :)

shufflebits commented 1 year ago

Breaks on "in" as well.

from typing import  Literal

from pydantic import BaseModel

class Thing(BaseModel):
    value: Literal["in"]
An error happened on src/model/demo.py.
Traceback (most recent call last):
  File "/home/hclark/repos/stamp/venv/lib/python3.10/site-packages/bump_pydantic/main.py", line 185, in run_codemods
    output_tree = transformer.transform_module(input_tree)
  File "/home/hclark/repos/stamp/venv/lib/python3.10/site-packages/libcst/codemod/_codemod.py", line 108, in transform_module
    return self.transform_module_impl(tree_with_metadata)
  File "/home/hclark/repos/stamp/venv/lib/python3.10/site-packages/libcst/codemod/_visitor.py", line 32, in transform_module_impl
    return tree.visit(self)
  File "/home/hclark/repos/stamp/venv/lib/python3.10/site-packages/libcst/_nodes/module.py", line 90, in visit
    result = super(Module, self).visit(visitor)
  File "/home/hclark/repos/stamp/venv/lib/python3.10/site-packages/libcst/_nodes/base.py", line 218, in visit
    should_visit_children = visitor.on_visit(self)
  File "/home/hclark/repos/stamp/venv/lib/python3.10/site-packages/libcst/matchers/_visitors.py", line 511, in on_visit
    return CSTTransformer.on_visit(self, node)
  File "/home/hclark/repos/stamp/venv/lib/python3.10/site-packages/libcst/_visitors.py", line 44, in on_visit
    retval = visit_func(node)
  File "/home/hclark/repos/stamp/venv/lib/python3.10/site-packages/libcst/codemod/visitors/_remove_imports.py", line 300, in visit_Module
    node.visit(visitor)
  File "/home/hclark/repos/stamp/venv/lib/python3.10/site-packages/libcst/_nodes/module.py", line 90, in visit
    result = super(Module, self).visit(visitor)
  File "/home/hclark/repos/stamp/venv/lib/python3.10/site-packages/libcst/_nodes/base.py", line 218, in visit
    should_visit_children = visitor.on_visit(self)
  File "/home/hclark/repos/stamp/venv/lib/python3.10/site-packages/libcst/matchers/_visitors.py", line 718, in on_visit
    return CSTVisitor.on_visit(self, node)
  File "/home/hclark/repos/stamp/venv/lib/python3.10/site-packages/libcst/_visitors.py", line 123, in on_visit
    retval = visit_func(node)
  File "/home/hclark/repos/stamp/venv/lib/python3.10/site-packages/libcst/codemod/visitors/_gather_unused_imports.py", line 71, in visit_Module
    node.visit(annotation_visitor)
  File "/home/hclark/repos/stamp/venv/lib/python3.10/site-packages/libcst/_nodes/module.py", line 90, in visit
    result = super(Module, self).visit(visitor)
  File "/home/hclark/repos/stamp/venv/lib/python3.10/site-packages/libcst/_nodes/base.py", line 227, in visit
    _CSTNodeSelfT, self._visit_and_replace_children(visitor)
  File "/home/hclark/repos/stamp/venv/lib/python3.10/site-packages/libcst/_nodes/module.py", line 74, in _visit_and_replace_children
    body=visit_body_sequence(self, "body", self.body, visitor),
  File "/home/hclark/repos/stamp/venv/lib/python3.10/site-packages/libcst/_nodes/internal.py", line 227, in visit_body_sequence
    return tuple(visit_body_iterable(parent, fieldname, children, visitor))
  File "/home/hclark/repos/stamp/venv/lib/python3.10/site-packages/libcst/_nodes/internal.py", line 193, in visit_body_iterable
    new_child = child.visit(visitor)
  File "/home/hclark/repos/stamp/venv/lib/python3.10/site-packages/libcst/_nodes/base.py", line 227, in visit
    _CSTNodeSelfT, self._visit_and_replace_children(visitor)
  File "/home/hclark/repos/stamp/venv/lib/python3.10/site-packages/libcst/_nodes/statement.py", line 1931, in _visit_and_replace_children
    body=visit_required(self, "body", self.body, visitor),
  File "/home/hclark/repos/stamp/venv/lib/python3.10/site-packages/libcst/_nodes/internal.py", line 81, in visit_required
    result = node.visit(visitor)
  File "/home/hclark/repos/stamp/venv/lib/python3.10/site-packages/libcst/_nodes/base.py", line 227, in visit
    _CSTNodeSelfT, self._visit_and_replace_children(visitor)
  File "/home/hclark/repos/stamp/venv/lib/python3.10/site-packages/libcst/_nodes/statement.py", line 697, in _visit_and_replace_children
    body=visit_body_sequence(self, "body", self.body, visitor),
  File "/home/hclark/repos/stamp/venv/lib/python3.10/site-packages/libcst/_nodes/internal.py", line 227, in visit_body_sequence
    return tuple(visit_body_iterable(parent, fieldname, children, visitor))
  File "/home/hclark/repos/stamp/venv/lib/python3.10/site-packages/libcst/_nodes/internal.py", line 193, in visit_body_iterable
    new_child = child.visit(visitor)
  File "/home/hclark/repos/stamp/venv/lib/python3.10/site-packages/libcst/_nodes/base.py", line 227, in visit
    _CSTNodeSelfT, self._visit_and_replace_children(visitor)
  File "/home/hclark/repos/stamp/venv/lib/python3.10/site-packages/libcst/_nodes/statement.py", line 442, in _visit_and_replace_children
    body=visit_sequence(self, "body", self.body, visitor),
  File "/home/hclark/repos/stamp/venv/lib/python3.10/site-packages/libcst/_nodes/internal.py", line 177, in visit_sequence
    return tuple(visit_iterable(parent, fieldname, children, visitor))
  File "/home/hclark/repos/stamp/venv/lib/python3.10/site-packages/libcst/_nodes/internal.py", line 159, in visit_iterable
    new_child = child.visit(visitor)
  File "/home/hclark/repos/stamp/venv/lib/python3.10/site-packages/libcst/_nodes/base.py", line 227, in visit
    _CSTNodeSelfT, self._visit_and_replace_children(visitor)
  File "/home/hclark/repos/stamp/venv/lib/python3.10/site-packages/libcst/_nodes/statement.py", line 1542, in _visit_and_replace_children
    annotation=visit_required(self, "annotation", self.annotation, visitor),
  File "/home/hclark/repos/stamp/venv/lib/python3.10/site-packages/libcst/_nodes/internal.py", line 81, in visit_required
    result = node.visit(visitor)
  File "/home/hclark/repos/stamp/venv/lib/python3.10/site-packages/libcst/_nodes/base.py", line 227, in visit
    _CSTNodeSelfT, self._visit_and_replace_children(visitor)
  File "/home/hclark/repos/stamp/venv/lib/python3.10/site-packages/libcst/_nodes/expression.py", line 1673, in _visit_and_replace_children
    annotation=visit_required(self, "annotation", self.annotation, visitor),
  File "/home/hclark/repos/stamp/venv/lib/python3.10/site-packages/libcst/_nodes/internal.py", line 81, in visit_required
    result = node.visit(visitor)
  File "/home/hclark/repos/stamp/venv/lib/python3.10/site-packages/libcst/_nodes/base.py", line 227, in visit
    _CSTNodeSelfT, self._visit_and_replace_children(visitor)
  File "/home/hclark/repos/stamp/venv/lib/python3.10/site-packages/libcst/_nodes/expression.py", line 1604, in _visit_and_replace_children
    slice=visit_sequence(self, "slice", self.slice, visitor),
  File "/home/hclark/repos/stamp/venv/lib/python3.10/site-packages/libcst/_nodes/internal.py", line 177, in visit_sequence
    return tuple(visit_iterable(parent, fieldname, children, visitor))
  File "/home/hclark/repos/stamp/venv/lib/python3.10/site-packages/libcst/_nodes/internal.py", line 159, in visit_iterable
    new_child = child.visit(visitor)
  File "/home/hclark/repos/stamp/venv/lib/python3.10/site-packages/libcst/_nodes/base.py", line 227, in visit
    _CSTNodeSelfT, self._visit_and_replace_children(visitor)
  File "/home/hclark/repos/stamp/venv/lib/python3.10/site-packages/libcst/_nodes/expression.py", line 1549, in _visit_and_replace_children
    slice=visit_required(self, "slice", self.slice, visitor),
  File "/home/hclark/repos/stamp/venv/lib/python3.10/site-packages/libcst/_nodes/internal.py", line 81, in visit_required
    result = node.visit(visitor)
  File "/home/hclark/repos/stamp/venv/lib/python3.10/site-packages/libcst/_nodes/base.py", line 227, in visit
    _CSTNodeSelfT, self._visit_and_replace_children(visitor)
  File "/home/hclark/repos/stamp/venv/lib/python3.10/site-packages/libcst/_nodes/expression.py", line 1463, in _visit_and_replace_children
    value=visit_required(self, "value", self.value, visitor),
  File "/home/hclark/repos/stamp/venv/lib/python3.10/site-packages/libcst/_nodes/internal.py", line 81, in visit_required
    result = node.visit(visitor)
  File "/home/hclark/repos/stamp/venv/lib/python3.10/site-packages/libcst/_nodes/base.py", line 218, in visit
    should_visit_children = visitor.on_visit(self)
  File "/home/hclark/repos/stamp/venv/lib/python3.10/site-packages/libcst/matchers/_visitors.py", line 718, in on_visit
    return CSTVisitor.on_visit(self, node)
  File "/home/hclark/repos/stamp/venv/lib/python3.10/site-packages/libcst/_visitors.py", line 123, in on_visit
    retval = visit_func(node)
  File "/home/hclark/repos/stamp/venv/lib/python3.10/site-packages/libcst/codemod/visitors/_gather_string_annotation_names.py", line 65, in visit_SimpleString
    self.handle_any_string(node)
  File "/home/hclark/repos/stamp/venv/lib/python3.10/site-packages/libcst/codemod/visitors/_gather_string_annotation_names.py", line 74, in handle_any_string
    mod = cst.parse_module(value)
  File "/home/hclark/repos/stamp/venv/lib/python3.10/site-packages/libcst/_parser/entrypoints.py", line 109, in parse_module
    result = _parse(
  File "/home/hclark/repos/stamp/venv/lib/python3.10/site-packages/libcst/_parser/entrypoints.py", line 55, in _parse
    return parse(source_str)
libcst._exceptions.ParserSyntaxError: Syntax Error @ 1:1.
parser error: error at 1:2: expected one of (, *, +, -, ..., AWAIT, EOF, False, NUMBER, None, True, [, break, continue, lambda, match, not, pass, ~

in
^
Kludex commented 1 year ago

I don't need more examples :)

It breaks on every literal that is a reserved keyword.

kkirsche commented 1 year ago

I don't need more examples :)

It breaks on every literal that is a reserved keyword.

First, is there an issue open with LibCST? Maybe https://github.com/Instagram/LibCST/issues/924?

From the way you describe it @Kludex it sounds as if it's only reserved keywords that are failing, in which case I'd ask what reserved keywords are Literal[".csv"] and Literal["3mo", "6mo", "9mo", "12mo", "infinite", "never"] triggering as shown in my examples above? Apologies if I misunderstood you and that was simply in reference to some of but not all of the examples.

Kludex commented 1 year ago

Ah... Well... On this repository, it doesn't matter what the issue really is on LibCST. You can ask on their repository.

I'm interested in giving a better error message pointing out that LibCST couldn't parse the code.

Kludex commented 1 year ago

In case of ParserSyntaxError error, there's nothing we can do here. LibCST needs to fix on their end.

I've improved the error message on #128.

justin-snyder-slgg commented 1 year ago

also breaks on literals containing spaces

marksparkza commented 1 year ago

Workaround

Comment out all offending Literal declarations. Re-run bump-pydantic. Uncomment the offending Literal declarations.