Skip to content

Commit 6582fcf

Browse files
authored
Switch to Ruff & Test Python 3.12 (#870)
* ci: Use Checkout releases instead of shas * ci: Test Python 3.12 * ci: Fix Knope dry-run * Switch to Ruff * test: Ignore `.ruff_cache` in golden records --------- Co-authored-by: Dylan Anthony <dbanty@users.noreply.github.com>
1 parent 4be2047 commit 6582fcf

File tree

68 files changed

+169
-516
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+169
-516
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
default: patch
3+
---
4+
5+
#### Remove useless `pass` statements from generated code
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
default: major
3+
---
4+
5+
#### Use Ruff instead of isort + autoflake at runtime
6+
7+
`isort` and `autoflake` are no longer runtime dependencies, so if you have them set in custom `post_hooks` in a config file, you'll need to make sure they're being installed manually. [`ruff`](https://docs.astral.sh/ruff) is now installed and used by default instead.

.github/check_for_changes.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import subprocess
2+
import sys
23

34
output = subprocess.run(["git", "status", "--porcelain"], capture_output=True, check=True).stdout
45

56
if output == b"":
67
# No changes
7-
exit(0)
8+
sys.exit(0)
89

910
print(output)
10-
exit(1)
11+
sys.exit(1)

.github/workflows/checks.yml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
test:
1212
strategy:
1313
matrix:
14-
python: [ "3.8", "3.9", "3.10", "3.11" ]
14+
python: [ "3.8", "3.9", "3.10", "3.11", "3.12" ]
1515
os: [ ubuntu-latest, macos-latest, windows-latest ]
1616
runs-on: ${{ matrix.os }}
1717
steps:
@@ -48,17 +48,14 @@ jobs:
4848
- name: Run Black
4949
run: poetry run black . --check
5050

51-
- name: Run isort
52-
run: poetry run isort . --check
53-
5451
- name: Run safety
5552
run: poetry export -f requirements.txt | poetry run safety check --bare --stdin
5653

5754
- name: Run mypy
5855
run: poetry run mypy --show-error-codes openapi_python_client
5956

60-
- name: Run pylint
61-
run: poetry run pylint openapi_python_client
57+
- name: Run Ruff
58+
run: poetry run ruff check .
6259

6360
- name: Run pytest
6461
run: poetry run pytest --cov=openapi_python_client --cov-report=term-missing tests end_to_end_tests/test_end_to_end.py --basetemp=tests/tmp
@@ -106,7 +103,7 @@ jobs:
106103
- name: Set up Python
107104
uses: actions/setup-python@v4
108105
with:
109-
python-version: "3.10"
106+
python-version: "3.8"
110107
- name: Get Python Version
111108
id: get_python_version
112109
run: echo "python_version=$(python --version)" >> $GITHUB_OUTPUT

.github/workflows/release-dry-run.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ jobs:
1414
uses: knope-dev/action@v2.0.0
1515
with:
1616
version: 0.12.0
17-
- run: knope release --dry-run
17+
- run: knope prepare-release --dry-run

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ This tool focuses on creating the best developer experience for Python developer
2727

2828
I recommend you install with [pipx](https://pipxproject.github.io/pipx/) so you don't conflict with any other packages you might have: `pipx install openapi-python-client --include-deps`.
2929

30-
> Note the `--include-deps` option which will also make `black`, `isort`, and `autoflake` available in your path so that `openapi-python-client` can use them to clean up the generated code.
30+
> Note the `--include-deps` option which will also make `black` and `ruff` available in your path so that `openapi-python-client` can use them to clean up the generated code.
3131
3232
**If you use `pipx run` then the post-generation hooks will not be available unless you install them manually.**
3333

@@ -151,8 +151,7 @@ In the config file, there's an easy way to tell `openapi-python-client` to run a
151151

152152
```yaml
153153
post_hooks:
154-
- "autoflake -i -r --remove-all-unused-imports --remove-unused-variables --ignore-init-module-imports ."
155-
- "isort ."
154+
- "ruff check . --fix"
156155
- "black ."
157156
```
158157

end_to_end_tests/golden-record/my_test_api_client/api/default/get_common_parameters.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ def _get_kwargs(
1212
*,
1313
common: Union[Unset, None, str] = UNSET,
1414
) -> Dict[str, Any]:
15-
pass
16-
1715
params: Dict[str, Any] = {}
1816
params["common"] = common
1917

end_to_end_tests/golden-record/my_test_api_client/api/default/post_common_parameters.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ def _get_kwargs(
1212
*,
1313
common: Union[Unset, None, str] = UNSET,
1414
) -> Dict[str, Any]:
15-
pass
16-
1715
params: Dict[str, Any] = {}
1816
params["common"] = common
1917

end_to_end_tests/golden-record/my_test_api_client/api/default/reserved_parameters.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ def _get_kwargs(
1313
client_query: str,
1414
url_query: str,
1515
) -> Dict[str, Any]:
16-
pass
17-
1816
params: Dict[str, Any] = {}
1917
params["client"] = client_query
2018

end_to_end_tests/golden-record/my_test_api_client/api/location/get_location_query_optionality.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ def _get_kwargs(
1616
null_not_required: Union[Unset, None, datetime.datetime] = UNSET,
1717
not_null_not_required: Union[Unset, None, datetime.datetime] = UNSET,
1818
) -> Dict[str, Any]:
19-
pass
20-
2119
params: Dict[str, Any] = {}
2220
json_not_null_required = not_null_required.isoformat()
2321

end_to_end_tests/golden-record/my_test_api_client/api/naming/post_naming_property_conflict_with_import.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ def _get_kwargs(
1616
*,
1717
json_body: PostNamingPropertyConflictWithImportJsonBody,
1818
) -> Dict[str, Any]:
19-
pass
20-
2119
json_json_body = json_body.to_dict()
2220

2321
return {

end_to_end_tests/golden-record/my_test_api_client/api/parameters/delete_common_parameters_overriding_param.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ def _get_kwargs(
1313
*,
1414
param_query: Union[Unset, None, str] = UNSET,
1515
) -> Dict[str, Any]:
16-
pass
17-
1816
params: Dict[str, Any] = {}
1917
params["param"] = param_query
2018

end_to_end_tests/golden-record/my_test_api_client/api/parameters/get_common_parameters_overriding_param.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ def _get_kwargs(
1313
*,
1414
param_query: str = "overridden_in_GET",
1515
) -> Dict[str, Any]:
16-
pass
17-
1816
params: Dict[str, Any] = {}
1917
params["param"] = param_query
2018

end_to_end_tests/golden-record/my_test_api_client/api/parameters/multiple_path_parameters.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ def _get_kwargs(
1414
param1: str,
1515
param3: int,
1616
) -> Dict[str, Any]:
17-
pass
18-
1917
return {
2018
"method": "get",
2119
"url": "/multiple-path-parameters/{param4}/something/{param2}/{param1}/{param3}".format(

end_to_end_tests/golden-record/my_test_api_client/api/responses/post_responses_unions_simple_before_complex.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212

1313

1414
def _get_kwargs() -> Dict[str, Any]:
15-
pass
16-
1715
return {
1816
"method": "post",
1917
"url": "/responses/unions/simple_before_complex",

end_to_end_tests/golden-record/my_test_api_client/api/tag1/get_tag_with_number.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99

1010

1111
def _get_kwargs() -> Dict[str, Any]:
12-
pass
13-
1412
return {
1513
"method": "get",
1614
"url": "/tag_with_number",

end_to_end_tests/golden-record/my_test_api_client/api/tests/callback_test.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ def _get_kwargs(
1414
*,
1515
json_body: AModel,
1616
) -> Dict[str, Any]:
17-
pass
18-
1917
json_json_body = json_body.to_dict()
2018

2119
return {

end_to_end_tests/golden-record/my_test_api_client/api/tests/defaults_tests_defaults_post.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ def _get_kwargs(
2727
model_prop: "ModelWithUnionProperty",
2828
required_model_prop: "ModelWithUnionProperty",
2929
) -> Dict[str, Any]:
30-
pass
31-
3230
params: Dict[str, Any] = {}
3331
params["string_prop"] = string_prop
3432

end_to_end_tests/golden-record/my_test_api_client/api/tests/description_with_backslash.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99

1010

1111
def _get_kwargs() -> Dict[str, Any]:
12-
pass
13-
1412
return {
1513
"method": "get",
1614
"url": "/tests/description-with-backslash",

end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_booleans.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99

1010

1111
def _get_kwargs() -> Dict[str, Any]:
12-
pass
13-
1412
return {
1513
"method": "get",
1614
"url": "/tests/basic_lists/booleans",

end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_floats.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99

1010

1111
def _get_kwargs() -> Dict[str, Any]:
12-
pass
13-
1412
return {
1513
"method": "get",
1614
"url": "/tests/basic_lists/floats",

end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_integers.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99

1010

1111
def _get_kwargs() -> Dict[str, Any]:
12-
pass
13-
1412
return {
1513
"method": "get",
1614
"url": "/tests/basic_lists/integers",

end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_strings.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99

1010

1111
def _get_kwargs() -> Dict[str, Any]:
12-
pass
13-
1412
return {
1513
"method": "get",
1614
"url": "/tests/basic_lists/strings",

end_to_end_tests/golden-record/my_test_api_client/api/tests/get_user_list.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ def _get_kwargs(
2020
an_enum_value_with_only_null: List[None],
2121
some_date: Union[datetime.date, datetime.datetime],
2222
) -> Dict[str, Any]:
23-
pass
24-
2523
params: Dict[str, Any] = {}
2624
json_an_enum_value = []
2725
for an_enum_value_item_data in an_enum_value:

end_to_end_tests/golden-record/my_test_api_client/api/tests/int_enum_tests_int_enum_post.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ def _get_kwargs(
1414
*,
1515
int_enum: AnIntEnum,
1616
) -> Dict[str, Any]:
17-
pass
18-
1917
params: Dict[str, Any] = {}
2018
json_int_enum = int_enum.value
2119

end_to_end_tests/golden-record/my_test_api_client/api/tests/json_body_tests_json_body_post.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ def _get_kwargs(
1414
*,
1515
json_body: AModel,
1616
) -> Dict[str, Any]:
17-
pass
18-
1917
json_json_body = json_body.to_dict()
2018

2119
return {

end_to_end_tests/golden-record/my_test_api_client/api/tests/no_response_tests_no_response_get.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99

1010

1111
def _get_kwargs() -> Dict[str, Any]:
12-
pass
13-
1412
return {
1513
"method": "get",
1614
"url": "/tests/no_response",

end_to_end_tests/golden-record/my_test_api_client/api/tests/octet_stream_tests_octet_stream_get.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010

1111

1212
def _get_kwargs() -> Dict[str, Any]:
13-
pass
14-
1513
return {
1614
"method": "get",
1715
"url": "/tests/octet_stream",

end_to_end_tests/golden-record/my_test_api_client/api/tests/post_form_data.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
def _get_kwargs(
1313
form_data: AFormData,
1414
) -> Dict[str, Any]:
15-
pass
16-
1715
return {
1816
"method": "post",
1917
"url": "/tests/post_form_data",

end_to_end_tests/golden-record/my_test_api_client/api/tests/post_form_data_inline.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
def _get_kwargs(
1313
form_data: PostFormDataInlineData,
1414
) -> Dict[str, Any]:
15-
pass
16-
1715
return {
1816
"method": "post",
1917
"url": "/tests/post_form_data_inline",

end_to_end_tests/golden-record/my_test_api_client/api/tests/post_tests_json_body_string.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ def _get_kwargs(
1313
*,
1414
json_body: str,
1515
) -> Dict[str, Any]:
16-
pass
17-
1816
json_json_body = json_body
1917

2018
return {

end_to_end_tests/golden-record/my_test_api_client/api/tests/test_inline_objects.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ def _get_kwargs(
1414
*,
1515
json_body: TestInlineObjectsJsonBody,
1616
) -> Dict[str, Any]:
17-
pass
18-
1917
json_json_body = json_body.to_dict()
2018

2119
return {

end_to_end_tests/golden-record/my_test_api_client/api/tests/unsupported_content_tests_unsupported_content_get.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99

1010

1111
def _get_kwargs() -> Dict[str, Any]:
12-
pass
13-
1412
return {
1513
"method": "get",
1614
"url": "/tests/unsupported_content",

end_to_end_tests/golden-record/my_test_api_client/api/tests/upload_file_tests_upload_post.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ def _get_kwargs(
1414
*,
1515
multipart_data: BodyUploadFileTestsUploadPost,
1616
) -> Dict[str, Any]:
17-
pass
18-
1917
multipart_multipart_data = multipart_data.to_multipart()
2018

2119
return {

end_to_end_tests/golden-record/my_test_api_client/api/tests/upload_multiple_files_tests_upload_post.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ def _get_kwargs(
1313
*,
1414
multipart_data: List[File],
1515
) -> Dict[str, Any]:
16-
pass
17-
1816
multipart_multipart_data = []
1917
for multipart_data_item_data in multipart_data:
2018
multipart_data_item = multipart_data_item_data.to_tuple()

end_to_end_tests/golden-record/my_test_api_client/api/true_/false_.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ def _get_kwargs(
1212
*,
1313
import_: str,
1414
) -> Dict[str, Any]:
15-
pass
16-
1715
params: Dict[str, Any] = {}
1816
params["import"] = import_
1917

end_to_end_tests/golden-record/my_test_api_client/models/an_array_with_a_circular_ref_in_items_object_additional_properties_a_item.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ class AnArrayWithACircularRefInItemsObjectAdditionalPropertiesAItem:
2121
] = _attrs_field(init=False, factory=dict)
2222

2323
def to_dict(self) -> Dict[str, Any]:
24-
pass
25-
2624
field_dict: Dict[str, Any] = {}
2725
for prop_name, prop in self.additional_properties.items():
2826
field_dict[prop_name] = []

end_to_end_tests/golden-record/my_test_api_client/models/an_array_with_a_circular_ref_in_items_object_additional_properties_b_item.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ class AnArrayWithACircularRefInItemsObjectAdditionalPropertiesBItem:
2121
] = _attrs_field(init=False, factory=dict)
2222

2323
def to_dict(self) -> Dict[str, Any]:
24-
pass
25-
2624
field_dict: Dict[str, Any] = {}
2725
for prop_name, prop in self.additional_properties.items():
2826
field_dict[prop_name] = []

end_to_end_tests/golden-record/my_test_api_client/models/model_with_circular_ref_in_additional_properties_a.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ class ModelWithCircularRefInAdditionalPropertiesA:
1919
)
2020

2121
def to_dict(self) -> Dict[str, Any]:
22-
pass
23-
2422
field_dict: Dict[str, Any] = {}
2523
for prop_name, prop in self.additional_properties.items():
2624
field_dict[prop_name] = prop.to_dict()

end_to_end_tests/golden-record/my_test_api_client/models/model_with_circular_ref_in_additional_properties_b.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ class ModelWithCircularRefInAdditionalPropertiesB:
1919
)
2020

2121
def to_dict(self) -> Dict[str, Any]:
22-
pass
23-
2422
field_dict: Dict[str, Any] = {}
2523
for prop_name, prop in self.additional_properties.items():
2624
field_dict[prop_name] = prop.to_dict()

0 commit comments

Comments
 (0)