Skip to content

Switch to Ruff & Test Python 3.12 #870

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

Merged
merged 6 commits into from
Oct 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
default: patch
---

#### Remove useless `pass` statements from generated code
7 changes: 7 additions & 0 deletions .changeset/use_ruff_instead_of_isort_autoflake_at_runtime.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
default: major
---

#### Use Ruff instead of isort + autoflake at runtime

`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.
5 changes: 3 additions & 2 deletions .github/check_for_changes.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import subprocess
import sys

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

if output == b"":
# No changes
exit(0)
sys.exit(0)

print(output)
exit(1)
sys.exit(1)
11 changes: 4 additions & 7 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
test:
strategy:
matrix:
python: [ "3.8", "3.9", "3.10", "3.11" ]
python: [ "3.8", "3.9", "3.10", "3.11", "3.12" ]
os: [ ubuntu-latest, macos-latest, windows-latest ]
runs-on: ${{ matrix.os }}
steps:
Expand Down Expand Up @@ -48,17 +48,14 @@ jobs:
- name: Run Black
run: poetry run black . --check

- name: Run isort
run: poetry run isort . --check

- name: Run safety
run: poetry export -f requirements.txt | poetry run safety check --bare --stdin

- name: Run mypy
run: poetry run mypy --show-error-codes openapi_python_client

- name: Run pylint
run: poetry run pylint openapi_python_client
- name: Run Ruff
run: poetry run ruff check .

- name: Run pytest
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
Expand Down Expand Up @@ -106,7 +103,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
python-version: "3.8"
- name: Get Python Version
id: get_python_version
run: echo "python_version=$(python --version)" >> $GITHUB_OUTPUT
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-dry-run.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ jobs:
uses: knope-dev/action@v2.0.0
with:
version: 0.12.0
- run: knope release --dry-run
- run: knope prepare-release --dry-run
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ This tool focuses on creating the best developer experience for Python developer

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`.

> 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.
> 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.

**If you use `pipx run` then the post-generation hooks will not be available unless you install them manually.**

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

```yaml
post_hooks:
- "autoflake -i -r --remove-all-unused-imports --remove-unused-variables --ignore-init-module-imports ."
- "isort ."
- "ruff check . --fix"
- "black ."
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ def _get_kwargs(
*,
common: Union[Unset, None, str] = UNSET,
) -> Dict[str, Any]:
pass

params: Dict[str, Any] = {}
params["common"] = common

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ def _get_kwargs(
*,
common: Union[Unset, None, str] = UNSET,
) -> Dict[str, Any]:
pass

params: Dict[str, Any] = {}
params["common"] = common

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ def _get_kwargs(
client_query: str,
url_query: str,
) -> Dict[str, Any]:
pass

params: Dict[str, Any] = {}
params["client"] = client_query

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ def _get_kwargs(
null_not_required: Union[Unset, None, datetime.datetime] = UNSET,
not_null_not_required: Union[Unset, None, datetime.datetime] = UNSET,
) -> Dict[str, Any]:
pass

params: Dict[str, Any] = {}
json_not_null_required = not_null_required.isoformat()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ def _get_kwargs(
*,
json_body: PostNamingPropertyConflictWithImportJsonBody,
) -> Dict[str, Any]:
pass

json_json_body = json_body.to_dict()

return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ def _get_kwargs(
*,
param_query: Union[Unset, None, str] = UNSET,
) -> Dict[str, Any]:
pass

params: Dict[str, Any] = {}
params["param"] = param_query

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ def _get_kwargs(
*,
param_query: str = "overridden_in_GET",
) -> Dict[str, Any]:
pass

params: Dict[str, Any] = {}
params["param"] = param_query

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ def _get_kwargs(
param1: str,
param3: int,
) -> Dict[str, Any]:
pass

return {
"method": "get",
"url": "/multiple-path-parameters/{param4}/something/{param2}/{param1}/{param3}".format(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@


def _get_kwargs() -> Dict[str, Any]:
pass

return {
"method": "post",
"url": "/responses/unions/simple_before_complex",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@


def _get_kwargs() -> Dict[str, Any]:
pass

return {
"method": "get",
"url": "/tag_with_number",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ def _get_kwargs(
*,
json_body: AModel,
) -> Dict[str, Any]:
pass

json_json_body = json_body.to_dict()

return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ def _get_kwargs(
model_prop: "ModelWithUnionProperty",
required_model_prop: "ModelWithUnionProperty",
) -> Dict[str, Any]:
pass

params: Dict[str, Any] = {}
params["string_prop"] = string_prop

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@


def _get_kwargs() -> Dict[str, Any]:
pass

return {
"method": "get",
"url": "/tests/description-with-backslash",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@


def _get_kwargs() -> Dict[str, Any]:
pass

return {
"method": "get",
"url": "/tests/basic_lists/booleans",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@


def _get_kwargs() -> Dict[str, Any]:
pass

return {
"method": "get",
"url": "/tests/basic_lists/floats",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@


def _get_kwargs() -> Dict[str, Any]:
pass

return {
"method": "get",
"url": "/tests/basic_lists/integers",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@


def _get_kwargs() -> Dict[str, Any]:
pass

return {
"method": "get",
"url": "/tests/basic_lists/strings",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ def _get_kwargs(
an_enum_value_with_only_null: List[None],
some_date: Union[datetime.date, datetime.datetime],
) -> Dict[str, Any]:
pass

params: Dict[str, Any] = {}
json_an_enum_value = []
for an_enum_value_item_data in an_enum_value:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ def _get_kwargs(
*,
int_enum: AnIntEnum,
) -> Dict[str, Any]:
pass

params: Dict[str, Any] = {}
json_int_enum = int_enum.value

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ def _get_kwargs(
*,
json_body: AModel,
) -> Dict[str, Any]:
pass

json_json_body = json_body.to_dict()

return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@


def _get_kwargs() -> Dict[str, Any]:
pass

return {
"method": "get",
"url": "/tests/no_response",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@


def _get_kwargs() -> Dict[str, Any]:
pass

return {
"method": "get",
"url": "/tests/octet_stream",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
def _get_kwargs(
form_data: AFormData,
) -> Dict[str, Any]:
pass

return {
"method": "post",
"url": "/tests/post_form_data",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
def _get_kwargs(
form_data: PostFormDataInlineData,
) -> Dict[str, Any]:
pass

return {
"method": "post",
"url": "/tests/post_form_data_inline",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ def _get_kwargs(
*,
json_body: str,
) -> Dict[str, Any]:
pass

json_json_body = json_body

return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ def _get_kwargs(
*,
json_body: TestInlineObjectsJsonBody,
) -> Dict[str, Any]:
pass

json_json_body = json_body.to_dict()

return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@


def _get_kwargs() -> Dict[str, Any]:
pass

return {
"method": "get",
"url": "/tests/unsupported_content",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ def _get_kwargs(
*,
multipart_data: BodyUploadFileTestsUploadPost,
) -> Dict[str, Any]:
pass

multipart_multipart_data = multipart_data.to_multipart()

return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ def _get_kwargs(
*,
multipart_data: List[File],
) -> Dict[str, Any]:
pass

multipart_multipart_data = []
for multipart_data_item_data in multipart_data:
multipart_data_item = multipart_data_item_data.to_tuple()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ def _get_kwargs(
*,
import_: str,
) -> Dict[str, Any]:
pass

params: Dict[str, Any] = {}
params["import"] = import_

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ class AnArrayWithACircularRefInItemsObjectAdditionalPropertiesAItem:
] = _attrs_field(init=False, factory=dict)

def to_dict(self) -> Dict[str, Any]:
pass

field_dict: Dict[str, Any] = {}
for prop_name, prop in self.additional_properties.items():
field_dict[prop_name] = []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ class AnArrayWithACircularRefInItemsObjectAdditionalPropertiesBItem:
] = _attrs_field(init=False, factory=dict)

def to_dict(self) -> Dict[str, Any]:
pass

field_dict: Dict[str, Any] = {}
for prop_name, prop in self.additional_properties.items():
field_dict[prop_name] = []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ class ModelWithCircularRefInAdditionalPropertiesA:
)

def to_dict(self) -> Dict[str, Any]:
pass

field_dict: Dict[str, Any] = {}
for prop_name, prop in self.additional_properties.items():
field_dict[prop_name] = prop.to_dict()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ class ModelWithCircularRefInAdditionalPropertiesB:
)

def to_dict(self) -> Dict[str, Any]:
pass

field_dict: Dict[str, Any] = {}
for prop_name, prop in self.additional_properties.items():
field_dict[prop_name] = prop.to_dict()
Expand Down
Loading