From ae3da7469ff8c28b726e082cd671997e09b19d55 Mon Sep 17 00:00:00 2001 From: Kevin Kirsche Date: Mon, 1 Aug 2022 06:55:45 -0400 Subject: 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 --- jwt/help.py | 11 ++++++----- setup.cfg | 2 ++ 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 -- cgit v1.2.1