Skip to content

Commit 199c1b6

Browse files
committed
Update the pdm to uv and ty
1 parent a076426 commit 199c1b6

File tree

10 files changed

+1273
-593
lines changed

10 files changed

+1273
-593
lines changed

.github/workflows/ci.yml

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: CI
1+
name: ci
22

33
on:
44
push:
@@ -12,25 +12,23 @@ jobs:
1212
name: lint ${{ matrix.python-version }}
1313
strategy:
1414
matrix:
15-
python-version: [ '3.10', '3.11', '3.12' ]
15+
python-version: [ '3.10', '3.11', '3.12', '3.13', '3.14' ]
1616
fail-fast: false
1717
steps:
1818
- uses: actions/checkout@v4
1919

20-
- name: Setup PDM
21-
uses: pdm-project/setup-pdm@v4
22-
with:
23-
python-version: ${{ matrix.python-version }}
20+
- name: Install uv
21+
uses: astral-sh/setup-uv@v3
22+
23+
- name: Set up Python ${{ matrix.python-version }}
24+
run: uv python install ${{ matrix.python-version }}
2425

2526
- name: Install dependencies
2627
run: |
27-
pdm sync -dG lint
28-
29-
# - name: Run Tests
30-
# run: |
31-
# pdm run -v pytest tests
28+
uv sync --group lint
3229
33-
- name: pre-commit
34-
uses: pre-commit/[email protected]
35-
with:
36-
extra_args: --all-files --verbose
30+
- name: Run lint
31+
run: |
32+
source .venv/bin/activate
33+
chmod 755 pre-commit.sh
34+
./pre-commit.sh

.github/workflows/test.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: ci
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
name: test ${{ matrix.python-version }}
13+
strategy:
14+
matrix:
15+
python-version: [ '3.10', '3.11', '3.12', '3.13', '3.14' ]
16+
fail-fast: false
17+
steps:
18+
- uses: actions/checkout@v4
19+
20+
- name: Install uv
21+
uses: astral-sh/setup-uv@v3
22+
23+
- name: Set up Python ${{ matrix.python-version }}
24+
run: uv python install ${{ matrix.python-version }}
25+
26+
- name: Install dependencies
27+
run: |
28+
uv sync
29+
30+
- name: Run test
31+
run: uv run pytest

.pre-commit-config.yaml

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,28 @@ repos:
66
- id: check-toml
77

88
- repo: https://github.com/charliermarsh/ruff-pre-commit
9-
rev: v0.11.4
9+
rev: v0.14.0
1010
hooks:
1111
- id: ruff
1212
args:
1313
- '--fix'
1414
- '--unsafe-fixes'
1515
- id: ruff-format
1616

17-
- repo: https://github.com/pdm-project/pdm
18-
rev: 2.23.0
17+
- repo: https://github.com/astral-sh/uv-pre-commit
18+
rev: 0.9.0
1919
hooks:
20-
- id: pdm-lock-check
20+
- id: uv-lock
21+
- id: uv-export
22+
args:
23+
- '-o'
24+
- 'requirements.txt'
25+
- '--no-hashes'
26+
27+
- repo: local
28+
hooks:
29+
- id: ty
30+
language: python
31+
name: ty
32+
pass_filenames: false
33+
entry: uv run ty check fastapi_oauth20

fastapi_oauth20/integrations/fastapi.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ async def __call__(
5353
state: str | None = None,
5454
code_verifier: str | None = None,
5555
error: str | None = None,
56-
) -> tuple[dict, str]:
56+
) -> tuple[dict[str, Any], str | None]:
5757
if code is None or error is not None:
5858
raise OAuth20AuthorizeCallbackError(
5959
status_code=400,

fastapi_oauth20/oauth20.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import abc
44
import json
55

6-
from typing import Literal, cast
6+
from typing import Any, Literal, cast
77
from urllib.parse import urlencode
88

99
import httpx
@@ -102,7 +102,7 @@ async def get_authorization_url(
102102

103103
return f'{self.authorize_endpoint}?{urlencode(params)}'
104104

105-
async def get_access_token(self, code: str, redirect_uri: str, code_verifier: str | None = None) -> dict:
105+
async def get_access_token(self, code: str, redirect_uri: str, code_verifier: str | None = None) -> dict[str, Any]:
106106
"""
107107
Get access token for given.
108108
@@ -136,7 +136,7 @@ async def get_access_token(self, code: str, redirect_uri: str, code_verifier: st
136136
result = self.get_json_result(response, err_class=AccessTokenError)
137137
return result
138138

139-
async def refresh_token(self, refresh_token: str) -> dict:
139+
async def refresh_token(self, refresh_token: str) -> dict[str, Any]:
140140
"""
141141
Get new access token by refresh token.
142142
@@ -202,15 +202,15 @@ def raise_httpx_oauth20_errors(response: httpx.Response) -> None:
202202
raise HTTPXOAuth20Error(str(e)) from e
203203

204204
@staticmethod
205-
def get_json_result(response: httpx.Response, *, err_class: type[OAuth20RequestError]) -> dict:
205+
def get_json_result(response: httpx.Response, *, err_class: type[OAuth20RequestError]) -> dict[str, Any]:
206206
"""Get response json"""
207207
try:
208-
return cast(dict, response.json())
209-
except json.decoder.JSONDecodeError as e:
208+
return cast(dict[str, Any], response.json())
209+
except json.JSONDecodeError as e:
210210
raise err_class('Result serialization failed.', response) from e
211211

212212
@abc.abstractmethod
213-
async def get_userinfo(self, access_token: str) -> dict:
213+
async def get_userinfo(self, access_token: str) -> dict[str, Any]:
214214
"""
215215
Get user info from the API provider
216216

0 commit comments

Comments
 (0)