Skip to content

Commit 20cfce8

Browse files
authored
Fix Ruff formatting when meta=none (#940)
Also, does a bunch of test refactoring to make future changes like this easier by: - Putting `Config` in a fixture, since most tests need it but don't care what's in it - Deleting more of the mocked tests, since they don't test much and are hard to read To get coverage back up, this means adding more functional e2e tests --------- Co-authored-by: Dylan Anthony <[email protected]>
1 parent 89dc670 commit 20cfce8

36 files changed

+515
-1023
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
default: patch
3+
---
4+
5+
# Fix Ruff formatting for `--meta=none`
6+
7+
PR #940 fixes issue #939. Thanks @satwell!
8+
9+
Due to the lack of `pyproject.toml`, Ruff was not getting configured properly when `--meta=none`.
10+
As a result, it didn't clean up common generation issues like duplicate imports, which would then cause errors from
11+
linters.
12+
13+
This is now fixed by changing the default `post_hook` to `ruff check . --fix --extend-select=I` when `--meta=none`.
14+
Using `generate --meta=none` should now be almost identical to the code generated by `update`.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
default: minor
3+
---
4+
5+
# Include the `UP` rule for generated Ruff config
6+
7+
This enables [pyupgrade-like improvements](https://docs.astral.sh/ruff/rules/#pyupgrade-up) which should replace some
8+
`.format()` calls with f-strings.

.github/check_for_changes.py

Lines changed: 0 additions & 11 deletions
This file was deleted.

.github/workflows/checks.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -149,11 +149,6 @@ jobs:
149149
pip install pdm
150150
python -m venv .venv
151151
pdm install
152-
- name: Regenerate Integration Client
153-
run: |
154-
pdm run openapi-python-client update --url http://localhost:3000/openapi.json --config integration-tests-config.yaml --meta pdm
155-
- name: Check for any file changes
156-
run: python .github/check_for_changes.py
157152
- name: Cache Generated Client Dependencies
158153
uses: actions/cache@v3
159154
with:
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
post_hooks:
2+
- echo "this should fail" && exit 1

end_to_end_tests/golden-record/my_test_api_client/api/parameter_references/get_parameter_references_path_param.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,7 @@ def _get_kwargs(
3434

3535
_kwargs: Dict[str, Any] = {
3636
"method": "get",
37-
"url": "/parameter-references/{path_param}".format(
38-
path_param=path_param,
39-
),
37+
"url": f"/parameter-references/{path_param}",
4038
"params": params,
4139
"cookies": cookies,
4240
}

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@ def _get_kwargs(
2121

2222
_kwargs: Dict[str, Any] = {
2323
"method": "delete",
24-
"url": "/common_parameters_overriding/{param}".format(
25-
param=param_path,
26-
),
24+
"url": f"/common_parameters_overriding/{param_path}",
2725
"params": params,
2826
}
2927

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@ def _get_kwargs(
2121

2222
_kwargs: Dict[str, Any] = {
2323
"method": "get",
24-
"url": "/common_parameters_overriding/{param}".format(
25-
param=param_path,
26-
),
24+
"url": f"/common_parameters_overriding/{param_path}",
2725
"params": params,
2826
}
2927

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,7 @@ def _get_kwargs(
3131

3232
_kwargs: Dict[str, Any] = {
3333
"method": "get",
34-
"url": "/same-name-multiple-locations/{param}".format(
35-
param=param_path,
36-
),
34+
"url": f"/same-name-multiple-locations/{param_path}",
3735
"params": params,
3836
"cookies": cookies,
3937
}

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

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,7 @@ def _get_kwargs(
1616
) -> Dict[str, Any]:
1717
_kwargs: Dict[str, Any] = {
1818
"method": "get",
19-
"url": "/multiple-path-parameters/{param4}/something/{param2}/{param1}/{param3}".format(
20-
param4=param4,
21-
param2=param2,
22-
param1=param1,
23-
param3=param3,
24-
),
19+
"url": f"/multiple-path-parameters/{param4}/something/{param2}/{param1}/{param3}",
2520
}
2621

2722
return _kwargs

0 commit comments

Comments
 (0)