Skip to content

Commit f3a9409

Browse files
add support for python 3.14 (#117)
1 parent 158f6d1 commit f3a9409

7 files changed

Lines changed: 25 additions & 29 deletions

File tree

.github/workflows/main.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ on:
1414
workflow_dispatch:
1515

1616
env:
17-
POETRY_VERSION: 1.5.1
17+
POETRY_VERSION: 2.3.2
1818

1919
jobs:
2020
tests:
@@ -23,7 +23,7 @@ jobs:
2323
strategy:
2424
matrix:
2525
os: [Ubuntu]
26-
python-version: ["3.10", "3.11", "3.12", "3.13"]
26+
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
2727
include:
2828
- os: Ubuntu
2929
image: ubuntu-latest

.github/workflows/release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ jobs:
1616
- name: Checkout code
1717
uses: actions/checkout@v5
1818

19-
- name: Set up Python 3.13
19+
- name: Set up Python 3.14
2020
uses: actions/setup-python@v6
2121
with:
22-
python-version: "3.13"
22+
python-version: "3.14"
2323

2424
- name: Bootstrap poetry
2525
run: |

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ default_language_version:
44
python: python3
55
repos:
66
- repo: https://github.com/asottile/pyupgrade
7-
rev: v3.10.1
7+
rev: v3.21.2
88
hooks:
99
- id: pyupgrade
1010
args:

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ To enable plotting also install the `plot` extra:
1919
pip install openeo-pg-parser-networkx[plot]
2020
```
2121

22-
Currently Python versions 3.10-3.12 are supported.
22+
Currently Python versions 3.10-3.14 are supported.
2323

2424
## Basic usage
2525
(An example notebook of using `openeo-pg-parser-networkx` together with a process implementation source like [`openeo-processes-dask`](https://github.com/Open-EO/openeo-processes-dask) can be found in `openeo-pg-parser-networkx/examples/01_minibackend_demo.ipynb`.)

openeo_pg_parser_networkx/pg_schema.py

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
)
2121
from pydantic import (
2222
BaseModel,
23-
Extra,
2423
Field,
2524
RootModel,
2625
StringConstraints,
@@ -57,12 +56,12 @@
5756
]
5857

5958

60-
class ResultReference(BaseModel, extra=Extra.forbid):
59+
class ResultReference(BaseModel, extra="forbid"):
6160
from_node: str
6261
node: ProcessNode
6362

6463

65-
class ParameterReference(BaseModel, extra=Extra.forbid):
64+
class ParameterReference(BaseModel, extra="forbid"):
6665
from_parameter: str
6766

6867

@@ -105,7 +104,7 @@ def __str__(self):
105104
return json.dumps(self.dict(), indent=4)
106105

107106

108-
class ProcessGraph(BaseModel, extra=Extra.forbid):
107+
class ProcessGraph(BaseModel, extra="forbid"):
109108
process_graph: dict[str, ProcessNode]
110109
uid: UUID = Field(default_factory=uuid4)
111110

@@ -115,7 +114,7 @@ class PGEdgeType(str, Enum):
115114
Callback = "callback"
116115

117116

118-
def parse_crs(v) -> pyproj.CRS:
117+
def parse_crs(v: Optional[Union[str, int]]) -> str:
119118
if not isinstance(v, int) and (v is None or v.strip() == ""):
120119
return DEFAULT_CRS
121120
else:
@@ -128,23 +127,19 @@ def parse_crs(v) -> pyproj.CRS:
128127
raise e
129128

130129

131-
def crs_validator(field: Union[str, int]) -> classmethod:
132-
decorator = validator(field, allow_reuse=True, pre=True, always=True)
133-
validator_func = decorator(parse_crs)
134-
return validator_func
135-
136-
137130
class BoundingBox(BaseModel, arbitrary_types_allowed=True):
138131
west: float
139132
east: float
140133
north: float
141134
south: float
142135
base: Optional[float] = None
143136
height: Optional[float] = None
144-
crs: Optional[Union[str, int]] = None
137+
crs: Optional[str] = Field(default=DEFAULT_CRS)
145138

146-
# validators
147-
_parse_crs: classmethod = crs_validator('crs')
139+
@field_validator("crs", mode="before")
140+
@classmethod
141+
def validate_crs(cls, v: Optional[Union[str, int]]) -> Optional[str]:
142+
return parse_crs(v)
148143

149144
@property
150145
def polygon(self) -> Polygon:

openeo_pg_parser_networkx/utils.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@
99

1010
def parse_nested_parameter(parameter: Any):
1111
try:
12-
return ResultReference.parse_obj(parameter)
12+
return ResultReference.model_validate(parameter)
1313
except pydantic.ValidationError:
1414
pass
1515
except TypeError:
1616
pass
1717

1818
try:
19-
return ParameterReference.parse_obj(parameter)
19+
return ParameterReference.model_validate(parameter)
2020
except pydantic.ValidationError:
2121
pass
2222
except TypeError:
@@ -236,17 +236,17 @@ def _generate_function_from_nodes(nodes: dict):
236236
if node_type == "array_element":
237237
value = ast.Subscript(
238238
value=ast.Name(id=operand1, ctx=ast.Load()),
239-
slice=ast.Index(value=ast.Num(n=int(operand2))),
239+
slice=ast.Constant(value=int(operand2)),
240240
ctx=ast.Load(),
241241
)
242242
elif node_type == "const":
243243
if isinstance(operand1, list):
244244
value = ast.List(
245-
elts=[ast.Num(n=n) for n in operand1],
245+
elts=[ast.Constant(value=n) for n in operand1],
246246
ctx=ast.Load(),
247247
)
248248
else:
249-
value = ast.Num(n=operand1)
249+
value = ast.Constant(value=operand1)
250250

251251
elif node_type == "variable":
252252
value = ast.Name(id=operand1, ctx=ast.Load())

pyproject.toml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,25 +17,26 @@ classifiers = [
1717
"Programming Language :: Python :: 3.11",
1818
"Programming Language :: Python :: 3.12",
1919
"Programming Language :: Python :: 3.13",
20+
"Programming Language :: Python :: 3.14",
2021
]
2122

2223
packages = [
2324
{ include = "openeo_pg_parser_networkx" }
2425
]
2526

2627
[tool.poetry.dependencies]
27-
python = ">=3.10,<3.14"
28+
python = ">=3.10,<3.15"
2829
pydantic = "^2.4.0"
29-
pyproj = "^3.4.0"
30+
pyproj = ">=3.4.0,<4.0"
3031
networkx = ">=3.0.0"
3132
geojson-pydantic = "^1.0.0"
3233
numpy = ">=1.20.3"
3334
pendulum = ">=3.0.0"
3435
matplotlib = { version = "^3.7.1", optional = true }
35-
traitlets = "<=5.13.0"
36+
traitlets = "<=5.14.4"
3637
yprov4wfs = ">=0.0.8"
3738
xarray = ">=2022.11.0"
38-
dask = ">=2023.4.0,<2025.2.0"
39+
dask = ">=2023.4.0"
3940

4041
[tool.poetry.group.dev.dependencies]
4142
matplotlib = "^3.7.1"

0 commit comments

Comments
 (0)