Merge branch 'main' into issue211
This commit is contained in:
commit
c8241b3da4
|
@ -7,9 +7,9 @@ jobs:
|
||||||
lint:
|
lint:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
- name: Setup Python
|
- name: Setup Python
|
||||||
uses: actions/setup-python@v4
|
uses: actions/setup-python@v5
|
||||||
with:
|
with:
|
||||||
python-version: '3.11'
|
python-version: '3.11'
|
||||||
cache: 'pip'
|
cache: 'pip'
|
||||||
|
@ -22,13 +22,13 @@ jobs:
|
||||||
test:
|
test:
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
python: ['3.7', '3.8', '3.9', '3.10', '3.11']
|
python: ['3.8', '3.9', '3.10', '3.11']
|
||||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
os: [ubuntu-latest, windows-latest, macos-latest]
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
- name: Setup Python
|
- name: Setup Python
|
||||||
uses: actions/setup-python@v4
|
uses: actions/setup-python@v5
|
||||||
with:
|
with:
|
||||||
python-version: ${{ matrix.python }}
|
python-version: ${{ matrix.python }}
|
||||||
cache: 'pip'
|
cache: 'pip'
|
||||||
|
|
|
@ -12,15 +12,16 @@ jobs:
|
||||||
name: Build source distribution
|
name: Build source distribution
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-22.04
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
- name: Build SDist and wheel
|
- name: Build SDist and wheel
|
||||||
run: pipx run build
|
run: pipx run build
|
||||||
|
|
||||||
- uses: actions/upload-artifact@v3
|
- uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
|
name: artifact
|
||||||
path: dist/*
|
path: dist/*
|
||||||
|
|
||||||
- name: Check metadata
|
- name: Check metadata
|
||||||
|
@ -30,7 +31,7 @@ jobs:
|
||||||
if: github.event_name == 'push'
|
if: github.event_name == 'push'
|
||||||
needs: [ build_dist ]
|
needs: [ build_dist ]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
- name: Set up Python
|
- name: Set up Python
|
||||||
|
@ -40,7 +41,7 @@ jobs:
|
||||||
cache: 'pip'
|
cache: 'pip'
|
||||||
- name: Install build dependencies
|
- name: Install build dependencies
|
||||||
run: pip install -U setuptools wheel build
|
run: pip install -U setuptools wheel build
|
||||||
- uses: actions/download-artifact@v3
|
- uses: actions/download-artifact@v4
|
||||||
with:
|
with:
|
||||||
# unpacks default artifact into dist/
|
# unpacks default artifact into dist/
|
||||||
# if `name: artifact` is omitted, the action will create extra parent dir
|
# if `name: artifact` is omitted, the action will create extra parent dir
|
||||||
|
|
|
@ -6,17 +6,17 @@ repos:
|
||||||
- id: end-of-file-fixer
|
- id: end-of-file-fixer
|
||||||
- id: check-toml
|
- id: check-toml
|
||||||
- repo: https://github.com/pycqa/isort
|
- repo: https://github.com/pycqa/isort
|
||||||
rev: 5.12.0
|
rev: 5.13.2
|
||||||
hooks:
|
hooks:
|
||||||
- id: isort
|
- id: isort
|
||||||
args: [ "--profile", "black", "--filter-files" ]
|
args: [ "--profile", "black", "--filter-files" ]
|
||||||
- repo: https://github.com/psf/black
|
- repo: https://github.com/psf/black
|
||||||
rev: 23.10.1
|
rev: 24.4.2
|
||||||
hooks:
|
hooks:
|
||||||
- id: black
|
- id: black
|
||||||
language_version: python3.11
|
language_version: python3.11
|
||||||
- repo: https://github.com/pre-commit/mirrors-mypy
|
- repo: https://github.com/pre-commit/mirrors-mypy
|
||||||
rev: v1.6.1
|
rev: v1.10.0
|
||||||
hooks:
|
hooks:
|
||||||
- id: mypy
|
- id: mypy
|
||||||
files: ^(cloudevents/)
|
files: ^(cloudevents/)
|
||||||
|
@ -24,4 +24,4 @@ repos:
|
||||||
types: [ python ]
|
types: [ python ]
|
||||||
args: [ ]
|
args: [ ]
|
||||||
additional_dependencies:
|
additional_dependencies:
|
||||||
- "pydantic"
|
- "pydantic~=2.7"
|
||||||
|
|
|
@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Dropped Python3.7 from CI while its EOL.
|
||||||
|
|
||||||
## [1.10.1]
|
## [1.10.1]
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
|
@ -12,22 +12,31 @@
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
from cloudevents.exceptions import PydanticFeatureNotInstalled
|
from cloudevents.exceptions import PydanticFeatureNotInstalled
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from pydantic import VERSION as PYDANTIC_VERSION
|
if TYPE_CHECKING:
|
||||||
|
from cloudevents.pydantic.v2 import CloudEvent, from_dict, from_http, from_json
|
||||||
pydantic_major_version = PYDANTIC_VERSION.split(".")[0]
|
|
||||||
if pydantic_major_version == "1":
|
|
||||||
from cloudevents.pydantic.v1 import CloudEvent, from_dict, from_http, from_json
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
from cloudevents.pydantic.v2 import ( # type: ignore
|
from pydantic import VERSION as PYDANTIC_VERSION
|
||||||
CloudEvent,
|
|
||||||
from_dict,
|
pydantic_major_version = PYDANTIC_VERSION.split(".")[0]
|
||||||
from_http,
|
if pydantic_major_version == "1":
|
||||||
from_json,
|
from cloudevents.pydantic.v1 import (
|
||||||
)
|
CloudEvent,
|
||||||
|
from_dict,
|
||||||
|
from_http,
|
||||||
|
from_json,
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
from cloudevents.pydantic.v2 import (
|
||||||
|
CloudEvent,
|
||||||
|
from_dict,
|
||||||
|
from_http,
|
||||||
|
from_json,
|
||||||
|
)
|
||||||
|
|
||||||
except ImportError: # pragma: no cover # hard to test
|
except ImportError: # pragma: no cover # hard to test
|
||||||
raise PydanticFeatureNotInstalled(
|
raise PydanticFeatureNotInstalled(
|
||||||
|
|
|
@ -51,53 +51,53 @@ class CloudEvent(abstract.CloudEvent, BaseModel): # type: ignore
|
||||||
data: typing.Optional[typing.Any] = Field(
|
data: typing.Optional[typing.Any] = Field(
|
||||||
title=FIELD_DESCRIPTIONS["data"].get("title"),
|
title=FIELD_DESCRIPTIONS["data"].get("title"),
|
||||||
description=FIELD_DESCRIPTIONS["data"].get("description"),
|
description=FIELD_DESCRIPTIONS["data"].get("description"),
|
||||||
example=FIELD_DESCRIPTIONS["data"].get("example"),
|
examples=[FIELD_DESCRIPTIONS["data"].get("example")],
|
||||||
default=None,
|
default=None,
|
||||||
)
|
)
|
||||||
source: str = Field(
|
source: str = Field(
|
||||||
title=FIELD_DESCRIPTIONS["source"].get("title"),
|
title=FIELD_DESCRIPTIONS["source"].get("title"),
|
||||||
description=FIELD_DESCRIPTIONS["source"].get("description"),
|
description=FIELD_DESCRIPTIONS["source"].get("description"),
|
||||||
example=FIELD_DESCRIPTIONS["source"].get("example"),
|
examples=[FIELD_DESCRIPTIONS["source"].get("example")],
|
||||||
)
|
)
|
||||||
id: str = Field(
|
id: str = Field(
|
||||||
title=FIELD_DESCRIPTIONS["id"].get("title"),
|
title=FIELD_DESCRIPTIONS["id"].get("title"),
|
||||||
description=FIELD_DESCRIPTIONS["id"].get("description"),
|
description=FIELD_DESCRIPTIONS["id"].get("description"),
|
||||||
example=FIELD_DESCRIPTIONS["id"].get("example"),
|
examples=[FIELD_DESCRIPTIONS["id"].get("example")],
|
||||||
default_factory=attribute.default_id_selection_algorithm,
|
default_factory=attribute.default_id_selection_algorithm,
|
||||||
)
|
)
|
||||||
type: str = Field(
|
type: str = Field(
|
||||||
title=FIELD_DESCRIPTIONS["type"].get("title"),
|
title=FIELD_DESCRIPTIONS["type"].get("title"),
|
||||||
description=FIELD_DESCRIPTIONS["type"].get("description"),
|
description=FIELD_DESCRIPTIONS["type"].get("description"),
|
||||||
example=FIELD_DESCRIPTIONS["type"].get("example"),
|
examples=[FIELD_DESCRIPTIONS["type"].get("example")],
|
||||||
)
|
)
|
||||||
specversion: attribute.SpecVersion = Field(
|
specversion: attribute.SpecVersion = Field(
|
||||||
title=FIELD_DESCRIPTIONS["specversion"].get("title"),
|
title=FIELD_DESCRIPTIONS["specversion"].get("title"),
|
||||||
description=FIELD_DESCRIPTIONS["specversion"].get("description"),
|
description=FIELD_DESCRIPTIONS["specversion"].get("description"),
|
||||||
example=FIELD_DESCRIPTIONS["specversion"].get("example"),
|
examples=[FIELD_DESCRIPTIONS["specversion"].get("example")],
|
||||||
default=attribute.DEFAULT_SPECVERSION,
|
default=attribute.DEFAULT_SPECVERSION,
|
||||||
)
|
)
|
||||||
time: typing.Optional[datetime.datetime] = Field(
|
time: typing.Optional[datetime.datetime] = Field(
|
||||||
title=FIELD_DESCRIPTIONS["time"].get("title"),
|
title=FIELD_DESCRIPTIONS["time"].get("title"),
|
||||||
description=FIELD_DESCRIPTIONS["time"].get("description"),
|
description=FIELD_DESCRIPTIONS["time"].get("description"),
|
||||||
example=FIELD_DESCRIPTIONS["time"].get("example"),
|
examples=[FIELD_DESCRIPTIONS["time"].get("example")],
|
||||||
default_factory=attribute.default_time_selection_algorithm,
|
default_factory=attribute.default_time_selection_algorithm,
|
||||||
)
|
)
|
||||||
subject: typing.Optional[str] = Field(
|
subject: typing.Optional[str] = Field(
|
||||||
title=FIELD_DESCRIPTIONS["subject"].get("title"),
|
title=FIELD_DESCRIPTIONS["subject"].get("title"),
|
||||||
description=FIELD_DESCRIPTIONS["subject"].get("description"),
|
description=FIELD_DESCRIPTIONS["subject"].get("description"),
|
||||||
example=FIELD_DESCRIPTIONS["subject"].get("example"),
|
examples=[FIELD_DESCRIPTIONS["subject"].get("example")],
|
||||||
default=None,
|
default=None,
|
||||||
)
|
)
|
||||||
datacontenttype: typing.Optional[str] = Field(
|
datacontenttype: typing.Optional[str] = Field(
|
||||||
title=FIELD_DESCRIPTIONS["datacontenttype"].get("title"),
|
title=FIELD_DESCRIPTIONS["datacontenttype"].get("title"),
|
||||||
description=FIELD_DESCRIPTIONS["datacontenttype"].get("description"),
|
description=FIELD_DESCRIPTIONS["datacontenttype"].get("description"),
|
||||||
example=FIELD_DESCRIPTIONS["datacontenttype"].get("example"),
|
examples=[FIELD_DESCRIPTIONS["datacontenttype"].get("example")],
|
||||||
default=None,
|
default=None,
|
||||||
)
|
)
|
||||||
dataschema: typing.Optional[str] = Field(
|
dataschema: typing.Optional[str] = Field(
|
||||||
title=FIELD_DESCRIPTIONS["dataschema"].get("title"),
|
title=FIELD_DESCRIPTIONS["dataschema"].get("title"),
|
||||||
description=FIELD_DESCRIPTIONS["dataschema"].get("description"),
|
description=FIELD_DESCRIPTIONS["dataschema"].get("description"),
|
||||||
example=FIELD_DESCRIPTIONS["dataschema"].get("example"),
|
examples=[FIELD_DESCRIPTIONS["dataschema"].get("example")],
|
||||||
default=None,
|
default=None,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
2
mypy.ini
2
mypy.ini
|
@ -1,6 +1,6 @@
|
||||||
[mypy]
|
[mypy]
|
||||||
plugins = pydantic.mypy
|
plugins = pydantic.mypy
|
||||||
python_version = 3.7
|
python_version = 3.8
|
||||||
|
|
||||||
pretty = True
|
pretty = True
|
||||||
show_error_context = True
|
show_error_context = True
|
||||||
|
|
1
setup.py
1
setup.py
|
@ -65,7 +65,6 @@ if __name__ == "__main__":
|
||||||
"Programming Language :: Python",
|
"Programming Language :: Python",
|
||||||
"Programming Language :: Python :: 3",
|
"Programming Language :: Python :: 3",
|
||||||
"Programming Language :: Python :: 3 :: Only",
|
"Programming Language :: Python :: 3 :: Only",
|
||||||
"Programming Language :: Python :: 3.7",
|
|
||||||
"Programming Language :: Python :: 3.8",
|
"Programming Language :: Python :: 3.8",
|
||||||
"Programming Language :: Python :: 3.9",
|
"Programming Language :: Python :: 3.9",
|
||||||
"Programming Language :: Python :: 3.10",
|
"Programming Language :: Python :: 3.10",
|
||||||
|
|
Loading…
Reference in New Issue