Skip to content

Commit b1100bc

Browse files
authored
build: add py3.12 support (#234)
1 parent 9c48e6a commit b1100bc

File tree

8 files changed

+27
-24
lines changed

8 files changed

+27
-24
lines changed

.github/workflows/checks.yml

+5-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ jobs:
2121
py-version-img: [
2222
["3.9", "3.9-slim-bookworm"],
2323
["3.10", "3.10-slim-bookworm"],
24-
["3.11", "3.11-slim-bookworm"]
24+
["3.11", "3.11-slim-bookworm"],
25+
["3.12", "3.12-slim-bookworm"],
2526
]
2627
mongodb-version: ["4.4", "5.0", "6.0", "7.0"]
2728
mongodb-port: [12345]
@@ -35,6 +36,7 @@ jobs:
3536
- name: Install requirements
3637
run: |
3738
pip install -e .[dev]
39+
pip install setuptools
3840
- name: Lint with flake8
3941
run: flake8
4042
- name: Run mypy
@@ -83,7 +85,8 @@ jobs:
8385
py-version-img-tag: [
8486
["3.9", "3.9-slim-bookworm", ""],
8587
["3.10", "3.10-slim-bookworm", ""],
86-
["3.11", "3.11-slim-bookworm", "latest"],
88+
["3.11", "3.11-slim-bookworm", ""],
89+
["3.12", "3.12-slim-bookworm", "latest"],
8790
]
8891

8992
steps:

docker/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
ARG PY_IMAGE=3.11-slim-bookworm
1+
ARG PY_IMAGE=3.12-slim-bookworm
22
FROM python:$PY_IMAGE as base
33

44
# Metadata

examples/petstore-access-control/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ Some notes:
7979
> executing the build command. For example:
8080
>
8181
> ```bash
82-
> export PETSTORE_PY_IMAGE=3.11-slim-bookworm
82+
> export PETSTORE_PY_IMAGE=3.12-slim-bookworm
8383
> ```
8484
>
8585
> * In case Docker complains about port conflicts or if any of the used ports

examples/petstore/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ Some notes:
7777
> executing the build command. For example:
7878
>
7979
> ```bash
80-
> export PETSTORE_PY_IMAGE=3.11-slim-bookworm
80+
> export PETSTORE_PY_IMAGE=3.12-slim-bookworm
8181
> ```
8282
>
8383
> * In case Docker complains about port conflicts or if any of the used ports

foca/models/config.py

+6-7
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,11 @@
44
from enum import Enum
55
from functools import reduce
66
import importlib
7+
from importlib.resources import path as resource_path
78
import operator
89
from pathlib import Path
910
from typing import (Any, Dict, List, Optional, Union)
1011

11-
from pkg_resources import resource_filename
12-
1312
from pydantic import (BaseModel, Field, validator) # pylint: disable=E0611
1413
import pymongo
1514

@@ -710,11 +709,11 @@ def validate_model_path(cls, v: Optional[Path]): # pylint: disable=E0213
710709
if path is not provided.
711710
"""
712711
if v is None:
713-
return str(
714-
resource_filename(
715-
ACCESS_CONTROL_BASE_PATH, DEFAULT_MODEL_FILE
716-
)
717-
)
712+
with resource_path(
713+
ACCESS_CONTROL_BASE_PATH,
714+
DEFAULT_MODEL_FILE
715+
) as _path:
716+
return str(_path)
718717

719718
model_path = Path(v)
720719
if not model_path.is_absolute():

foca/security/access_control/register_access_control.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import logging
44
from functools import wraps
5-
from pkg_resources import resource_filename
5+
from importlib.resources import path as resource_path
66
from pathlib import Path
77
from typing import (Callable, Optional, Tuple)
88

@@ -108,9 +108,10 @@ def register_permission_specs(
108108
"""
109109
# Check if default, get package path variables for specs.
110110
if access_control_config.api_specs is None:
111-
spec_path = str(resource_filename(
111+
with resource_path(
112112
ACCESS_CONTROL_BASE_PATH, DEFAULT_API_SPEC_PATH
113-
))
113+
) as _path:
114+
spec_path = str(_path)
114115
else:
115116
spec_path = access_control_config.api_specs
116117

setup.py

+1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
"Programming Language :: Python :: 3.9",
5959
"Programming Language :: Python :: 3.10",
6060
"Programming Language :: Python :: 3.11",
61+
"Programming Language :: Python :: 3.12",
6162
"Topic :: Internet :: WWW/HTTP",
6263
"Topic :: System :: Systems Administration",
6364
"Topic :: Utilities",

tests/security/test_cors.py

+8-9
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
"""Unit test for security.cors.py"""
22

3-
from foca.security.cors import enable_cors
4-
from flask import Flask
3+
from unittest.mock import patch
54

5+
from flask import Flask
66

7-
from unittest.mock import patch
7+
from foca.security.cors import enable_cors
88

99

10-
@patch('flask_cors.CORS')
11-
def test_enable_cors(test_patch):
12-
"""Test that CORS is called with app as a parameter
13-
"""
10+
def test_enable_cors():
11+
"""Test that CORS is called with app as a parameter."""
1412
app = Flask(__name__)
15-
assert enable_cors(app) is None
16-
assert test_patch.called_with(app)
13+
with patch('foca.security.cors.CORS') as mock_cors:
14+
enable_cors(app)
15+
mock_cors.assert_called_once_with(app)

0 commit comments

Comments
 (0)