summaryrefslogtreecommitdiff
path: root/jwt/help.py
diff options
context:
space:
mode:
authorAarni Koskela <akx@iki.fi>2022-12-10 17:44:04 +0200
committerGitHub <noreply@github.com>2022-12-10 21:44:04 +0600
commit2306f68b87c5f7eecbd838db900a2d3685b81b3c (patch)
treeeba477f54ab693600e65cf325842fc0c15436a1b /jwt/help.py
parentfb9b3119449353dca6c03be27f32e482852473c3 (diff)
downloadpyjwt-2306f68b87c5f7eecbd838db900a2d3685b81b3c.tar.gz
Make mypy configuration stricter and improve typing (#830)
* PyJWS._verify_signature: raise early KeyError if header is missing alg * Make Mypy configuration stricter * Improve typing in jwt.utils * Improve typing in jwt.help * Improve typing in jwt.exceptions * Improve typing in jwt.api_jwk * Improve typing in jwt.api_jws * Improve typing & clean up imports in jwt.algorithms * Correct JWS.decode rettype to any (payload could be something else) * Update typing in api_jwt * Improve typing in jwks_client * Improve typing in docs/conf.py * Fix (benign) mistyping in test_advisory * Fix misc type complaints in tests
Diffstat (limited to 'jwt/help.py')
-rw-r--r--jwt/help.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/jwt/help.py b/jwt/help.py
index 0c02eb9..80b0ca5 100644
--- a/jwt/help.py
+++ b/jwt/help.py
@@ -7,8 +7,10 @@ from . import __version__ as pyjwt_version
try:
import cryptography
+
+ cryptography_version = cryptography.__version__
except ModuleNotFoundError:
- cryptography = None
+ cryptography_version = ""
def info() -> Dict[str, Dict[str, str]]:
@@ -29,7 +31,7 @@ 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")
+ pypy_version_info = sys.pypy_version_info # type: ignore[attr-defined]
implementation_version = (
f"{pypy_version_info.major}."
f"{pypy_version_info.minor}."
@@ -48,7 +50,7 @@ def info() -> Dict[str, Dict[str, str]]:
"name": implementation,
"version": implementation_version,
},
- "cryptography": {"version": getattr(cryptography, "__version__", "")},
+ "cryptography": {"version": cryptography_version},
"pyjwt": {"version": pyjwt_version},
}