Skip to content

Commit 6c7d0a4

Browse files
committed
Fix UP035
1 parent d84873d commit 6c7d0a4

File tree

9 files changed

+37
-29
lines changed

9 files changed

+37
-29
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ select = [
7474
# isort
7575
"I",
7676
]
77-
ignore = ["E501", "I001", "SIM102", "UP006", "UP035"]
77+
ignore = ["E501", "I001", "SIM102", "UP006"]
7878
exclude = ["examples/*"]
7979

8080
[tool.ruff.lint.isort]

src/cryptojwt/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""JSON Web Token"""
22

33
import logging
4-
from importlib.metadata import version, PackageNotFoundError
4+
from importlib.metadata import PackageNotFoundError, version
55

66
from cryptojwt.jwe.jwe import JWE
77
from cryptojwt.jwk import JWK

src/cryptojwt/jwk/__init__.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import hashlib
33
import json
44
import ssl
5-
from typing import List
65

76
from ..exception import UnsupportedAlgorithm
87
from ..utils import as_bytes, as_unicode, b64e, base64url_to_long
@@ -21,12 +20,21 @@ class JWK:
2120
"""
2221

2322
members = ["kty", "alg", "use", "kid", "x5c", "x5t", "x5u", "key_ops"]
24-
longs: List[str] = []
23+
longs: list[str] = []
2524
public_members = ["kty", "alg", "use", "kid", "x5c", "x5t", "x5u", "key_ops"]
2625
required = ["kty"]
2726

2827
def __init__(
29-
self, kty="", alg="", use="", kid="", x5c=None, x5t="", x5u="", key_ops=None, **kwargs
28+
self,
29+
kty="",
30+
alg="",
31+
use="",
32+
kid="",
33+
x5c=None,
34+
x5t="",
35+
x5u="",
36+
key_ops=None,
37+
**kwargs,
3038
):
3139
self.extra_args = kwargs
3240

@@ -121,7 +129,7 @@ def __init__(
121129
self.kid = as_unicode(kid)
122130

123131
if key_ops:
124-
self.key_ops: List[str] = []
132+
self.key_ops: list[str] = []
125133
for ops in key_ops:
126134
if isinstance(ops, str):
127135
self.key_ops.append(ops)

src/cryptojwt/jwt.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
import logging
66
import time
77
import uuid
8+
from collections.abc import MutableMapping
89
from json import JSONDecodeError
9-
from typing import Dict, List, MutableMapping, Optional
10+
from typing import Optional
1011

1112
from .exception import HeaderError, VerificationError
1213
from .jwe.jwe import JWE, factory as jwe_factory
@@ -84,14 +85,14 @@ def __init__(
8485
enc_enc: str = "A128GCM",
8586
enc_alg: str = "RSA-OAEP-256",
8687
msg_cls: Optional[MutableMapping] = None,
87-
iss2msg_cls: Optional[Dict[str, str]] = None,
88+
iss2msg_cls: Optional[dict[str, str]] = None,
8889
skew: Optional[int] = 15,
89-
allowed_sign_algs: Optional[List[str]] = None,
90-
allowed_enc_algs: Optional[List[str]] = None,
91-
allowed_enc_encs: Optional[List[str]] = None,
90+
allowed_sign_algs: Optional[list[str]] = None,
91+
allowed_enc_algs: Optional[list[str]] = None,
92+
allowed_enc_encs: Optional[list[str]] = None,
9293
allowed_max_lifetime: Optional[int] = None,
9394
zip: Optional[str] = "",
94-
typ2msg_cls: Optional[Dict] = None,
95+
typ2msg_cls: Optional[dict] = None,
9596
):
9697
self.key_jar = key_jar # KeyJar instance
9798
self.iss = iss # My identifier
@@ -214,7 +215,7 @@ def pack(
214215
recv: Optional[str] = "",
215216
aud: Optional[str] = None,
216217
iat: Optional[int] = None,
217-
jws_headers: Optional[Dict[str, str]] = None,
218+
jws_headers: Optional[dict[str, str]] = None,
218219
**kwargs,
219220
) -> str:
220221
"""

src/cryptojwt/key_bundle.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import time
1010
from datetime import datetime
1111
from functools import cmp_to_key
12-
from typing import List, Optional
12+
from typing import Optional
1313

1414
import requests
1515

@@ -808,7 +808,7 @@ def difference(self, bundle):
808808

809809
return [k for k in self.keys() if k not in bundle]
810810

811-
def dump(self, exclude_attributes: Optional[List[str]] = None):
811+
def dump(self, exclude_attributes: Optional[list[str]] = None):
812812
if exclude_attributes is None:
813813
exclude_attributes = []
814814

src/cryptojwt/key_issuer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import json
22
import logging
33
import os
4-
from typing import List, Optional
4+
from typing import Optional
55

66
from requests import request
77

@@ -345,7 +345,7 @@ def __len__(self):
345345
nr += len(kb)
346346
return nr
347347

348-
def dump(self, exclude_attributes: Optional[List[str]] = None) -> dict:
348+
def dump(self, exclude_attributes: Optional[list[str]] = None) -> dict:
349349
"""
350350
Returns the content as a dictionary.
351351

src/cryptojwt/key_jar.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import contextlib
22
import json
33
import logging
4-
from typing import List, Optional
4+
from typing import Optional
55

66
from requests import request
77

@@ -55,7 +55,7 @@ def __init__(
5555
if not self.httpc_params: # backward compatibility
5656
self.httpc_params["verify"] = verify_ssl
5757

58-
def _issuer_ids(self) -> List[str]:
58+
def _issuer_ids(self) -> list[str]:
5959
"""
6060
Returns a list of issuer identifiers
6161
@@ -159,7 +159,7 @@ def add_kb(self, issuer_id, kb):
159159
issuer.add_kb(kb)
160160
self._issuers[issuer_id] = issuer
161161

162-
def add_keys(self, issuer_id: str, keys: List[JWK], **kwargs):
162+
def add_keys(self, issuer_id: str, keys: list[JWK], **kwargs):
163163
_kb = KeyBundle(**kwargs)
164164
_kb.extend(keys)
165165
self.add_kb(issuer_id, _kb)
@@ -623,8 +623,8 @@ def __len__(self):
623623

624624
def _dump_issuers(
625625
self,
626-
exclude_issuers: Optional[List[str]] = None,
627-
exclude_attributes: Optional[List[str]] = None,
626+
exclude_issuers: Optional[list[str]] = None,
627+
exclude_attributes: Optional[list[str]] = None,
628628
):
629629
_issuers = {}
630630
for _id, _issuer in self._issuers.items():
@@ -635,8 +635,8 @@ def _dump_issuers(
635635

636636
def dump(
637637
self,
638-
exclude_issuers: Optional[List[str]] = None,
639-
exclude_attributes: Optional[List[str]] = None,
638+
exclude_issuers: Optional[list[str]] = None,
639+
exclude_attributes: Optional[list[str]] = None,
640640
) -> dict:
641641
"""
642642
Returns the key jar content as dictionary
@@ -667,7 +667,7 @@ def dump(
667667

668668
return info
669669

670-
def dumps(self, exclude_issuers: Optional[List[str]] = None):
670+
def dumps(self, exclude_issuers: Optional[list[str]] = None):
671671
"""
672672
Returns a JSON representation of the key jar
673673

src/cryptojwt/utils.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import warnings
99
from binascii import unhexlify
1010
from email.message import EmailMessage
11-
from typing import List, Set, Union
1211

1312
from cryptojwt.exception import BadSyntax
1413

@@ -32,7 +31,7 @@ def intarr2str(arr):
3231

3332

3433
def long2intarr(long_int):
35-
_bytes: List[int] = []
34+
_bytes: list[int] = []
3635
while long_int:
3736
long_int, r = divmod(long_int, 256)
3837
_bytes.insert(0, r)
@@ -262,7 +261,7 @@ def httpc_params_loader(httpc_params):
262261
return httpc_params
263262

264263

265-
def check_content_type(content_type: str, mime_type: Union[str, List[str], Set[str]]):
264+
def check_content_type(content_type: str, mime_type: str | list[str] | set[str]):
266265
"""Return True if the content type contains the MIME type"""
267266
msg = EmailMessage()
268267
msg["content-type"] = content_type

tests/test_21_pss.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import json
22

33
import pytest
4+
import test_vector
45

56
from cryptojwt.jwk.jwk import key_from_jwk_dict
67
from cryptojwt.jws.jws import JWS
7-
import test_vector
88

99

1010
@pytest.mark.parametrize("alg", ["RS256", "RS384", "RS512", "PS256", "PS384", "PS512"])

0 commit comments

Comments
 (0)