Skip to content

black.parsing.InvalidInput error when enum value is and #364

@boukepostma

Description

@boukepostma

Hi! I'm trying to generate a graphql client of monday.com API and am (possibly) running into a bug.

How to reproduce:

  1. Run wget "https://api.monday.com/v2/get_schema?version=2024-04&format=sdl" -O schema.graphql
  2. Set pyproject.toml to
[tool.ariadne-codegen]
enable_custom_operations = true
schema_path = "schema.graphql"
  1. Run ariadne-codegen

Now, I see the following error:

Selected strategy: Strategy.CLIENT
Using schema from 'schema.graphql'.
Reading queries from ''.
Using 'graphql_client' as package name.
Generating package into '/workspaces/mondaytoframe'.
Using 'Client' as client name.
Using 'AsyncBaseClient' as base client class.
Coping base client class from '/workspaces/mondaytoframe/.venv/lib/python3.12/site-packages/ariadne_codegen/client_generators/dependencies/async_base_client.py'.
Generating enums into 'enums.py'.
Generating inputs into 'input_types.py'.
Generating fragments into 'fragments.py'.
Comments type: stable
Converting fields and arguments name to snake case.
Generating async client.
No files to copy.
No plugin is being used.
Traceback (most recent call last):
  File "/workspaces/mondaytoframe/.venv/bin/ariadne-codegen", line 10, in <module>
    sys.exit(main())
             ^^^^^^
  File "/workspaces/mondaytoframe/.venv/lib/python3.12/site-packages/click/core.py", line 1161, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/workspaces/mondaytoframe/.venv/lib/python3.12/site-packages/click/core.py", line 1082, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/workspaces/mondaytoframe/.venv/lib/python3.12/site-packages/click/core.py", line 1443, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/workspaces/mondaytoframe/.venv/lib/python3.12/site-packages/click/core.py", line 788, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/workspaces/mondaytoframe/.venv/lib/python3.12/site-packages/ariadne_codegen/main.py", line 37, in main
    client(config_dict)
  File "/workspaces/mondaytoframe/.venv/lib/python3.12/site-packages/ariadne_codegen/main.py", line 81, in client
    generated_files = package_generator.generate()
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/workspaces/mondaytoframe/.venv/lib/python3.12/site-packages/ariadne_codegen/client_generators/package.py", line 152, in generate
    self._generate_input_types()
  File "/workspaces/mondaytoframe/.venv/lib/python3.12/site-packages/ariadne_codegen/client_generators/package.py", line 307, in _generate_input_types
    code = self._add_comments_to_code(ast_to_str(module), self.schema_source)
                                      ^^^^^^^^^^^^^^^^^^
  File "/workspaces/mondaytoframe/.venv/lib/python3.12/site-packages/ariadne_codegen/utils.py", line 33, in ast_to_str
    return format_str(isort.code(code), mode=Mode())
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "src/black/__init__.py", line 1208, in format_str
  File "src/black/__init__.py", line 1222, in _format_str_once
  File "src/black/parsing.py", line 98, in lib2to3_parse
black.parsing.InvalidInput: Cannot parse: 45:64:     operator: Optional[ItemsQueryOperator] = ItemsQueryOperator.and

Using version 0.14.0.

This issue feels similar to #220

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions