From c1c588b865687be79d69a1dbdb39ce464e41584b Mon Sep 17 00:00:00 2001 From: Kevin Kirsche Date: Tue, 26 Jul 2022 13:51:12 -0400 Subject: [PATCH 1/3] refactor: add type hints to jwt/help.py --- jwt/help.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/jwt/help.py b/jwt/help.py index d5c3ebbf..7ba1fb82 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 @@ 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.minor}." - f"{sys.pypy_version_info.micro}" + f"{sys.pypy_version_info.major}." # type: ignore[attr-defined] + f"{sys.pypy_version_info.minor}." # type: ignore[attr-defined] + f"{sys.pypy_version_info.micro}" # type: ignore[attr-defined] ) - 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)) From 1600a8bbfa28da9c7298924d591b7e2e1c42adb1 Mon Sep 17 00:00:00 2001 From: Kevin Kirsche Date: Tue, 26 Jul 2022 13:51:38 -0400 Subject: [PATCH 2/3] refactor: include cryptography types when installing development environment --- setup.cfg | 2 ++ 1 file changed, 2 insertions(+) diff --git a/setup.cfg b/setup.cfg index 67d30a7b..9fc9169f 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 From ad1795bb0378ed8640432c09445a8708f39f78fb Mon Sep 17 00:00:00 2001 From: Kevin Kirsche Date: Tue, 26 Jul 2022 13:56:50 -0400 Subject: [PATCH 3/3] fix: unused type: ignore on Python 3.8 --- jwt/help.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jwt/help.py b/jwt/help.py index 7ba1fb82..767c323f 100644 --- a/jwt/help.py +++ b/jwt/help.py @@ -31,8 +31,8 @@ def info() -> Dict[str, Dict[str, str]]: elif implementation == "PyPy": implementation_version = ( f"{sys.pypy_version_info.major}." # type: ignore[attr-defined] - f"{sys.pypy_version_info.minor}." # type: ignore[attr-defined] - f"{sys.pypy_version_info.micro}" # type: ignore[attr-defined] + f"{sys.pypy_version_info.minor}." + f"{sys.pypy_version_info.micro}" ) if sys.pypy_version_info.releaselevel != "final": # type: ignore[attr-defined] implementation_version = "".join(