Skip to content

Commit

Permalink
Merge pull request #194 from Deltares/feat/GEOLIB-219-Force-Pydantic-v2
Browse files Browse the repository at this point in the history
Feat/geolib 219 force pydantic v2 (restored)
  • Loading branch information
wfaustmann authored Aug 12, 2024
2 parents 33ca087 + 55c3bd4 commit 607caf3
Show file tree
Hide file tree
Showing 8 changed files with 122 additions and 182 deletions.
60 changes: 0 additions & 60 deletions .github/workflows/CI-v1.yml

This file was deleted.

4 changes: 2 additions & 2 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: ci-pydantic-v2
name: ci

on:
push:
Expand Down Expand Up @@ -45,7 +45,7 @@ jobs:
poetry config virtualenvs.path ~/.virtualenvs
- name: Install Dependencies
run: poetry install -E server -E pydantic-v2
run: poetry install -E server

- name: Test with pytest
run: poetry run pytest --cov=geolib --cov-report xml:coverage-reports/coverage-hydrolib-core.xml --junitxml=xunit-reports/xunit-result-hydrolib-core.xml -m "unittest and not workinprogress"
14 changes: 0 additions & 14 deletions docs/user/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,6 @@ This package, unlike GEOLib+, tries to limit the number of

You don't need to install anything manually, as the pip installation should take care of it.

Combining GEOLib with pydantic v2
---------------------------------

GEOLib uses pydantic for validation of types and some parameters (min/max/defaults). The
latest version of pydantic (v2) has some breaking changes. When using pydantic v2, some
extra dependencies are required.To use GEOLib with pydantic v2, you can use the following
command to automatically install the extra dependencies::

$ pip install d-geolib[pydantic-v2]

When the extra dependencies are not installed, and pydantic v2 is used, an error will be
thrown when trying to import GEOLib. The error message will guide you in installing the
required packages yourself.

Get the Source Code
-------------------

Expand Down
21 changes: 0 additions & 21 deletions geolib/_compat.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,3 @@
"""This module contaiuns the logic to support both pydantic v1 and v2
"""
from pydantic import VERSION as PYDANTIC_VERSION

IS_PYDANTIC_V2 = PYDANTIC_VERSION.startswith("2.")

if IS_PYDANTIC_V2:
try:
from pydantic_extra_types.color import Color
from pydantic_settings import BaseSettings
except ImportError:
raise ImportError(
"Please install `pydantic-settings` and `pydantic-extra-types` to use geolib with "
"pydantic v2 with `pip install pydantic-settings pydantic-extra-types`. Alternatively, "
"you can install geolib with the extra required packages by running `pip install "
"geolib[pydantic-v2]`."
)
else:
# Example of how to raise a DeprecationWarning. Should be enabled when it is decided to remove
# support for pydantic v1 in a future release.
# raise DeprecationWarning(
# "Support for pydantic v1 will be removed in the next major release. Please upgrade to pydantic v2."
# )
pass
7 changes: 3 additions & 4 deletions poetry.lock

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

7 changes: 3 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ packages = [{ include = "geolib" }]

[tool.poetry.dependencies]
python = ">=3.9,<3.13"
pydantic = ">=1.10.7"
pydantic = "^2.0.0"
zipp = "^3.15.0"
fastapi = { version = ">=0.95.1", optional = true }
uvicorn = { version = "^0.21.1", optional = true }
Expand All @@ -22,8 +22,8 @@ httpx = { version = "^0.24.0", optional = true }
shapely = "^2.0.1"
python-dotenv = "^1.0.0"
matplotlib = "3.9.0"
pydantic-settings = { version = "^2.1.0", optional = true }
pydantic-extra-types = { version = "^2.5.0", optional = true }
pydantic-settings = "^2.1.0"
pydantic-extra-types = "^2.5.0"
python-multipart = "^0.0.9"

[tool.poetry.group.dev.dependencies]
Expand All @@ -45,7 +45,6 @@ tomlkit = "^0.11.8"

[tool.poetry.extras]
server = ["fastapi", "uvicorn", "httpx", "starlette"]
pydantic-v2 = ["pydantic-settings", "pydantic-extra-types"]

[tool.poetry.scripts]
geolib_server = "geolib.service.main:app"
Expand Down
119 changes: 68 additions & 51 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,85 +1,102 @@
alabaster==0.7.13 ; python_version >= "3.9" and python_version < "3.13"
anyio==4.0.0 ; python_version >= "3.9" and python_version < "3.13"
argcomplete==3.1.6 ; python_version >= "3.9" and python_version < "3.13"
alabaster==0.7.16 ; python_version >= "3.9" and python_version < "3.13"
annotated-types==0.7.0 ; python_version >= "3.9" and python_version < "3.13"
anyio==4.4.0 ; python_version >= "3.9" and python_version < "3.13"
argcomplete==3.4.0 ; python_version >= "3.9" and python_version < "3.13"
asttokens==2.4.1 ; python_version >= "3.9" and python_version < "3.13"
babel==2.13.1 ; python_version >= "3.9" and python_version < "3.13"
black==23.11.0 ; python_version >= "3.9" and python_version < "3.13"
certifi==2023.7.22 ; python_version >= "3.9" and python_version < "3.13"
babel==2.15.0 ; python_version >= "3.9" and python_version < "3.13"
black==23.12.1 ; python_version >= "3.9" and python_version < "3.13"
certifi==2024.7.4 ; python_version >= "3.9" and python_version < "3.13"
charset-normalizer==3.3.2 ; python_version >= "3.9" and python_version < "3.13"
click==8.1.7 ; python_version >= "3.9" and python_version < "3.13"
colorama==0.4.6 ; python_version >= "3.9" and python_version < "3.13"
commitizen==3.12.0 ; python_version >= "3.9" and python_version < "3.13"
commitizen==3.28.0 ; python_version >= "3.9" and python_version < "3.13"
commonmark==0.9.1 ; python_version >= "3.9" and python_version < "3.13"
contourpy==1.2.0 ; python_version >= "3.9" and python_version < "3.13"
coverage[toml]==7.3.2 ; python_version >= "3.9" and python_version < "3.13"
contourpy==1.2.1 ; python_version >= "3.9" and python_version < "3.13"
coverage[toml]==7.6.0 ; python_version >= "3.9" and python_version < "3.13"
cycler==0.12.1 ; python_version >= "3.9" and python_version < "3.13"
decli==0.6.1 ; python_version >= "3.9" and python_version < "3.13"
decli==0.6.2 ; python_version >= "3.9" and python_version < "3.13"
devtools==0.11.0 ; python_version >= "3.9" and python_version < "3.13"
docutils==0.20.1 ; python_version >= "3.9" and python_version < "3.13"
exceptiongroup==1.1.3 ; python_version >= "3.9" and python_version < "3.11"
dnspython==2.6.1 ; python_version >= "3.9" and python_version < "3.13"
docutils==0.21.2 ; python_version >= "3.9" and python_version < "3.13"
email-validator==2.2.0 ; python_version >= "3.9" and python_version < "3.13"
exceptiongroup==1.2.2 ; python_version >= "3.9" and python_version < "3.11"
executing==2.0.1 ; python_version >= "3.9" and python_version < "3.13"
fastapi==0.95.1 ; python_version >= "3.9" and python_version < "3.13"
fastapi-cli==0.0.4 ; python_version >= "3.9" and python_version < "3.13"
fastapi==0.111.1 ; python_version >= "3.9" and python_version < "3.13"
flake8==6.1.0 ; python_version >= "3.9" and python_version < "3.13"
fonttools==4.44.1 ; python_version >= "3.9" and python_version < "3.13"
fonttools==4.53.1 ; python_version >= "3.9" and python_version < "3.13"
h11==0.14.0 ; python_version >= "3.9" and python_version < "3.13"
httpcore==0.17.3 ; python_version >= "3.9" and python_version < "3.13"
httptools==0.6.1 ; python_version >= "3.9" and python_version < "3.13"
httpx==0.24.1 ; python_version >= "3.9" and python_version < "3.13"
idna==3.4 ; python_version >= "3.9" and python_version < "3.13"
idna==3.7 ; python_version >= "3.9" and python_version < "3.13"
imagesize==1.4.1 ; python_version >= "3.9" and python_version < "3.13"
importlib-metadata==6.8.0 ; python_version >= "3.9" and python_version < "3.13"
importlib-resources==6.1.1 ; python_version >= "3.9" and python_version < "3.10"
importlib-metadata==8.0.0 ; python_version >= "3.9" and python_version < "3.10"
importlib-resources==6.4.0 ; python_version >= "3.9" and python_version < "3.10"
iniconfig==2.0.0 ; python_version >= "3.9" and python_version < "3.13"
isort==5.12.0 ; python_version >= "3.9" and python_version < "3.13"
jinja2==3.1.3 ; python_version >= "3.9" and python_version < "3.13"
isort==5.13.2 ; python_version >= "3.9" and python_version < "3.13"
jinja2==3.1.4 ; python_version >= "3.9" and python_version < "3.13"
kiwisolver==1.4.5 ; python_version >= "3.9" and python_version < "3.13"
markupsafe==2.1.3 ; python_version >= "3.9" and python_version < "3.13"
matplotlib==3.8.1 ; python_version >= "3.9" and python_version < "3.13"
markdown-it-py==3.0.0 ; python_version >= "3.9" and python_version < "3.13"
markupsafe==2.1.5 ; python_version >= "3.9" and python_version < "3.13"
matplotlib==3.9.1 ; python_version >= "3.9" and python_version < "3.13"
mccabe==0.7.0 ; python_version >= "3.9" and python_version < "3.13"
mdurl==0.1.2 ; python_version >= "3.9" and python_version < "3.13"
mypy-extensions==1.0.0 ; python_version >= "3.9" and python_version < "3.13"
mypy==1.7.0 ; python_version >= "3.9" and python_version < "3.13"
numpy==1.26.2 ; python_version >= "3.9" and python_version < "3.13"
packaging==23.2 ; python_version >= "3.9" and python_version < "3.13"
pathspec==0.11.2 ; python_version >= "3.9" and python_version < "3.13"
pillow==10.2.0 ; python_version >= "3.9" and python_version < "3.13"
platformdirs==4.0.0 ; python_version >= "3.9" and python_version < "3.13"
pluggy==1.3.0 ; python_version >= "3.9" and python_version < "3.13"
mypy==1.11.0 ; python_version >= "3.9" and python_version < "3.13"
numpy==2.0.1 ; python_version >= "3.9" and python_version < "3.13"
packaging==24.1 ; python_version >= "3.9" and python_version < "3.13"
pathspec==0.12.1 ; python_version >= "3.9" and python_version < "3.13"
pillow==10.4.0 ; python_version >= "3.9" and python_version < "3.13"
platformdirs==4.2.2 ; python_version >= "3.9" and python_version < "3.13"
pluggy==1.5.0 ; python_version >= "3.9" and python_version < "3.13"
prompt-toolkit==3.0.36 ; python_version >= "3.9" and python_version < "3.13"
pycodestyle==2.11.1 ; python_version >= "3.9" and python_version < "3.13"
pydantic==1.10.13 ; python_version >= "3.9" and python_version < "3.13"
pydantic-core==2.20.1 ; python_version >= "3.9" and python_version < "3.13"
pydantic-extra-types==2.9.0 ; python_version >= "3.9" and python_version < "3.13"
pydantic-settings==2.3.4 ; python_version >= "3.9" and python_version < "3.13"
pydantic==2.8.2 ; python_version >= "3.9" and python_version < "3.13"
pyflakes==3.1.0 ; python_version >= "3.9" and python_version < "3.13"
pygments==2.16.1 ; python_version >= "3.9" and python_version < "3.13"
pyparsing==3.1.1 ; python_version >= "3.9" and python_version < "3.13"
pygments==2.18.0 ; python_version >= "3.9" and python_version < "3.13"
pyparsing==3.1.2 ; python_version >= "3.9" and python_version < "3.13"
pytest-cov==4.1.0 ; python_version >= "3.9" and python_version < "3.13"
pytest==7.4.3 ; python_version >= "3.9" and python_version < "3.13"
python-dateutil==2.8.2 ; python_version >= "3.9" and python_version < "3.13"
python-dotenv==1.0.0 ; python_version >= "3.9" and python_version < "3.13"
pytest==7.4.4 ; python_version >= "3.9" and python_version < "3.13"
python-dateutil==2.9.0.post0 ; python_version >= "3.9" and python_version < "3.13"
python-dotenv==1.0.1 ; python_version >= "3.9" and python_version < "3.13"
python-multipart==0.0.9 ; python_version >= "3.9" and python_version < "3.13"
pyyaml==6.0.1 ; python_version >= "3.9" and python_version < "3.13"
questionary==2.0.1 ; python_version >= "3.9" and python_version < "3.13"
recommonmark==0.7.1 ; python_version >= "3.9" and python_version < "3.13"
releases==2.1.1 ; python_version >= "3.9" and python_version < "3.13"
requests==2.31.0 ; python_version >= "3.9" and python_version < "3.13"
requests==2.32.3 ; python_version >= "3.9" and python_version < "3.13"
rich==13.7.1 ; python_version >= "3.9" and python_version < "3.13"
semantic-version==2.6.0 ; python_version >= "3.9" and python_version < "3.13"
setuptools==68.2.2 ; python_version >= "3.12" and python_version < "3.13"
shapely==2.0.2 ; python_version >= "3.9" and python_version < "3.13"
shapely==2.0.5 ; python_version >= "3.9" and python_version < "3.13"
shellingham==1.5.4 ; python_version >= "3.9" and python_version < "3.13"
six==1.16.0 ; python_version >= "3.9" and python_version < "3.13"
sniffio==1.3.0 ; python_version >= "3.9" and python_version < "3.13"
sniffio==1.3.1 ; python_version >= "3.9" and python_version < "3.13"
snowballstemmer==2.2.0 ; python_version >= "3.9" and python_version < "3.13"
sphinx-autodoc-typehints==1.25.2 ; python_version >= "3.9" and python_version < "3.13"
sphinx-autodoc-typehints==1.25.3 ; python_version >= "3.9" and python_version < "3.13"
sphinx-multiversion==0.2.4 ; python_version >= "3.9" and python_version < "3.13"
sphinx==7.2.6 ; python_version >= "3.9" and python_version < "3.13"
sphinxcontrib-applehelp==1.0.7 ; python_version >= "3.9" and python_version < "3.13"
sphinxcontrib-devhelp==1.0.5 ; python_version >= "3.9" and python_version < "3.13"
sphinxcontrib-htmlhelp==2.0.4 ; python_version >= "3.9" and python_version < "3.13"
sphinx==7.4.7 ; python_version >= "3.9" and python_version < "3.13"
sphinxcontrib-applehelp==1.0.8 ; python_version >= "3.9" and python_version < "3.13"
sphinxcontrib-devhelp==1.0.6 ; python_version >= "3.9" and python_version < "3.13"
sphinxcontrib-htmlhelp==2.0.6 ; python_version >= "3.9" and python_version < "3.13"
sphinxcontrib-jsmath==1.0.1 ; python_version >= "3.9" and python_version < "3.13"
sphinxcontrib-qthelp==1.0.6 ; python_version >= "3.9" and python_version < "3.13"
sphinxcontrib-serializinghtml==1.1.9 ; python_version >= "3.9" and python_version < "3.13"
starlette==0.26.1 ; python_version >= "3.9" and python_version < "3.13"
sphinxcontrib-qthelp==1.0.8 ; python_version >= "3.9" and python_version < "3.13"
sphinxcontrib-serializinghtml==1.1.10 ; python_version >= "3.9" and python_version < "3.13"
starlette==0.37.2 ; python_version >= "3.9" and python_version < "3.13"
teamcity-messages==1.32 ; python_version >= "3.9" and python_version < "3.13"
termcolor==2.3.0 ; python_version >= "3.9" and python_version < "3.13"
termcolor==2.4.0 ; python_version >= "3.9" and python_version < "3.13"
tomli==2.0.1 ; python_version >= "3.9" and python_full_version <= "3.11.0a6"
tomlkit==0.11.8 ; python_version >= "3.9" and python_version < "3.13"
typing-extensions==4.8.0 ; python_version >= "3.9" and python_version < "3.13"
urllib3==2.1.0 ; python_version >= "3.9" and python_version < "3.13"
typer==0.12.3 ; python_version >= "3.9" and python_version < "3.13"
typing-extensions==4.12.2 ; python_version >= "3.9" and python_version < "3.13"
urllib3==2.2.2 ; python_version >= "3.9" and python_version < "3.13"
uvicorn==0.21.1 ; python_version >= "3.9" and python_version < "3.13"
wcwidth==0.2.10 ; python_version >= "3.9" and python_version < "3.13"
zipp==3.17.0 ; python_version >= "3.9" and python_version < "3.13"
uvicorn[standard]==0.21.1 ; python_version >= "3.9" and python_version < "3.13"
uvloop==0.19.0 ; sys_platform != "win32" and sys_platform != "cygwin" and platform_python_implementation != "PyPy" and python_version >= "3.9" and python_version < "3.13"
watchfiles==0.22.0 ; python_version >= "3.9" and python_version < "3.13"
wcwidth==0.2.13 ; python_version >= "3.9" and python_version < "3.13"
websockets==12.0 ; python_version >= "3.9" and python_version < "3.13"
zipp==3.19.2 ; python_version >= "3.9" and python_version < "3.13"
Loading

0 comments on commit 607caf3

Please sign in to comment.