Skip to content

Commit 381328f

Browse files
dbantyfyhertz
andauthored
Prevent autoflake to clean imports in module init files (#233)
* Prevent autoflake to clean imports in module init files Co-authored-by: Simon Guigui <[email protected]> Co-authored-by: Dylan Anthony <[email protected]>
1 parent ef04aa3 commit 381328f

File tree

5 files changed

+12
-2
lines changed

5 files changed

+12
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1212
### Fixes
1313

1414
- Prefix generated identifiers to allow leading digits in field names (#206 - @kalzoo).
15+
- Prevent autoflake from removing `__init__.py` imports during generation. (#223 - Thanks @fyhertz!)
1516
- Update minimum Pydantic version to support Python 3.9
1617

1718
### Additions
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
""" A client library for accessing My Test API """
2+
from .client import AuthenticatedClient, Client
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,9 @@
11
""" Contains all the data models used in inputs/outputs """
2+
3+
from .a_model import AModel
4+
from .an_enum import AnEnum
5+
from .an_int_enum import AnIntEnum
6+
from .body_upload_file_tests_upload_post import BodyUploadFileTestsUploadPost
7+
from .different_enum import DifferentEnum
8+
from .http_validation_error import HTTPValidationError
9+
from .validation_error import ValidationError

openapi_python_client/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def update(self) -> Sequence[GeneratorError]:
7777

7878
def _reformat(self) -> None:
7979
subprocess.run(
80-
"autoflake -i -r --remove-all-unused-imports --remove-unused-variables .",
80+
"autoflake -i -r --remove-all-unused-imports --remove-unused-variables --ignore-init-module-imports .",
8181
cwd=self.package_dir,
8282
shell=True,
8383
stdout=subprocess.PIPE,

tests/test___init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ def test__reformat(mocker):
382382
sub_run.assert_has_calls(
383383
[
384384
mocker.call(
385-
"autoflake -i -r --remove-all-unused-imports --remove-unused-variables .",
385+
"autoflake -i -r --remove-all-unused-imports --remove-unused-variables --ignore-init-module-imports .",
386386
cwd=project.package_dir,
387387
shell=True,
388388
stdout=subprocess.PIPE,

0 commit comments

Comments
 (0)