diff --git a/.github/workflows/pypi.yml b/.github/workflows/pypi.yml index 3224949..5af6d19 100644 --- a/.github/workflows/pypi.yml +++ b/.github/workflows/pypi.yml @@ -11,14 +11,14 @@ jobs: steps: - uses: actions/checkout@v2 - - name: Set up Python 3.8 - uses: actions/setup-python@v1 + - name: Set up Python 3.11 + uses: actions/setup-python@v2 with: - python-version: 3.8 + python-version: '3.11' - name: Prepare artifacts run: | - python setup.py sdist + python -m build - name: Publish to PyPI env: diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 11ade14..152b2a5 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -8,12 +8,12 @@ jobs: pre-commit: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v2 - - name: Set up Python 3.8 - uses: actions/setup-python@v1 + - name: Set up Python 3.11 + uses: actions/setup-python@v2 with: - python-version: 3.8 + python-version: '3.11' - name: Run pre-commit run: | @@ -24,14 +24,14 @@ jobs: strategy: matrix: os: [ubuntu-latest, macos-latest] - python-version: [3.6, 3.7, 3.8] + python-version: ['3.7', '3.8', '3.9', '3.10', '3.11'] runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v2 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v1 + uses: actions/setup-python@v2 with: python-version: ${{ matrix.python-version }} @@ -49,10 +49,10 @@ jobs: steps: - uses: actions/checkout@v2 - - name: Set up Python 3.8 - uses: actions/setup-python@v1 + - name: Set up Python 3.11 + uses: actions/setup-python@v2 with: - python-version: 3.8 + python-version: '3.11' - name: Run sphinx run: | diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index cbe6ff1..b34adc7 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v2.4.0 + rev: v4.4.0 hooks: - id: trailing-whitespace - id: end-of-file-fixer @@ -10,7 +10,7 @@ repos: - id: debug-statements - repo: https://github.com/psf/black - rev: 19.10b0 + rev: 22.10.0 hooks: - id: black args: [--line-length=88, --target-version=py35] @@ -41,8 +41,7 @@ repos: | tests/test_spec_examples.py ) - - repo: https://gitlab.com/pycqa/flake8 - rev: 3.7.9 + - repo: https://github.com/pycqa/flake8 + rev: 6.0.0 hooks: - id: flake8 - args: [--max-line-length=99] diff --git a/setup.py b/setup.py index 11481e0..3d97e05 100755 --- a/setup.py +++ b/setup.py @@ -49,14 +49,11 @@ "Programming Language :: Python", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3 :: Only", - "Programming Language :: Python :: 3.6", - "Programming Language :: Python :: 3.7", - "Programming Language :: Python :: 3.8", "Programming Language :: Python :: Implementation :: CPython", "Framework :: Setuptools Plugin", "Framework :: Sphinx", "Framework :: Sphinx :: Extension", ], namespace_packages=["sphinxcontrib"], - python_requires=">=3.6", + python_requires=">=3.7", ) diff --git a/sphinxcontrib/openapi/renderers/_httpdomain.py b/sphinxcontrib/openapi/renderers/_httpdomain.py index 4746c47..630e11a 100644 --- a/sphinxcontrib/openapi/renderers/_httpdomain.py +++ b/sphinxcontrib/openapi/renderers/_httpdomain.py @@ -1,6 +1,7 @@ """OpenAPI spec renderer.""" import collections +import collections.abc import copy import functools import http.client @@ -174,7 +175,7 @@ def _get_schema_type(schema): _merge_mappings = deepmerge.Merger( - [(collections.Mapping, deepmerge.strategy.dict.DictStrategies("merge"))], + [(collections.abc.Mapping, deepmerge.strategy.dict.DictStrategies("merge"))], ["override"], ["override"], ).merge diff --git a/tests/renderers/httpdomain/test_render_request_body.py b/tests/renderers/httpdomain/test_render_request_body.py index 2794cbb..b45e9d5 100644 --- a/tests/renderers/httpdomain/test_render_request_body.py +++ b/tests/renderers/httpdomain/test_render_request_body.py @@ -79,7 +79,8 @@ def test_render_request_body_schema_description_turned_off(fakestate, oas_fragme """JSON schema description is not rendered b/c feature is off.""" testrenderer = renderers.HttpdomainRenderer( - fakestate, {"no-json-schema-description": True}, + fakestate, + {"no-json-schema-description": True}, ) markup = textify( diff --git a/tests/renderers/httpdomain/test_render_request_body_example.py b/tests/renderers/httpdomain/test_render_request_body_example.py index 40022dc..b27eaf0 100644 --- a/tests/renderers/httpdomain/test_render_request_body_example.py +++ b/tests/renderers/httpdomain/test_render_request_body_example.py @@ -122,7 +122,9 @@ def test_render_request_body_example(testrenderer, content, oas_fragment): markup = textify( testrenderer.render_request_body_example( - oas_fragment(content), "/evidences/{evidenceId}", "POST", + oas_fragment(content), + "/evidences/{evidenceId}", + "POST", ) ) assert markup == textwrap.dedent( @@ -397,7 +399,9 @@ def test_render_request_body_example_external_errored_next_example( """Request body's example fallbacks on next when external cannot be retrieved.""" responses.add( - responses.GET, "https://example.com/json/examples/test.json", status=404, + responses.GET, + "https://example.com/json/examples/test.json", + status=404, ) markup = textify( @@ -431,12 +435,16 @@ def test_render_request_body_example_external_errored_next_example( @responses.activate def test_render_request_body_example_external_errored_next_media_type( - testrenderer, oas_fragment, caplog, + testrenderer, + oas_fragment, + caplog, ): """Request body's example fallbacks on next when external cannot be retrieved.""" responses.add( - responses.GET, "https://example.com/json/examples/test.json", status=404, + responses.GET, + "https://example.com/json/examples/test.json", + status=404, ) markup = textify( @@ -524,7 +532,9 @@ def test_render_request_body_example_noop(testrenderer, oas_fragment): ["http_method"], [pytest.param("POST"), pytest.param("PUT"), pytest.param("PATCH")] ) def test_render_request_body_example_http_method( - testrenderer, oas_fragment, http_method, + testrenderer, + oas_fragment, + http_method, ): """Request body's example shows proper HTTP method.""" @@ -562,7 +572,9 @@ def test_render_request_body_example_http_method( [pytest.param("/evidences/{evidenceId}"), pytest.param("/heroes/{heroId}")], ) def test_render_request_body_example_http_endpoint( - testrenderer, oas_fragment, http_endpoint, + testrenderer, + oas_fragment, + http_endpoint, ): """Request body's example shows proper HTTP method.""" diff --git a/tests/renderers/httpdomain/test_render_response_example.py b/tests/renderers/httpdomain/test_render_response_example.py index 09e4f55..99791c5 100644 --- a/tests/renderers/httpdomain/test_render_response_example.py +++ b/tests/renderers/httpdomain/test_render_response_example.py @@ -375,7 +375,9 @@ def test_render_response_example_external_errored_next_example( """Path response's example fallbacks on next when external cannot be retrieved.""" responses.add( - responses.GET, "https://example.com/json/examples/test.json", status=404, + responses.GET, + "https://example.com/json/examples/test.json", + status=404, ) markup = textify( @@ -412,7 +414,9 @@ def test_render_response_example_external_errored_next_media_type( """Path response's example fallbacks on next when external cannot be retrieved.""" responses.add( - responses.GET, "https://example.com/json/examples/test.json", status=404, + responses.GET, + "https://example.com/json/examples/test.json", + status=404, ) markup = textify( diff --git a/tests/renderers/httpdomain/test_render_responses.py b/tests/renderers/httpdomain/test_render_responses.py index f80437d..0c72e30 100644 --- a/tests/renderers/httpdomain/test_render_responses.py +++ b/tests/renderers/httpdomain/test_render_responses.py @@ -213,7 +213,8 @@ def test_render_responses_json_schema_description_turned_off(fakestate, oas_frag """JSON schema description is not rendered b/c feature is off.""" testrenderer = renderers.HttpdomainRenderer( - fakestate, {"no-json-schema-description": True}, + fakestate, + {"no-json-schema-description": True}, ) markup = textify( diff --git a/tox.ini b/tox.ini index 0cf5e21..938e424 100644 --- a/tox.ini +++ b/tox.ini @@ -7,7 +7,7 @@ deps = pytest responses commands = - {envpython} -m pytest tests/ --strict {posargs} + {envpython} -m pytest tests/ --strict-markers {posargs} [testenv:pre-commit] skip_install = true @@ -23,3 +23,17 @@ commands = [pytest] markers = regenerate_rendered_specs + +[flake8] +# The following are ignored since they conflict with black +# +# E123 closing bracket does not match indentation of opening bracket's line +# E241 multiple spaces after ':' +# E226 missing whitespace around arithmetic operator +# W503 line break before binary operator +# +# The following are ignored since we disagree with them +# +# F541 f-string is missing placeholders +ignore = E123, E241, E226, W503, F541 +max-line-length = 99