From a086e61af8f12384045079e38fd62a9f09c8985b Mon Sep 17 00:00:00 2001 From: Jon Dufresne Date: Wed, 16 Dec 2020 12:30:03 -0800 Subject: [PATCH] Upgrade black version and usage (#538) Upgrade black to version 20.8b1 and specify that Python 3.6+ syntax should be used. Run it on all files to upgrade syntax. --- .pre-commit-config.yaml | 4 ++-- docs/conf.py | 6 +++--- jwt/api_jws.py | 2 +- jwt/api_jwt.py | 4 ++-- tests/test_algorithms.py | 2 +- tests/test_api_jws.py | 12 ++++++------ 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 724e8a07..1e443458 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,9 +1,9 @@ repos: - repo: https://github.com/psf/black - rev: 19.10b0 + rev: 20.8b1 hooks: - id: black - language_version: python3.8 + args: ["--target-version=py36"] - repo: https://gitlab.com/pycqa/flake8 rev: 3.7.9 diff --git a/docs/conf.py b/docs/conf.py index 42a978d9..18a4ecf9 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -65,7 +65,7 @@ def find_version(*file_paths): release = find_version("../jwt/__init__.py") # The short X.Y version. -version = release.rsplit(u".", 1)[0] +version = release.rsplit(".", 1)[0] # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. @@ -112,7 +112,7 @@ def find_version(*file_paths): # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). -man_pages = [(master_doc, "pyjwt", u"PyJWT Documentation", [author], 1)] +man_pages = [(master_doc, "pyjwt", "PyJWT Documentation", [author], 1)] # -- Options for Texinfo output ------------------------------------------- @@ -124,7 +124,7 @@ def find_version(*file_paths): ( master_doc, "PyJWT", - u"PyJWT Documentation", + "PyJWT Documentation", author, "PyJWT", "One line description of project.", diff --git a/jwt/api_jws.py b/jwt/api_jws.py index 1e00221e..83baaab8 100644 --- a/jwt/api_jws.py +++ b/jwt/api_jws.py @@ -131,7 +131,7 @@ def decode( algorithms: List[str] = None, options: Dict = None, complete: bool = False, - **kwargs + **kwargs, ): merged_options = merge_dict(self.options, options) diff --git a/jwt/api_jwt.py b/jwt/api_jwt.py index 521cc651..4862580f 100644 --- a/jwt/api_jwt.py +++ b/jwt/api_jwt.py @@ -71,7 +71,7 @@ def decode( algorithms: List[str] = None, options: Dict = None, complete: bool = False, - **kwargs + **kwargs, ) -> Dict[str, Any]: if options is None: @@ -90,7 +90,7 @@ def decode( algorithms=algorithms, options=options, complete=complete, - **kwargs + **kwargs, ) try: diff --git a/tests/test_algorithms.py b/tests/test_algorithms.py index 468f58e7..145ac924 100644 --- a/tests/test_algorithms.py +++ b/tests/test_algorithms.py @@ -442,7 +442,7 @@ def test_rsa_to_jwk_returns_correct_values_for_private_key(self): key = algo.to_jwk(priv_key) expected = { - "key_ops": [u"sign"], + "key_ops": ["sign"], "kty": "RSA", "e": "AQAB", "n": ( diff --git a/tests/test_api_jws.py b/tests/test_api_jws.py index 464cfeba..6b7efa87 100644 --- a/tests/test_api_jws.py +++ b/tests/test_api_jws.py @@ -493,7 +493,7 @@ def test_encode_decode_with_rsa_sha256(self, jws, payload): # PEM-formatted RSA key with open("tests/keys/testkey_rsa.priv", "r") as rsa_priv_file: priv_rsakey = load_pem_private_key( - force_bytes(rsa_priv_file.read()), password=None, + force_bytes(rsa_priv_file.read()), password=None ) jws_message = jws.encode(payload, priv_rsakey, algorithm="RS256") @@ -518,7 +518,7 @@ def test_encode_decode_with_rsa_sha384(self, jws, payload): # PEM-formatted RSA key with open("tests/keys/testkey_rsa.priv", "r") as rsa_priv_file: priv_rsakey = load_pem_private_key( - force_bytes(rsa_priv_file.read()), password=None, + force_bytes(rsa_priv_file.read()), password=None ) jws_message = jws.encode(payload, priv_rsakey, algorithm="RS384") @@ -542,7 +542,7 @@ def test_encode_decode_with_rsa_sha512(self, jws, payload): # PEM-formatted RSA key with open("tests/keys/testkey_rsa.priv", "r") as rsa_priv_file: priv_rsakey = load_pem_private_key( - force_bytes(rsa_priv_file.read()), password=None, + force_bytes(rsa_priv_file.read()), password=None ) jws_message = jws.encode(payload, priv_rsakey, algorithm="RS512") @@ -586,7 +586,7 @@ def test_encode_decode_with_ecdsa_sha256(self, jws, payload): # PEM-formatted EC key with open("tests/keys/testkey_ec.priv", "r") as ec_priv_file: priv_eckey = load_pem_private_key( - force_bytes(ec_priv_file.read()), password=None, + force_bytes(ec_priv_file.read()), password=None ) jws_message = jws.encode(payload, priv_eckey, algorithm="ES256") @@ -611,7 +611,7 @@ def test_encode_decode_with_ecdsa_sha384(self, jws, payload): # PEM-formatted EC key with open("tests/keys/testkey_ec.priv", "r") as ec_priv_file: priv_eckey = load_pem_private_key( - force_bytes(ec_priv_file.read()), password=None, + force_bytes(ec_priv_file.read()), password=None ) jws_message = jws.encode(payload, priv_eckey, algorithm="ES384") @@ -635,7 +635,7 @@ def test_encode_decode_with_ecdsa_sha512(self, jws, payload): # PEM-formatted EC key with open("tests/keys/testkey_ec.priv", "r") as ec_priv_file: priv_eckey = load_pem_private_key( - force_bytes(ec_priv_file.read()), password=None, + force_bytes(ec_priv_file.read()), password=None ) jws_message = jws.encode(payload, priv_eckey, algorithm="ES512")