Skip to content

Commit

Permalink
some workarounds for using ... as sentinel until python/typing#689 is…
Browse files Browse the repository at this point in the history
… fixed
  • Loading branch information
guillp committed Mar 11, 2024
1 parent 22e8685 commit 01fdfbd
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions requests_oauth2client/authorization_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import secrets
from datetime import datetime
from enum import Enum
from types import EllipsisType
from typing import Any, Callable, ClassVar, Iterable, Sequence

from attrs import Factory, asdict, field, fields, frozen
Expand Down Expand Up @@ -312,11 +311,15 @@ def __init__( # noqa: PLR0913, C901
)
raise ValueError(msg)

if isinstance(state, EllipsisType):
if state is ...:
state = self.generate_state()
if state is not None and not isinstance(state, str):
state = str(state)

Check warning on line 317 in requests_oauth2client/authorization_request.py

View check run for this annotation

Codecov / codecov/patch

requests_oauth2client/authorization_request.py#L317

Added line #L317 was not covered by tests

if isinstance(nonce, EllipsisType):
if nonce is ...:
nonce = self.generate_nonce() if scope is not None and "openid" in scope else None
if nonce is not None and not isinstance(nonce, str):
nonce = str(nonce)

Check warning on line 322 in requests_oauth2client/authorization_request.py

View check run for this annotation

Codecov / codecov/patch

requests_oauth2client/authorization_request.py#L322

Added line #L322 was not covered by tests

if not scope:
scope = None
Expand Down

0 comments on commit 01fdfbd

Please sign in to comment.