Skip to content

Commit ae3da74

Browse files
author
Kevin Kirsche
authored
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
1 parent 435e826 commit ae3da74

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

jwt/help.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import json
22
import platform
33
import sys
4+
from typing import Dict
45

56
from . import __version__ as pyjwt_version
67

@@ -10,7 +11,7 @@
1011
cryptography = None # type: ignore
1112

1213

13-
def info():
14+
def info() -> Dict[str, Dict[str, str]]:
1415
"""
1516
Generate information for a bug report.
1617
Based on the requests package help utility module.
@@ -29,13 +30,13 @@ def info():
2930
implementation_version = platform.python_version()
3031
elif implementation == "PyPy":
3132
implementation_version = (
32-
f"{sys.pypy_version_info.major}."
33+
f"{sys.pypy_version_info.major}." # type: ignore[attr-defined]
3334
f"{sys.pypy_version_info.minor}."
3435
f"{sys.pypy_version_info.micro}"
3536
)
36-
if sys.pypy_version_info.releaselevel != "final":
37+
if sys.pypy_version_info.releaselevel != "final": # type: ignore[attr-defined]
3738
implementation_version = "".join(
38-
[implementation_version, sys.pypy_version_info.releaselevel]
39+
[implementation_version, sys.pypy_version_info.releaselevel] # type: ignore[attr-defined]
3940
)
4041
else:
4142
implementation_version = "Unknown"
@@ -51,7 +52,7 @@ def info():
5152
}
5253

5354

54-
def main():
55+
def main() -> None:
5556
"""Pretty-print the bug information as JSON."""
5657
print(json.dumps(info(), sort_keys=True, indent=2))
5758

setup.cfg

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ docs =
4545
zope.interface
4646
crypto =
4747
cryptography>=3.3.1
48+
types-cryptography>=3.3.21
4849
tests =
4950
pytest>=6.0.0,<7.0.0
5051
coverage[toml]==5.0.4
@@ -53,6 +54,7 @@ dev =
5354
sphinx-rtd-theme
5455
zope.interface
5556
cryptography>=3.3.1
57+
types-cryptography>=3.3.21
5658
pytest>=6.0.0,<7.0.0
5759
coverage[toml]==5.0.4
5860
mypy

0 commit comments

Comments
 (0)