Skip to content

Commit

Permalink
Add type hints to jwt/help.py and add missing types dependency (#784)
Browse files Browse the repository at this point in the history
* refactor: add type hints to jwt/help.py

* refactor: include cryptography types when installing development environment

* fix: unused type: ignore on Python 3.8
  • Loading branch information
Kevin Kirsche committed Aug 1, 2022
1 parent 435e826 commit ae3da74
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
11 changes: 6 additions & 5 deletions jwt/help.py
@@ -1,6 +1,7 @@
import json
import platform
import sys
from typing import Dict

from . import __version__ as pyjwt_version

Expand All @@ -10,7 +11,7 @@
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.
Expand All @@ -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"
Expand All @@ -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))

Expand Down
2 changes: 2 additions & 0 deletions setup.cfg
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit ae3da74

Please sign in to comment.