Skip to content

Invalid PythonIdentifier used #475

Closed
@mtovts

Description

@mtovts

Describe the bug
Generator produces black error and invalid model.

To Reproduce
Steps to reproduce the behavior:

  1. Generate lib from example OpenAPI
  2. See error traceback
  File "/Users/Matvey/Documents/GitHub/openapi-python-client/openapi_python_client/__init__.py", line 113, in build
    self._reformat()
  File "/Users/Matvey/Documents/GitHub/openapi-python-client/openapi_python_client/__init__.py", line 146, in _reformat
    subprocess.run(
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/subprocess.py", line 528, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command 'black .' returned non-zero exit status 123.
  1. See generated model. It uses import statement.
    @classmethod
    def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T:
        d = src_dict.copy()
        import =
        import cls

        import.additional_properties = d
        return import

Expected behavior
The identifier import_ should be used.

OpenAPI Spec File

openapi: 3.0.3
info:
  title: 'Example'
  version: 0.1.0
servers:
  - url: 'http://example.com'
paths:
  '/foo':
    delete:
      responses:
        '200':
          description: OK
components:
  schemas:
    import:
      type: object
      properties: { }

Desktop (please complete the following information):

  • OS: [e.g. macOS 10.15.1] macOS 11.4
  • Python Version: [e.g. 3.8.0] Python 3.9.5
  • openapi-python-client version [e.g. 0.1.0] 0.10.2

Additional context
It worked correctly on 0.10.1. And in my branch fix / overriding-parameters works well too.

Metadata

Metadata

Assignees

No one assigned

    Labels

    🐞bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions