summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Kirsche <kevin.kirsche@one.verizon.com>2022-08-01 06:55:45 -0400
committerGitHub <noreply@github.com>2022-08-01 16:55:45 +0600
commitae3da7469ff8c28b726e082cd671997e09b19d55 (patch)
tree1458c73bfb80f5f3a5014cf6aab3984d1fd2b424
parent435e826da56a105da51176355a29cdc00420f4c1 (diff)
downloadpyjwt-ae3da7469ff8c28b726e082cd671997e09b19d55.tar.gz
Add type hints to jwt/help.py and add missing types dependency (#784)
* refactor: add type hints to jwt/help.py * refactor: include cryptography types when installing development environment * fix: unused type: ignore on Python 3.8
-rw-r--r--jwt/help.py11
-rw-r--r--setup.cfg2
2 files changed, 8 insertions, 5 deletions
diff --git a/jwt/help.py b/jwt/help.py
index d5c3ebb..767c323 100644
--- a/jwt/help.py
+++ b/jwt/help.py
@@ -1,6 +1,7 @@
import json
import platform
import sys
+from typing import Dict
from . import __version__ as pyjwt_version
@@ -10,7 +11,7 @@ except ModuleNotFoundError:
cryptography = None # type: ignore
-def info():
+def info() -> Dict[str, Dict[str, str]]:
"""
Generate information for a bug report.
Based on the requests package help utility module.
@@ -29,13 +30,13 @@ def info():
implementation_version = platform.python_version()
elif implementation == "PyPy":
implementation_version = (
- f"{sys.pypy_version_info.major}."
+ f"{sys.pypy_version_info.major}." # type: ignore[attr-defined]
f"{sys.pypy_version_info.minor}."
f"{sys.pypy_version_info.micro}"
)
- if sys.pypy_version_info.releaselevel != "final":
+ if sys.pypy_version_info.releaselevel != "final": # type: ignore[attr-defined]
implementation_version = "".join(
- [implementation_version, sys.pypy_version_info.releaselevel]
+ [implementation_version, sys.pypy_version_info.releaselevel] # type: ignore[attr-defined]
)
else:
implementation_version = "Unknown"
@@ -51,7 +52,7 @@ def info():
}
-def main():
+def main() -> None:
"""Pretty-print the bug information as JSON."""
print(json.dumps(info(), sort_keys=True, indent=2))
diff --git a/setup.cfg b/setup.cfg
index 67d30a7..9fc9169 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -45,6 +45,7 @@ docs =
zope.interface
crypto =
cryptography>=3.3.1
+ types-cryptography>=3.3.21
tests =
pytest>=6.0.0,<7.0.0
coverage[toml]==5.0.4
@@ -53,6 +54,7 @@ dev =
sphinx-rtd-theme
zope.interface
cryptography>=3.3.1
+ types-cryptography>=3.3.21
pytest>=6.0.0,<7.0.0
coverage[toml]==5.0.4
mypy