Skip to content

Commit e85ea28

Browse files
authored
🔖 bump version 0.6.1
1 parent a1dbc6f commit e85ea28

File tree

4 files changed

+96
-58
lines changed

4 files changed

+96
-58
lines changed

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,26 @@ poetry add githubkit
4343
pdm add githubkit
4444
```
4545

46+
if you want to auth as github app, extra dependencies are required:
47+
48+
```bash
49+
pip install githubkit[auth-app]
50+
# or, use poetry
51+
poetry add githubkit[auth-app]
52+
# or, use pdm
53+
pdm add githubkit[auth-app]
54+
```
55+
56+
if you want to mix sync and async calls in oauth device callback, extra dependencies are required:
57+
58+
```bash
59+
pip install githubkit[auth-oauth-device]
60+
# or, use poetry
61+
poetry add githubkit[auth-oauth-device]
62+
# or, use pdm
63+
pdm add githubkit[auth-oauth-device]
64+
```
65+
4666
## Usage
4767

4868
### Authentication

githubkit/auth/oauth.py

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,25 @@
1616
cast,
1717
)
1818

19-
import anyio
2019
import httpx
21-
from anyio.to_thread import run_sync
22-
from anyio.from_thread import threadlocals
23-
from anyio.from_thread import run as run_async
2420

2521
from githubkit.utils import is_async
2622
from githubkit.exception import AuthExpiredError
2723

2824
from .base import BaseAuthStrategy
2925
from ._url import require_bypass, get_oauth_base_url, require_basic_auth
3026

27+
try:
28+
import anyio
29+
from anyio.to_thread import run_sync
30+
from anyio.from_thread import threadlocals
31+
from anyio.from_thread import run as run_async
32+
except ImportError:
33+
anyio = None
34+
run_sync = None
35+
run_async = None
36+
threadlocals = None
37+
3138
if TYPE_CHECKING:
3239
from githubkit import GitHubCore
3340

@@ -262,6 +269,11 @@ def _parse_response_data(self, data: Dict[str, Any]) -> str:
262269

263270
def call_handler(self, data: Dict[str, Any]) -> None:
264271
if is_async(self.on_verification):
272+
if anyio is None or threadlocals is None or run_async is None:
273+
raise RuntimeError(
274+
"AnyIO support for OAuth Device Callback should be installed "
275+
"with `pip install githubkit[auth-oauth-device]`"
276+
)
265277
handler = cast(
266278
Callable[[Dict[str, Any]], Coroutine[None, None, None]],
267279
self.on_verification,
@@ -284,6 +296,11 @@ async def acall_handler(self, data: Dict[str, Any]) -> None:
284296
)
285297
await handler(data)
286298
else:
299+
if run_sync is None:
300+
raise RuntimeError(
301+
"AnyIO support for OAuth Device Callback should be installed "
302+
"with `pip install githubkit[auth-oauth-device]`"
303+
)
287304
handler = cast(Callable[[Dict[str, Any]], None], self.on_verification)
288305
await run_sync(handler, data)
289306

poetry.lock

Lines changed: 54 additions & 53 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "GitHubKit"
3-
version = "0.6.0"
3+
version = "0.6.1"
44
description = "GitHub SDK for Python"
55
authors = ["yanyongyu <yyy@yyydl.top>"]
66
license = "MIT"

0 commit comments

Comments
 (0)