Skip to content

Commit

Permalink
Merge pull request #136 from stephenfin/update-python-versions
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenfin committed Dec 6, 2022
2 parents 4f78db9 + aacac98 commit f6438e1
Show file tree
Hide file tree
Showing 10 changed files with 63 additions and 34 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
18 changes: 9 additions & 9 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand All @@ -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 }}

Expand All @@ -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: |
Expand Down
9 changes: 4 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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]
Expand Down Expand Up @@ -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]
5 changes: 1 addition & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
)
3 changes: 2 additions & 1 deletion sphinxcontrib/openapi/renderers/_httpdomain.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""OpenAPI spec renderer."""

import collections
import collections.abc
import copy
import functools
import http.client
Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion tests/renderers/httpdomain/test_render_request_body.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
24 changes: 18 additions & 6 deletions tests/renderers/httpdomain/test_render_request_body_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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."""

Expand Down Expand Up @@ -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."""

Expand Down
8 changes: 6 additions & 2 deletions tests/renderers/httpdomain/test_render_response_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down
3 changes: 2 additions & 1 deletion tests/renderers/httpdomain/test_render_responses.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
16 changes: 15 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

0 comments on commit f6438e1

Please sign in to comment.