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

0 commit comments

Comments
 (0)