From a71672e2c103714ecbbfa12c61d799e0e4794bea Mon Sep 17 00:00:00 2001 From: Jakob Schlyter Date: Sun, 26 Jul 2020 08:55:21 +0200 Subject: [PATCH 1/7] move settings to pyproject.toml --- .travis.yml | 2 +- pyproject.toml | 12 ++++++++++++ setup.cfg | 7 ------- 3 files changed, 13 insertions(+), 8 deletions(-) create mode 100644 pyproject.toml delete mode 100644 setup.cfg diff --git a/.travis.yml b/.travis.yml index 12fd07a6..fe0ce8de 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,7 +18,7 @@ script: - codecov --version - tox - isort --check src tests - - black -l 100 --check src tests + - black --check src tests after_success: - codecov notifications: diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..a9f28cd0 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,12 @@ +# PEP 518: https://www.python.org/dev/peps/pep-0518/ + +[tool.black] +line-length = 100 + +[tool.isort] +force_single_line = true +known_first_party = "cryptojwt" +include_trailing_comma = true +force_grid_wrap = 0 +use_parentheses = true +line_length = 100 diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 6a04d9e3..00000000 --- a/setup.cfg +++ /dev/null @@ -1,7 +0,0 @@ -[isort] -force_single_line = 1 -known_first_party = cryptojwt -include_trailing_comma = True -force_grid_wrap = 0 -use_parentheses = True -line_length = 100 From aed209b5b9b69724c8c154fe7750199adddc6b7b Mon Sep 17 00:00:00 2001 From: Jakob Schlyter Date: Sun, 26 Jul 2020 09:00:17 +0200 Subject: [PATCH 2/7] add pytest plugins black and isort --- tox.ini | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tox.ini b/tox.ini index c3b44dff..5f2866c2 100644 --- a/tox.ini +++ b/tox.ini @@ -9,8 +9,10 @@ commands = extras = testing deps = codecov + pytest-black pytest-cov pytest-httpserver + pytest-isort [pep8] max-line-length=100 From 7a53a3fd40f87ef237808639a0140539da6587bc Mon Sep 17 00:00:00 2001 From: Jakob Schlyter Date: Sun, 26 Jul 2020 09:10:06 +0200 Subject: [PATCH 3/7] - run isort and black from pytest - use python 3.8 for quality checks - run black in quality env --- .travis.yml | 3 --- tox.ini | 8 ++++---- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index fe0ce8de..4da6eb14 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,12 +13,9 @@ addons: install: - pip install codecov - pip install tox tox-travis - - pip install isort black script: - codecov --version - tox - - isort --check src tests - - black --check src tests after_success: - codecov notifications: diff --git a/tox.ini b/tox.ini index 5f2866c2..e5b20223 100644 --- a/tox.ini +++ b/tox.ini @@ -4,7 +4,7 @@ envlist = py{36,37,38},quality [testenv] passenv = CI TRAVIS TRAVIS_* commands = - py.test --cov=cryptojwt tests/ {posargs} + py.test --cov=cryptojwt --isort --black tests/ {posargs} codecov extras = testing deps = @@ -22,10 +22,10 @@ addopts = --color=yes markers = network [testenv:quality] -# Black need python 3.6 -basepython = python3.6 +basepython = python3.8 ignore_errors = True deps = twine extras = quality commands = - isort --recursive --diff --check-only src/ tests/ + isort --check --diff src tests + black --check src tests From f0c1e7387259602773b98edcb630e776ab867d4a Mon Sep 17 00:00:00 2001 From: Jakob Schlyter Date: Sun, 26 Jul 2020 09:21:22 +0200 Subject: [PATCH 4/7] move coverage config to pyproject.toml --- .coveragerc | 7 ------- pyproject.toml | 9 +++++++++ 2 files changed, 9 insertions(+), 7 deletions(-) delete mode 100644 .coveragerc diff --git a/.coveragerc b/.coveragerc deleted file mode 100644 index f2c3d0b8..00000000 --- a/.coveragerc +++ /dev/null @@ -1,7 +0,0 @@ -[run] -branch = True - -[report] -exclude_lines = - pragma: no cover - raise NotImplementedError diff --git a/pyproject.toml b/pyproject.toml index a9f28cd0..d639eb5e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,3 +10,12 @@ include_trailing_comma = true force_grid_wrap = 0 use_parentheses = true line_length = 100 + +[tool.coverage.run] +branch = true + +[tool.coverage.report] +exclude_lines = [ + "pragma: no cover", + "raise NotImplementedError", +] From 80a135ff7531a0c554e7864be9787d0c4ab9c237 Mon Sep 17 00:00:00 2001 From: Jakob Schlyter Date: Tue, 28 Jul 2020 21:12:22 +0200 Subject: [PATCH 5/7] skip test as https://connect-op.herokuapp.com/jwks.json fails --- tests/test_04_key_jar.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/test_04_key_jar.py b/tests/test_04_key_jar.py index fcc19773..55f96020 100755 --- a/tests/test_04_key_jar.py +++ b/tests/test_04_key_jar.py @@ -443,6 +443,7 @@ def test_no_use(self): assert enc_key != [] @pytest.mark.network + @pytest.mark.skip("connect-op.herokuapp.com is broken") def test_provider(self): kj = KeyJar() kj.load_keys( From 08716b785a829546bdbbd158a05b9085b7a46699 Mon Sep 17 00:00:00 2001 From: Jakob Schlyter Date: Tue, 28 Jul 2020 21:18:46 +0200 Subject: [PATCH 6/7] test all files using pytest --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index e5b20223..def7f92e 100644 --- a/tox.ini +++ b/tox.ini @@ -4,7 +4,7 @@ envlist = py{36,37,38},quality [testenv] passenv = CI TRAVIS TRAVIS_* commands = - py.test --cov=cryptojwt --isort --black tests/ {posargs} + py.test --cov=cryptojwt --isort --black {posargs} codecov extras = testing deps = From a9ee149e61ae41938470de35c468b7138ad7580a Mon Sep 17 00:00:00 2001 From: Jakob Schlyter Date: Tue, 28 Jul 2020 21:19:30 +0200 Subject: [PATCH 7/7] run black on conf and setup --- doc/conf.py | 69 ++++++++++++++++++++++++++--------------------------- setup.py | 33 ++++++++++++++----------- 2 files changed, 53 insertions(+), 49 deletions(-) diff --git a/doc/conf.py b/doc/conf.py index 1cc6d858..28cd9204 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -31,36 +31,38 @@ # Add any Sphinx extension module names here, as strings. They can be # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. -extensions = ['sphinx.ext.autodoc', - 'sphinx.ext.intersphinx', - 'sphinx.ext.coverage', - 'sphinx.ext.viewcode'] +extensions = [ + "sphinx.ext.autodoc", + "sphinx.ext.intersphinx", + "sphinx.ext.coverage", + "sphinx.ext.viewcode", +] # Add any paths that contain templates here, relative to this directory. -templates_path = ['_templates'] +templates_path = ["_templates"] # The suffix(es) of source filenames. # You can specify multiple suffix as a list of string: # # source_suffix = ['.rst', '.md'] -source_suffix = '.rst' +source_suffix = ".rst" # The master toctree document. -master_doc = 'index' +master_doc = "index" # General information about the project. -project = 'CryptoJWT' -copyright = '2018, Roland Hedberg' -author = 'Roland Hedberg' +project = "CryptoJWT" +copyright = "2018, Roland Hedberg" +author = "Roland Hedberg" # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the # built documents. # # The short X.Y version. -version = '0.4' +version = "0.4" # The full version, including alpha/beta/rc tags. -release = '0.4' +release = "0.4" # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. @@ -72,10 +74,10 @@ # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. # This patterns also effect to html_static_path and html_extra_path -exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] +exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"] # The name of the Pygments (syntax highlighting) style to use. -pygments_style = 'sphinx' +pygments_style = "sphinx" # If true, `todo` and `todoList` produce output, else they produce nothing. todo_include_todos = False @@ -86,7 +88,7 @@ # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. # -html_theme = 'default' +html_theme = "default" # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the @@ -97,7 +99,7 @@ # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". -html_static_path = ['_static'] +html_static_path = ["_static"] # Custom sidebar templates, must be a dictionary that maps document names # to template names. @@ -105,9 +107,9 @@ # This is required for the alabaster theme # refs: http://alabaster.readthedocs.io/en/latest/installation.html#sidebars html_sidebars = { - '**': [ - 'relations.html', # needs 'show_related': True theme option to display - 'searchbox.html', + "**": [ + "relations.html", # needs 'show_related': True theme option to display + "searchbox.html", ] } @@ -115,7 +117,7 @@ # -- Options for HTMLHelp output ------------------------------------------ # Output file base name for HTML help builder. -htmlhelp_basename = 'CryptoJWTdoc' +htmlhelp_basename = "CryptoJWTdoc" # -- Options for LaTeX output --------------------------------------------- @@ -124,15 +126,12 @@ # The paper size ('letterpaper' or 'a4paper'). # # 'papersize': 'letterpaper', - # The font size ('10pt', '11pt' or '12pt'). # # 'pointsize': '10pt', - # Additional stuff for the LaTeX preamble. # # 'preamble': '', - # Latex figure (float) alignment # # 'figure_align': 'htbp', @@ -142,8 +141,7 @@ # (source start file, target name, title, # author, documentclass [howto, manual, or own class]). latex_documents = [ - (master_doc, 'CryptoJWT.tex', 'CryptoJWT Documentation', - 'Roland Hedberg', 'manual'), + (master_doc, "CryptoJWT.tex", "CryptoJWT Documentation", "Roland Hedberg", "manual"), ] @@ -151,10 +149,7 @@ # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). -man_pages = [ - (master_doc, 'cryptojwt', 'CryptoJWT Documentation', - [author], 1) -] +man_pages = [(master_doc, "cryptojwt", "CryptoJWT Documentation", [author], 1)] # -- Options for Texinfo output ------------------------------------------- @@ -163,13 +158,17 @@ # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ - (master_doc, 'CryptoJWT', 'CryptoJWT Documentation', - author, 'CryptoJWT', 'One line description of project.', - 'Miscellaneous'), + ( + master_doc, + "CryptoJWT", + "CryptoJWT Documentation", + author, + "CryptoJWT", + "One line description of project.", + "Miscellaneous", + ), ] - - # Example configuration for intersphinx: refer to the Python standard library. -intersphinx_mapping = {'https://docs.python.org/': None} +intersphinx_mapping = {"https://docs.python.org/": None} diff --git a/setup.py b/setup.py index fe415e37..d62ad040 100644 --- a/setup.py +++ b/setup.py @@ -20,13 +20,12 @@ from setuptools import setup -__author__ = 'Roland Hedberg' +__author__ = "Roland Hedberg" -with open('src/cryptojwt/__init__.py', 'r') as fd: - version = re.search(r'^__version__\s*=\s*[\'"]([^\'"]*)[\'"]', - fd.read(), re.MULTILINE).group(1) +with open("src/cryptojwt/__init__.py", "r") as fd: + version = re.search(r'^__version__\s*=\s*[\'"]([^\'"]*)[\'"]', fd.read(), re.MULTILINE).group(1) -tests_requires = ['responses', 'pytest', 'isort>=5.0.2', 'black'] +tests_requires = ["responses", "pytest", "isort>=5.0.2", "black"] setup( name="cryptojwt", @@ -35,8 +34,14 @@ author="Roland Hedberg", author_email="roland@catalogix.se", license="Apache 2.0", - packages=["cryptojwt", "cryptojwt/jwe", "cryptojwt/jwk", "cryptojwt/jws", "cryptojwt/tools", - "cryptojwt/serialize"], + packages=[ + "cryptojwt", + "cryptojwt/jwe", + "cryptojwt/jwk", + "cryptojwt/jws", + "cryptojwt/tools", + "cryptojwt/serialize", + ], package_dir={"": "src"}, classifiers=[ "Development Status :: 4 - Beta", @@ -45,22 +50,22 @@ "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", - "Programming Language :: Python :: 3.8" + "Programming Language :: Python :: 3.8", ], install_requires=["cryptography", "requests"], - tests_require=['pytest'], + tests_require=["pytest"], zip_safe=False, extras_require={ - 'testing': tests_requires, - 'docs': ['Sphinx', 'sphinx-autobuild', 'alabaster'], - 'quality': ['isort>=5.0.2', 'black'], + "testing": tests_requires, + "docs": ["Sphinx", "sphinx-autobuild", "alabaster"], + "quality": ["isort>=5.0.2", "black"], }, - scripts=glob.glob('script/*.py'), + scripts=glob.glob("script/*.py"), entry_points={ "console_scripts": [ "jwkgen = cryptojwt.tools.keygen:main", "jwkconv = cryptojwt.tools.keyconv:main", "jwtpeek = cryptojwt.tools.jwtpeek:main", ] - } + }, )