- Sponsor
-
Notifications
You must be signed in to change notification settings - Fork 228
Duplicated imports with --meta none
#939
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
Comments
dbanty
added a commit
that referenced
this issue
Jan 15, 2024
This PR was created by Knope. Merging it will create a new release ### Features #### Add `--meta=pdm` option for generating PEP621 + PDM metadata The default metadata is still `--meta=poetry`, which generates a `pyproject.toml` file with Poetry-specific metadata. This change adds the `--meta=pdm` option which includes [PDM](https://pdm-project.org/latest/)-specific metadata, but also standard [PEP621](https://packaging.python.org/en/latest/guides/writing-pyproject-toml/#writing-pyproject-toml) metadata. This may be useful as a starting point for other dependency managers & build tools (like Hatch). #### Add original OpenAPI `data` attribute to `Response` object PR #767 In custom templates, you can now access a `response.data` attribute that contains the original OpenAPI definition of the response (Response Object or Reference Object). #### Include the `UP` rule for generated Ruff config This enables [pyupgrade-like improvements](https://docs.astral.sh/ruff/rules/#pyupgrade-up) which should replace some `.format()` calls with f-strings. ### Fixes #### Fix Ruff formatting for `--meta=none` PR #940 fixes issue #939. Thanks @satwell! Due to the lack of `pyproject.toml`, Ruff was not getting configured properly when `--meta=none`. As a result, it didn't clean up common generation issues like duplicate imports, which would then cause errors from linters. This is now fixed by changing the default `post_hook` to `ruff check . --fix --extend-select=I` when `--meta=none`. Using `generate --meta=none` should now be almost identical to the code generated by `update`. Co-authored-by: GitHub <[email protected]>
This should be fixed in 0.17.2. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the bug
Running with
--meta none
prints a bunch ofF811
errors from ruff complaining about redefinition of imports. And the resulting output files do have duplicated imports. For example:I think this is happening because with
--meta none
there's nopyproject.toml
that turns on isort functionality in ruff. With the other--meta
options, ruff gets configured withselect = ["F", "I"]
, and this fixes the duplicate imports.One solution would be to explicitly include ruff's isort rules when running ruff in the post hooks. I've found that the following config fixes the issue:
OpenAPI Spec File
This is reproducible with the openapi-python-client test specs, such as https://github.com/raw/openapi-generators/openapi-python-client/main/end_to_end_tests/baseline_openapi_3.0.json.
Desktop (please complete the following information):
The text was updated successfully, but these errors were encountered: