Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Python 3.12 #224

Merged
merged 1 commit into from
Mar 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ ignore =
D202,
# D204: 1 blank line required after class docstring
D204,
# D101: Missing docstring in __init__
/__init__/* : D101,
# D107: Missing docstring in __init__
D107,
# W503: line break before binary operator
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ concurrency:

jobs:

test_311:
name: "Python 3.11 Tests"
test_312:
name: "Python 3.12 Tests"

runs-on: ubuntu-22.04

Expand Down Expand Up @@ -63,7 +63,7 @@ jobs:
name: htmlcov
path: htmlcov

test_38:
test_39:
name: "Python 3.9 Tests"

runs-on: ubuntu-22.04
Expand Down Expand Up @@ -104,7 +104,7 @@ jobs:
name: "Release to PyPI"

if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
needs: [test_311, test_38]
needs: [test_312, test_39]
runs-on: ubuntu-22.04

# To test publishing to testpypi:
Expand Down
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
## Changelog

0.17.0 (unreleased)
-------------------

* Update the supported version of Python to 3.12, Pyramid to 2.0.2.
miketheman marked this conversation as resolved.
Show resolved Hide resolved
Drop support for Python 3.8.
[zupo]

* Update the supported version of `openapi-core` to 0.19.0, refs #220.
Drop support for all older versions of `openapi-core`.
[miketheman, Wim-De-Clercq, zupo]

* Update Swagger UI version to 4.18.3, refs #210.
[kskarthik]

* Add support for specifying the protocol and port for getting the openapi3
spec file, fixes running behind a reverse proxy, refs #176.
[vpet98, zupo]


0.16.0 (2023-03-22)
-------------------
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Convenience makefile to build the dev env and run common commands
# Based on https://github.com/niteoweb/Makefile

PYTHON ?= python3.11
PYTHON ?= python3.12

.PHONY: all
all: tests
Expand Down
16 changes: 9 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ The authors of pyramid_openapi3 believe that the approach of validating a manual

## Running tests

You need to have [poetry](https://python-poetry.org/) and Python 3.9 through 3.11 installed on your machine. All `Makefile` commands assume you have the Poetry environment activated, i.e. `poetry shell`.
You need to have [poetry](https://python-poetry.org/) and Python 3.9 through 3.12 installed on your machine. All `Makefile` commands assume you have the Poetry environment activated, i.e. `poetry shell`.

Alternatively, if you use [nix](https://nix.dev/tutorials/declarative-and-reproducible-developer-environments), run `nix-shell` to drop into a shell that has everything prepared for development.

Expand All @@ -201,16 +201,18 @@ These packages tackle the same problem-space:

We do our best to follow the rules below.

* Support the latest few releases of Python, currently Python 3.9 through 3.11.
* Support the latest few releases of Pyramid, currently 1.10.7 through 2.0.
* Support the latest few releases of `openapi-core`, currently 0.16.1 through 0.16.2.
* Support the latest few releases of Python, currently Python 3.9 through 3.12.
* Support the latest few releases of Pyramid, currently 1.10.7 through 2.0.2.
* Support the latest few releases of `openapi-core`, currently just 0.19.0.
* See `poetry.lock` for a frozen-in-time known-good-set of all dependencies.

## Use in the wild

A couple of projects that use pyramid_openapi3 in production:

- [WooCart API](https://app.woocart.com/api/v1) - User control panel for WooCart Managed WooCommerce service.
- [Pareto Security Team Dashboard API](https://dash.paretosecurity.com/api/v1) - Team Dashboard for Pareto Security macOS security app.
- [SEO Domain Finder API](https://app.seodomainfinder.com/api/v1) - A tool for finding expired domains with SEO value.
- [Rankalyzer.io](https://app.rankalyzer.io/api/v1) - Monitor SEO changes and strategies of competitors to improve your search traffic.
- [Kafkai API](https://app.kafkai.com/api/v1) - User control panel for Kafkai text generation service.
- [Open on-chain data API](https://tradingstrategy.ai/api/explorer/) - Decentralised exchange and blockchain trading data open API
- [Pareto Security Team Dashboard API](https://dash.paretosecurity.app/api/v1) - Team Dashboard for Pareto Security macOS security app
- [Open on-chain data API](https://tradingstrategy.ai/api/explorer/) - Decentralised exchange and blockchain trading data open API.
- [Mayet RX](https://app.mayetrx.com/api/v1) - Vendor management system for pharma/medical clinical trials.
1,099 changes: 542 additions & 557 deletions poetry.lock

Large diffs are not rendered by default.

53 changes: 3 additions & 50 deletions py39/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions py39/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ exclude = ["pyramid_openapi3/tests/"]
python = "^3.9"

openapi-core = "==0.19.0"
jsonschema-path = ">=0.3.0"
pyramid = "==1.10.7"


Expand Down Expand Up @@ -62,7 +61,6 @@ pre-commit-hooks = "*"
pytest = "*"
pytest-cov = "*"
pytest-instafail = "*"
pytest-lazy-fixture = "*"
pytest-randomly = "*"
pytest-socket = "*"
pyupgrade = "*"
Expand Down
2 changes: 0 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ exclude = ["pyramid_openapi3/tests/"]
python = "^3.9"

openapi-core = ">=0.19.0"
jsonschema-path = ">=0.3.0"
miketheman marked this conversation as resolved.
Show resolved Hide resolved
pyramid = ">=1.10.7"


Expand Down Expand Up @@ -62,7 +61,6 @@ pre-commit-hooks = "*"
pytest = "*"
pytest-cov = "*"
pytest-instafail = "*"
pytest-lazy-fixture = "*"
pytest-randomly = "*"
pytest-socket = "*"
pyupgrade = "*"
Expand Down
6 changes: 3 additions & 3 deletions pyramid_openapi3/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,9 +348,9 @@ def action() -> None:
root_factory = path_item.get(root_factory_ext)
config.add_route(
route_name,
pattern=route_prefix + pattern
if route_prefix is not None
else pattern,
pattern=(
route_prefix + pattern if route_prefix is not None else pattern
),
factory=root_factory or None,
)

Expand Down
4 changes: 4 additions & 0 deletions pyramid_openapi3/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@


class RequestValidationError(HTTPBadRequest):
"""Error raised when Request validation fails."""

explanation = "Request validation failed."

Expand All @@ -28,6 +29,7 @@ def __str__(self) -> str:


class ResponseValidationError(HTTPInternalServerError):
"""Error raised when Response validation fails."""

explanation = "Response validation failed."

Expand Down Expand Up @@ -144,6 +146,8 @@ def extract_errors(


class MissingEndpointsError(Exception):
"""Error raised when endpoints are not found."""

missing: list

def __init__(self, missing: t.List[str]) -> None:
Expand Down
43 changes: 28 additions & 15 deletions pyramid_openapi3/tests/test_app_construction.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from pyramid.request import Request
from pyramid.testing import testConfig
from pyramid_openapi3 import MissingEndpointsError
from pytest_lazyfixture import lazy_fixture

import logging
import os
Expand Down Expand Up @@ -181,19 +180,19 @@ def root_server_app_config(
yield simple_config


@pytest.fixture(
params=(
lazy_fixture("simple_app_config"),
lazy_fixture("split_file_app_config"),
)
app_config = pytest.mark.parametrize(
"app_config",
[
"simple_app_config",
"split_file_app_config",
],
)
def app_config(request: SubRequest) -> Configurator:
"""Parametrized fixture containing various app configs to test."""
return request.param


def test_all_routes(app_config: Configurator) -> None:
@app_config
def test_all_routes(app_config: Configurator, request: SubRequest) -> None:
"""Test case showing that an app can be created with all routes defined."""
app_config = request.getfixturevalue(app_config)
app_config.add_route(name="foo", pattern="/foo")
app_config.add_route(name="bar", pattern="/bar")
app_config.add_view(
Expand All @@ -206,8 +205,10 @@ def test_all_routes(app_config: Configurator) -> None:
app_config.make_wsgi_app()


def test_prefixed_routes(app_config: Configurator) -> None:
@app_config
def test_prefixed_routes(app_config: Configurator, request: SubRequest) -> None:
"""Test case for prefixed routes."""
app_config = request.getfixturevalue(app_config)
app_config.add_route(name="foo", pattern="/api/v1/foo")
app_config.add_route(name="bar", pattern="/api/v1/bar")
app_config.add_view(
Expand All @@ -220,8 +221,12 @@ def test_prefixed_routes(app_config: Configurator) -> None:
app_config.make_wsgi_app()


def test_pyramid_prefixed_context_routes(app_config: Configurator) -> None:
@app_config
def test_pyramid_prefixed_context_routes(
app_config: Configurator, request: SubRequest
) -> None:
"""Test case for prefixed routes using pyramid route_prefix_context."""
app_config = request.getfixturevalue(app_config)
with app_config.route_prefix_context("/api/v1"):
app_config.add_route(name="foo", pattern="/foo")
app_config.add_route(name="bar", pattern="/bar")
Expand All @@ -235,19 +240,23 @@ def test_pyramid_prefixed_context_routes(app_config: Configurator) -> None:
app_config.make_wsgi_app()


def test_missing_routes(app_config: Configurator) -> None:
@app_config
def test_missing_routes(app_config: Configurator, request: SubRequest) -> None:
"""Test case showing app creation fails, when defined routes are missing."""
app_config = request.getfixturevalue(app_config)
with pytest.raises(MissingEndpointsError) as ex:
app_config.make_wsgi_app()

assert str(ex.value) == "Unable to find routes for endpoints: /foo, /bar"


@app_config
def test_disable_endpoint_validation(
app_config: Configurator, caplog: LogCaptureFixture
app_config: Configurator, caplog: LogCaptureFixture, request: SubRequest
) -> None:
"""Test case showing app creation whilst disabling endpoint validation."""
caplog.set_level(logging.INFO)
app_config = request.getfixturevalue(app_config)
app_config.registry.settings["pyramid_openapi3.enable_endpoint_validation"] = False
app_config.add_route(name="foo", pattern="/foo")
app_config.add_view(
Expand All @@ -273,8 +282,12 @@ def test_unconfigured_app(
assert "pyramid_openapi3 settings not found" in caplog.text


def test_routes_setting_generation(app_config: Configurator) -> None:
@app_config
def test_routes_setting_generation(
app_config: Configurator, request: SubRequest
) -> None:
"""Test the `routes` setting is correctly created after app creation."""
app_config = request.getfixturevalue(app_config)

# Test that having multiple routes for a single route / pattern still works
app_config.add_route(name="get_foo", pattern="/foo", request_method="GET")
Expand Down
2 changes: 1 addition & 1 deletion pyramid_openapi3/tests/test_permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
]


class DummyDefaultContext(object):
class DummyDefaultContext(object): # noqa: D101

__acl__ = DEFAULT_ACL

Expand Down
Loading
Loading