diff --git a/jwt/help.py b/jwt/help.py index 767c323f1..c56a57bde 100644 --- a/jwt/help.py +++ b/jwt/help.py @@ -1,14 +1,14 @@ import json import platform import sys -from typing import Dict +from typing import Any, Dict, cast from . import __version__ as pyjwt_version try: import cryptography except ModuleNotFoundError: - cryptography = None # type: ignore + cryptography = cast(Any, None) def info() -> Dict[str, Dict[str, str]]: @@ -29,14 +29,15 @@ def info() -> Dict[str, Dict[str, str]]: if implementation == "CPython": implementation_version = platform.python_version() elif implementation == "PyPy": + pypy_version_info = getattr(sys, "pypy_version_info") implementation_version = ( - f"{sys.pypy_version_info.major}." # type: ignore[attr-defined] - f"{sys.pypy_version_info.minor}." - f"{sys.pypy_version_info.micro}" + f"{pypy_version_info.major}." + f"{pypy_version_info.minor}." + f"{pypy_version_info.micro}" ) - if sys.pypy_version_info.releaselevel != "final": # type: ignore[attr-defined] + if pypy_version_info.releaselevel != "final": implementation_version = "".join( - [implementation_version, sys.pypy_version_info.releaselevel] # type: ignore[attr-defined] + [implementation_version, pypy_version_info.releaselevel] ) else: implementation_version = "Unknown" diff --git a/jwt/utils.py b/jwt/utils.py index b8ad5fa50..a7b2234bb 100644 --- a/jwt/utils.py +++ b/jwt/utils.py @@ -1,7 +1,7 @@ import base64 import binascii import re -from typing import Any, Union +from typing import Any, Union, cast try: from cryptography.hazmat.primitives.asymmetric.ec import EllipticCurve @@ -10,7 +10,7 @@ encode_dss_signature, ) except ModuleNotFoundError: - EllipticCurve = Any # type: ignore + EllipticCurve = cast(Any, None) def force_bytes(value: Union[str, bytes]) -> bytes: