Skip to content

Commit 8adcb14

Browse files
authored
Update to Python 3.10+ syntax and openapi-python-client (#18)
* update to python 3.10 + syntax (no typing) * api updates * lock * only add UNKNOWN to enum if it doesn't already exist, revert docstring changes * nullsafe various dates * bump version * update httpx * update openapi generator * remove test file * typo * add mypy to gh action task, fix test * add lint/test task that tests support python versions * remove package task run on PR
1 parent a43009b commit 8adcb14

348 files changed

Lines changed: 8463 additions & 4748 deletions

File tree

Some content is hidden

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

.github/workflows/lint.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Lint and Test
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
11+
jobs:
12+
lint-and-test:
13+
runs-on: ubuntu-latest
14+
permissions:
15+
contents: read
16+
strategy:
17+
matrix:
18+
python-version: [ "3.10", "3.11", "3.12", "3.13", "3.14" ]
19+
20+
steps:
21+
- uses: actions/checkout@v2
22+
23+
- name: Set up Python ${{ matrix.python-version }}
24+
uses: actions/setup-python@v2
25+
with:
26+
python-version: ${{ matrix.python-version }}
27+
28+
- name: Install deps
29+
run: |
30+
python -m pip install --upgrade pip setuptools
31+
pip install poetry
32+
33+
- name: Test install
34+
run: |
35+
poetry install --all-extras
36+
37+
- name: Lint (mypy)
38+
run: |
39+
poetry run mypy cirro_api_client
40+
41+
- name: Run tests (pytest)
42+
run: |
43+
poetry run pytest
44+
45+
- name: Build python package
46+
run: |
47+
poetry build

.github/workflows/package.yml

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,6 @@ on:
44
release:
55
types:
66
- published
7-
push:
8-
branches:
9-
- main
10-
pull_request:
11-
branches:
12-
- main
137

148
jobs:
159
build-and-push-image:
@@ -20,10 +14,10 @@ jobs:
2014
steps:
2115
- uses: actions/checkout@v2
2216

23-
- name: Set up Python 3.12
17+
- name: Set up Python 3.14
2418
uses: actions/setup-python@v2
2519
with:
26-
python-version: "3.12"
20+
python-version: 3.14
2721

2822
- name: Install deps
2923
run: |
@@ -34,10 +28,6 @@ jobs:
3428
run: |
3529
poetry install --all-extras
3630
37-
- name: Pytest
38-
run: |
39-
poetry run pytest
40-
4131
- name: Build python package
4232
run: |
4333
poetry build

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ This Python package is automatically generated by the [OpenAPI Python Client](ht
77

88
## Requirements.
99

10-
Python 3.9+.
10+
Python 3.10+.
1111

1212
## Installation & Usage
1313
### pip install
@@ -115,5 +115,5 @@ client.set_httpx_client(httpx.Client(base_url="https://api.cirro.bio", proxies="
115115
Re-generate the API client by running:
116116

117117
```sh
118-
openapi-python-client update --url https://dev.cirro.bio/openapi/cirro-data-latest.yml --config config.yml --custom-template-path=templates/
118+
openapi-python-client generate --overwrite --url http://localhost:8080/openapi/cirro-data-latest.yml --config config.yml --custom-template-path=templates/
119119
```
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"""Contains endpoint functions for accessing the API"""

cirro_api_client/v1/api/audit/get_event.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from http import HTTPStatus
2-
from typing import Any, Dict, Optional
2+
from typing import Any
3+
from urllib.parse import quote
34

45
import httpx
56

@@ -11,17 +12,19 @@
1112

1213
def _get_kwargs(
1314
audit_event_id: str,
14-
) -> Dict[str, Any]:
15-
_kwargs: Dict[str, Any] = {
15+
) -> dict[str, Any]:
16+
_kwargs: dict[str, Any] = {
1617
"method": "get",
17-
"url": f"/audit-events/{audit_event_id}",
18+
"url": "/audit-events/{audit_event_id}".format(
19+
audit_event_id=quote(str(audit_event_id), safe=""),
20+
),
1821
}
1922

2023
return _kwargs
2124

2225

23-
def _parse_response(*, client: Client, response: httpx.Response) -> Optional[AuditEvent]:
24-
if response.status_code == HTTPStatus.OK:
26+
def _parse_response(*, client: Client, response: httpx.Response) -> AuditEvent | None:
27+
if response.status_code == 200:
2528
response_200 = AuditEvent.from_dict(response.json())
2629

2730
return response_200
@@ -75,7 +78,7 @@ def sync(
7578
audit_event_id: str,
7679
*,
7780
client: Client,
78-
) -> Optional[AuditEvent]:
81+
) -> AuditEvent | None:
7982
"""Get audit event
8083
8184
Get audit event detailed information
@@ -135,7 +138,7 @@ async def asyncio(
135138
audit_event_id: str,
136139
*,
137140
client: Client,
138-
) -> Optional[AuditEvent]:
141+
) -> AuditEvent | None:
139142
"""Get audit event
140143
141144
Get audit event detailed information

cirro_api_client/v1/api/audit/list_events.py

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from http import HTTPStatus
2-
from typing import Any, Dict, List, Optional, Union
2+
from typing import Any
33

44
import httpx
55

@@ -12,15 +12,15 @@
1212

1313
def _get_kwargs(
1414
*,
15-
username: Union[Unset, str] = UNSET,
16-
entity_type: Union[Unset, ListEventsEntityType] = UNSET,
17-
entity_id: Union[Unset, str] = UNSET,
18-
) -> Dict[str, Any]:
19-
params: Dict[str, Any] = {}
15+
username: str | Unset = UNSET,
16+
entity_type: ListEventsEntityType | Unset = UNSET,
17+
entity_id: str | Unset = UNSET,
18+
) -> dict[str, Any]:
19+
params: dict[str, Any] = {}
2020

2121
params["username"] = username
2222

23-
json_entity_type: Union[Unset, str] = UNSET
23+
json_entity_type: str | Unset = UNSET
2424
if not isinstance(entity_type, Unset):
2525
json_entity_type = entity_type.value
2626

@@ -30,7 +30,7 @@ def _get_kwargs(
3030

3131
params = {k: v for k, v in params.items() if v is not UNSET and v is not None}
3232

33-
_kwargs: Dict[str, Any] = {
33+
_kwargs: dict[str, Any] = {
3434
"method": "get",
3535
"url": "/audit-events",
3636
"params": params,
@@ -39,8 +39,8 @@ def _get_kwargs(
3939
return _kwargs
4040

4141

42-
def _parse_response(*, client: Client, response: httpx.Response) -> Optional[List["AuditEvent"]]:
43-
if response.status_code == HTTPStatus.OK:
42+
def _parse_response(*, client: Client, response: httpx.Response) -> list[AuditEvent] | None:
43+
if response.status_code == 200:
4444
response_200 = []
4545
_response_200 = response.json()
4646
for response_200_item_data in _response_200:
@@ -53,7 +53,7 @@ def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Lis
5353
errors.handle_error_response(response, client.raise_on_unexpected_status)
5454

5555

56-
def _build_response(*, client: Client, response: httpx.Response) -> Response[List["AuditEvent"]]:
56+
def _build_response(*, client: Client, response: httpx.Response) -> Response[list[AuditEvent]]:
5757
return Response(
5858
status_code=HTTPStatus(response.status_code),
5959
content=response.content,
@@ -65,26 +65,26 @@ def _build_response(*, client: Client, response: httpx.Response) -> Response[Lis
6565
def sync_detailed(
6666
*,
6767
client: Client,
68-
username: Union[Unset, str] = UNSET,
69-
entity_type: Union[Unset, ListEventsEntityType] = UNSET,
70-
entity_id: Union[Unset, str] = UNSET,
71-
) -> Response[List["AuditEvent"]]:
68+
username: str | Unset = UNSET,
69+
entity_type: ListEventsEntityType | Unset = UNSET,
70+
entity_id: str | Unset = UNSET,
71+
) -> Response[list[AuditEvent]]:
7272
"""List audit events
7373
7474
Gets a list of audit events
7575
7676
Args:
77-
username (Union[Unset, str]):
78-
entity_type (Union[Unset, ListEventsEntityType]):
79-
entity_id (Union[Unset, str]):
77+
username (str | Unset):
78+
entity_type (ListEventsEntityType | Unset):
79+
entity_id (str | Unset):
8080
client (Client): instance of the API client
8181
8282
Raises:
8383
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
8484
httpx.TimeoutException: If the request takes longer than Client.timeout.
8585
8686
Returns:
87-
Response[List['AuditEvent']]
87+
Response[list[AuditEvent]]
8888
"""
8989

9090
kwargs = _get_kwargs(
@@ -104,26 +104,26 @@ def sync_detailed(
104104
def sync(
105105
*,
106106
client: Client,
107-
username: Union[Unset, str] = UNSET,
108-
entity_type: Union[Unset, ListEventsEntityType] = UNSET,
109-
entity_id: Union[Unset, str] = UNSET,
110-
) -> Optional[List["AuditEvent"]]:
107+
username: str | Unset = UNSET,
108+
entity_type: ListEventsEntityType | Unset = UNSET,
109+
entity_id: str | Unset = UNSET,
110+
) -> list[AuditEvent] | None:
111111
"""List audit events
112112
113113
Gets a list of audit events
114114
115115
Args:
116-
username (Union[Unset, str]):
117-
entity_type (Union[Unset, ListEventsEntityType]):
118-
entity_id (Union[Unset, str]):
116+
username (str | Unset):
117+
entity_type (ListEventsEntityType | Unset):
118+
entity_id (str | Unset):
119119
client (Client): instance of the API client
120120
121121
Raises:
122122
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
123123
httpx.TimeoutException: If the request takes longer than Client.timeout.
124124
125125
Returns:
126-
List['AuditEvent']
126+
list[AuditEvent]
127127
"""
128128

129129
try:
@@ -140,26 +140,26 @@ def sync(
140140
async def asyncio_detailed(
141141
*,
142142
client: Client,
143-
username: Union[Unset, str] = UNSET,
144-
entity_type: Union[Unset, ListEventsEntityType] = UNSET,
145-
entity_id: Union[Unset, str] = UNSET,
146-
) -> Response[List["AuditEvent"]]:
143+
username: str | Unset = UNSET,
144+
entity_type: ListEventsEntityType | Unset = UNSET,
145+
entity_id: str | Unset = UNSET,
146+
) -> Response[list[AuditEvent]]:
147147
"""List audit events
148148
149149
Gets a list of audit events
150150
151151
Args:
152-
username (Union[Unset, str]):
153-
entity_type (Union[Unset, ListEventsEntityType]):
154-
entity_id (Union[Unset, str]):
152+
username (str | Unset):
153+
entity_type (ListEventsEntityType | Unset):
154+
entity_id (str | Unset):
155155
client (Client): instance of the API client
156156
157157
Raises:
158158
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
159159
httpx.TimeoutException: If the request takes longer than Client.timeout.
160160
161161
Returns:
162-
Response[List['AuditEvent']]
162+
Response[list[AuditEvent]]
163163
"""
164164

165165
kwargs = _get_kwargs(
@@ -176,26 +176,26 @@ async def asyncio_detailed(
176176
async def asyncio(
177177
*,
178178
client: Client,
179-
username: Union[Unset, str] = UNSET,
180-
entity_type: Union[Unset, ListEventsEntityType] = UNSET,
181-
entity_id: Union[Unset, str] = UNSET,
182-
) -> Optional[List["AuditEvent"]]:
179+
username: str | Unset = UNSET,
180+
entity_type: ListEventsEntityType | Unset = UNSET,
181+
entity_id: str | Unset = UNSET,
182+
) -> list[AuditEvent] | None:
183183
"""List audit events
184184
185185
Gets a list of audit events
186186
187187
Args:
188-
username (Union[Unset, str]):
189-
entity_type (Union[Unset, ListEventsEntityType]):
190-
entity_id (Union[Unset, str]):
188+
username (str | Unset):
189+
entity_type (ListEventsEntityType | Unset):
190+
entity_id (str | Unset):
191191
client (Client): instance of the API client
192192
193193
Raises:
194194
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
195195
httpx.TimeoutException: If the request takes longer than Client.timeout.
196196
197197
Returns:
198-
List['AuditEvent']
198+
list[AuditEvent]
199199
"""
200200

201201
try:
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"""Contains endpoint functions for accessing the API"""

0 commit comments

Comments
 (0)