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

Pydantic >= 2.0 compatibility #5

Merged
merged 2 commits into from
May 17, 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
8 changes: 6 additions & 2 deletions .github/workflows/vulnerabilities.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ jobs:
run:
working-directory: .
steps:
- id: string
uses: ASzc/change-string-case-action
with:
string: ${{ github.repository }}
- name: Checkout pygeoapi
uses: actions/checkout@v4
- name: Scan vulnerabilities with trivy
Expand All @@ -34,7 +38,7 @@ jobs:
scan-ref: .
- name: Build locally the image from Dockerfile
run: |
docker buildx build -t ${{ github.repository }}:${{ github.sha }} --platform linux/amd64 --no-cache -f Dockerfile .
docker buildx build -t ${{ steps.string.outputs.lowercase }}:${{ github.sha }} --platform linux/amd64 --no-cache -f Dockerfile .
- name: Scan locally built Docker image for vulnerabilities with trivy
uses: aquasecurity/trivy-action@master
with:
Expand All @@ -43,4 +47,4 @@ jobs:
ignore-unfixed: true
severity: CRITICAL,HIGH
vuln-type: os,library
image-ref: '${{ github.repository }}:${{ github.sha }}'
image-ref: '${{ steps.string.outputs.lowercase }}:${{ github.sha }}'
6 changes: 5 additions & 1 deletion pygeoapi/models/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@
#
# =================================================================

from pydantic import BaseModel, Field
try:
from pydantic.v1 import BaseModel, Field
except ModuleNotFoundError:
# Pydantic version < 2.0
from pydantic import BaseModel, Field


class APIRules(BaseModel):
Expand Down
6 changes: 5 additions & 1 deletion pygeoapi/models/cql.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@
from datetime import date, datetime
from typing import Any, List, Literal, Optional, Union

from pydantic import BaseModel, Field
try:
from pydantic.v1 import BaseModel, Field
except ModuleNotFoundError:
# Pydantic version < 2.0
from pydantic import BaseModel, Field


class CQLModel(BaseModel):
Expand Down
6 changes: 5 additions & 1 deletion pygeoapi/models/openapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@

from enum import Enum

from pydantic import BaseModel
try:
from pydantic.v1 import BaseModel, Field
except ModuleNotFoundError:
# Pydantic version < 2.0
from pydantic import BaseModel, Field


class SupportedFormats(Enum):
Expand Down
6 changes: 5 additions & 1 deletion pygeoapi/models/provider/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@
from enum import Enum
from typing import List, Optional

from pydantic import BaseModel
try:
from pydantic.v1 import BaseModel
except ModuleNotFoundError:
# Pydantic version < 2.0
from pydantic import BaseModel


class TilesMetadataFormat(str, Enum):
Expand Down
6 changes: 5 additions & 1 deletion pygeoapi/models/provider/mvt.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@
#
# =================================================================

from pydantic import BaseModel
try:
from pydantic.v1 import BaseModel
except ModuleNotFoundError:
# Pydantic version < 2.0
from pydantic import BaseModel
from typing import List, Optional


Expand Down
2 changes: 1 addition & 1 deletion requirements-django.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Django
pydantic<2.0
pydantic
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ filelock
Flask
jinja2
jsonschema
pydantic<2.0
pydantic
pygeofilter
pygeoif
pyproj
Expand Down
Loading