Skip to content

Commit 7e66386

Browse files
authored
🐛 Fix: literal cannot use unset const (#117)
1 parent 67a54c7 commit 7e66386

File tree

1,280 files changed

+21501
-21089
lines changed

Some content is hidden

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

1,280 files changed

+21501
-21089
lines changed

codegen/templates/rest/_param.py.jinja

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ headers: Optional[Dict[str, str]] = None,
4646
{{ header_params(endpoint) }}
4747
{{ cookie_params(endpoint) }}
4848
*,
49-
data: Literal[UNSET] = UNSET,
49+
data: UnsetType = UNSET,
5050
headers: Optional[Dict[str, str]] = None,
5151
{{ body_params(model, endpoint.param_names) }}
5252
{% endmacro %}

codegen/templates/rest/client.py.jinja

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ from typing import TYPE_CHECKING, Dict, Literal, Optional, overload
1414

1515
from pydantic import BaseModel, Field
1616

17-
from githubkit.typing import Missing
17+
from githubkit.typing import Missing, UnsetType
1818
from githubkit.utils import exclude_unset, UNSET
1919
from githubkit.compat import model_dump, type_validate_python
2020

githubkit/core.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
Type,
1111
Union,
1212
Generic,
13-
Literal,
1413
TypeVar,
1514
Optional,
1615
Generator,
@@ -28,23 +27,24 @@
2827
from .compat import to_jsonable_python
2928
from .config import Config, get_config
3029
from .auth import BaseAuthStrategy, TokenAuthStrategy, UnauthAuthStrategy
30+
from .exception import (
31+
RequestError,
32+
RequestFailed,
33+
RequestTimeout,
34+
GitHubException,
35+
PrimaryRateLimitExceeded,
36+
SecondaryRateLimitExceeded,
37+
)
3138
from .typing import (
3239
URLTypes,
40+
UnsetType,
3341
CookieTypes,
3442
HeaderTypes,
3543
ContentTypes,
3644
RequestFiles,
3745
QueryParamTypes,
3846
RetryDecisionFunc,
3947
)
40-
from .exception import (
41-
RequestError,
42-
RequestFailed,
43-
RequestTimeout,
44-
GitHubException,
45-
PrimaryRateLimitExceeded,
46-
SecondaryRateLimitExceeded,
47-
)
4848

4949
T = TypeVar("T")
5050
A = TypeVar("A", bound="BaseAuthStrategy")
@@ -332,14 +332,14 @@ def _check(
332332
def _check(
333333
self,
334334
response: httpx.Response,
335-
response_model: Literal[UNSET] = UNSET,
335+
response_model: UnsetType = UNSET,
336336
error_models: Optional[Dict[str, type]] = None,
337337
) -> Response[Any]: ...
338338

339339
def _check(
340340
self,
341341
response: httpx.Response,
342-
response_model: Union[Type[T], Literal[UNSET]] = UNSET,
342+
response_model: Union[Type[T], UnsetType] = UNSET,
343343
error_models: Optional[Dict[str, type]] = None,
344344
) -> Union[Response[T], Response[Any]]:
345345
if response.is_error:
@@ -446,7 +446,7 @@ def request(
446446
json: Optional[Any] = None,
447447
headers: Optional[HeaderTypes] = None,
448448
cookies: Optional[CookieTypes] = None,
449-
response_model: Literal[UNSET] = UNSET,
449+
response_model: UnsetType = UNSET,
450450
error_models: Optional[Dict[str, type]] = None,
451451
) -> Response[Any]: ...
452452

@@ -462,7 +462,7 @@ def request(
462462
json: Optional[Any] = None,
463463
headers: Optional[HeaderTypes] = None,
464464
cookies: Optional[CookieTypes] = None,
465-
response_model: Union[Type[T], Literal[UNSET]] = UNSET,
465+
response_model: Union[Type[T], UnsetType] = UNSET,
466466
error_models: Optional[Dict[str, type]] = None,
467467
) -> Union[Response[T], Response[Any]]:
468468
retry_count: int = 0
@@ -523,7 +523,7 @@ async def arequest(
523523
json: Optional[Any] = None,
524524
headers: Optional[HeaderTypes] = None,
525525
cookies: Optional[CookieTypes] = None,
526-
response_model: Literal[UNSET] = UNSET,
526+
response_model: UnsetType = UNSET,
527527
error_models: Optional[Dict[str, type]] = None,
528528
) -> Response[Any]: ...
529529

@@ -539,7 +539,7 @@ async def arequest(
539539
json: Optional[Any] = None,
540540
headers: Optional[HeaderTypes] = None,
541541
cookies: Optional[CookieTypes] = None,
542-
response_model: Union[Type[T], Literal[UNSET]] = UNSET,
542+
response_model: Union[Type[T], UnsetType] = UNSET,
543543
error_models: Optional[Dict[str, type]] = None,
544544
) -> Union[Response[T], Response[Any]]:
545545
retry_count: int = 0

githubkit/rest/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4586,6 +4586,9 @@
45864586
from githubkit.versions.v2022_11_28.models import (
45874587
OrgsOrgActionsRunnersRunnerIdLabelsGetResponse200 as OrgsOrgActionsRunnersRunnerIdLabelsGetResponse200,
45884588
)
4589+
from githubkit.versions.v2022_11_28.models import (
4590+
OrgsOrgCodeSecurityConfigurationsDetachDeleteBody as OrgsOrgCodeSecurityConfigurationsDetachDeleteBody,
4591+
)
45894592
from githubkit.versions.v2022_11_28.models import (
45904593
OrgsOrgCopilotBillingSelectedTeamsPostResponse201 as OrgsOrgCopilotBillingSelectedTeamsPostResponse201,
45914594
)
@@ -12218,6 +12221,7 @@
1221812221
"OrgsOrgAttestationsSubjectDigestGetResponse200PropAttestationsItemsPropBundlePropVerificationMaterial",
1221912222
"OrgsOrgAttestationsSubjectDigestGetResponse200PropAttestationsItemsPropBundlePropDsseEnvelope",
1222012223
"OrgsOrgCodeSecurityConfigurationsPostBody",
12224+
"OrgsOrgCodeSecurityConfigurationsDetachDeleteBody",
1222112225
"OrgsOrgCodeSecurityConfigurationsConfigurationIdPatchBody",
1222212226
"OrgsOrgCodeSecurityConfigurationsConfigurationIdAttachPostBody",
1222312227
"OrgsOrgCodeSecurityConfigurationsConfigurationIdDefaultsPutBody",

githubkit/typing.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import httpx
1818
from pydantic import Field
1919

20-
from .utils import UNSET
20+
from .utils import Unset
2121
from .compat import PYDANTIC_V2
2222
from .exception import GitHubException
2323

@@ -76,9 +76,11 @@ def _validate_unique_list(value: List[H]) -> List[H]:
7676
else: # pragma: pydantic-v1
7777
UniqueList: TypeAlias = Annotated[List[H], Field(unique_items=True)] # type: ignore
7878

79+
UnsetType: TypeAlias = Literal[Unset._UNSET]
80+
7981
# if the property is not required, we allow it to have the value null.
8082
# See https://github.com/yanyongyu/githubkit/issues/47
81-
Missing: TypeAlias = Union[Literal[UNSET], T, None]
83+
Missing: TypeAlias = Union[UnsetType, T, None]
8284

8385

8486
class RetryOption(NamedTuple):

0 commit comments

Comments
 (0)