diff --git a/CHANGELOG.rst b/CHANGELOG.rst
index ba22cd4b..3a22594d 100644
--- a/CHANGELOG.rst
+++ b/CHANGELOG.rst
@@ -10,6 +10,8 @@ This project adheres to `Semantic Versioning `__.
Changed
~~~~~~~
+- Use ``Sequence`` for parameter types rather than ``List`` where applicable by @imnotjames in `#970 `__
+
Fixed
~~~~~
diff --git a/jwt/api_jws.py b/jwt/api_jws.py
index 5822ebf6..20515433 100644
--- a/jwt/api_jws.py
+++ b/jwt/api_jws.py
@@ -3,6 +3,7 @@
import binascii
import json
import warnings
+from collections.abc import Sequence
from typing import TYPE_CHECKING, Any
from .algorithms import (
@@ -30,7 +31,7 @@ class PyJWS:
def __init__(
self,
- algorithms: list[str] | None = None,
+ algorithms: Sequence[str] | None = None,
options: dict[str, Any] | None = None,
) -> None:
self._algorithms = get_default_algorithms()
@@ -174,7 +175,7 @@ def decode_complete(
self,
jwt: str | bytes,
key: AllowedPublicKeys | PyJWK | str | bytes = "",
- algorithms: list[str] | None = None,
+ algorithms: Sequence[str] | None = None,
options: dict[str, Any] | None = None,
detached_payload: bytes | None = None,
**kwargs,
@@ -219,7 +220,7 @@ def decode(
self,
jwt: str | bytes,
key: AllowedPublicKeys | PyJWK | str | bytes = "",
- algorithms: list[str] | None = None,
+ algorithms: Sequence[str] | None = None,
options: dict[str, Any] | None = None,
detached_payload: bytes | None = None,
**kwargs,
@@ -291,7 +292,7 @@ def _verify_signature(
header: dict[str, Any],
signature: bytes,
key: AllowedPublicKeys | PyJWK | str | bytes = "",
- algorithms: list[str] | None = None,
+ algorithms: Sequence[str] | None = None,
) -> None:
if algorithms is None and isinstance(key, PyJWK):
algorithms = [key.algorithm_name]
diff --git a/jwt/api_jwt.py b/jwt/api_jwt.py
index 7a07c336..e162623c 100644
--- a/jwt/api_jwt.py
+++ b/jwt/api_jwt.py
@@ -3,9 +3,9 @@
import json
import warnings
from calendar import timegm
-from collections.abc import Iterable
+from collections.abc import Iterable, Sequence
from datetime import datetime, timedelta, timezone
-from typing import TYPE_CHECKING, Any, List
+from typing import TYPE_CHECKING, Any
from . import api_jws
from .exceptions import (
@@ -102,7 +102,7 @@ def decode_complete(
self,
jwt: str | bytes,
key: AllowedPublicKeys | PyJWK | str | bytes = "",
- algorithms: list[str] | None = None,
+ algorithms: Sequence[str] | None = None,
options: dict[str, Any] | None = None,
# deprecated arg, remove in pyjwt3
verify: bool | None = None,
@@ -111,7 +111,7 @@ def decode_complete(
# passthrough arguments to _validate_claims
# consider putting in options
audience: str | Iterable[str] | None = None,
- issuer: str | List[str] | None = None,
+ issuer: str | Sequence[str] | None = None,
leeway: float | timedelta = 0,
# kwargs
**kwargs: Any,
@@ -187,7 +187,7 @@ def decode(
self,
jwt: str | bytes,
key: AllowedPublicKeys | PyJWK | str | bytes = "",
- algorithms: list[str] | None = None,
+ algorithms: Sequence[str] | None = None,
options: dict[str, Any] | None = None,
# deprecated arg, remove in pyjwt3
verify: bool | None = None,
@@ -196,7 +196,7 @@ def decode(
# passthrough arguments to _validate_claims
# consider putting in options
audience: str | Iterable[str] | None = None,
- issuer: str | List[str] | None = None,
+ issuer: str | Sequence[str] | None = None,
leeway: float | timedelta = 0,
# kwargs
**kwargs: Any,
@@ -363,7 +363,7 @@ def _validate_iss(self, payload: dict[str, Any], issuer: Any) -> None:
if "iss" not in payload:
raise MissingRequiredClaimError("iss")
- if isinstance(issuer, list):
+ if isinstance(issuer, Sequence):
if payload["iss"] not in issuer:
raise InvalidIssuerError("Invalid issuer")
else: