Skip to content

Generated client fails flake8 due to trailing comma #179

@dtkav

Description

@dtkav

Describe the bug
A trailing comma in the type signature of the endpoint_macros template causes Union types to include a trailing comma after the last type in the union.

To Reproduce
We run the following script to generate our client:

#!/usr/bin/env bash
set -x  # added for clarity below
rm -rf test-api-client
openapi-python-client generate --path test.yaml
autoflake --in-place --remove-all-unused-imports --remove-unused-variables --expand-star-imports -r test-api-client/
isort test-api-client/
black test-api-client/
# Ignore lines too long and bare except
flake8 --ignore=E722,E501 test-api-client/

With 0.6.0-alpha release it produces the following output:

+ rm -rf test-api-client
+ openapi-python-client generate --path test.yaml
Generating test-api-client
+ autoflake --in-place --remove-all-unused-imports --remove-unused-variables --expand-star-imports -r test-api-client/
+ isort test-api-client/
+ black test-api-client/
reformatted /Users/daniel/openapi-specs1/test-api-client/test_api_client/models/__init__.py
All done! ✨ 🍰 ✨
1 file reformatted, 8 files left unchanged.
+ flake8 --ignore=E722,E501 test-api-client/
test-api-client/test_api_client/api/default/create_cat.py:33:36: E231 missing whitespace after ','
test-api-client/test_api_client/api/default/create_cat.py:43:36: E231 missing whitespace after ','
test-api-client/test_api_client/api/default/create_cat.py:56:36: E231 missing whitespace after ','
test-api-client/test_api_client/api/default/create_cat.py:73:36: E231 missing whitespace after ','
test-api-client/test_api_client/api/default/create_cat.py:86:36: E231 missing whitespace after ','
test-api-client/test_api_client/api/default/create_cat.py:102:36: E231 missing whitespace after ','

Expected behavior
Since flake8 is part of our pipeline, we'd love for it to pass on the generated client.

OpenAPI Spec File
https://gist.github.com/dtkav/3f4525af7aa7f95548c6fc2bac2eef1d

Desktop (please complete the following information):

  • OS: macOS 10.15.6
  • Python Version: 3.8.0
  • openapi-python-client version v.0.6.0-alpha.1

Additional context
I put up PR #178 which seems to fix the issue.

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