From ca251a5c56bba99953f7528c493e18394a7b22fe Mon Sep 17 00:00:00 2001 From: sanix-darker Date: Wed, 17 Jan 2024 03:51:14 +0100 Subject: [PATCH 1/3] feat: remove the temp patch to fully support pydantic V2 --- .github/workflows/ci.yml | 25 ------------------------- peakina/datasource.py | 37 +++++++++---------------------------- 2 files changed, 9 insertions(+), 53 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4e56d507..26da190a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,9 +10,6 @@ jobs: python-version: - "3.10" - "3.11" - pydantic-version: - - "^1.10" - - "^2.0" steps: - uses: actions/checkout@v4 @@ -24,15 +21,6 @@ jobs: - name: install_system_deps run: sudo make install_system_deps - - name: Update Pydantic version on the toml & lock - run: | - pip install -U pip poetry - # we update the pydantic version corresponding to the matrix - sed -i "s/pydantic = \".*\"/pydantic = \"${PYDANTIC_VERSION}\"/" pyproject.toml - poetry lock --no-update - env: - PYDANTIC_VERSION: ${{ matrix.pydantic-version }} - - name: install run: make install @@ -49,9 +37,6 @@ jobs: python-version: - "3.10" - "3.11" - pydantic-version: - - "^1.10" - - "^2.0" steps: - uses: actions/checkout@v4 @@ -63,15 +48,6 @@ jobs: - name: install_system_deps run: sudo make install_system_deps - - name: Update Pydantic version on the toml & lock - run: | - pip install -U pip poetry - # we update the pydantic version corresponding to the matrix - sed -i "s/pydantic = \".*\"/pydantic = \"${PYDANTIC_VERSION}\"/" pyproject.toml - poetry lock --no-update - env: - PYDANTIC_VERSION: ${{ matrix.pydantic-version }} - - name: install run: make install @@ -79,7 +55,6 @@ jobs: run: make test env: FTP_PATH: ${{ secrets.FTP_PATH }} - PYDANTIC_VERSION: ${{ matrix.pydantic-version }} - name: Upload coverage uses: codecov/codecov-action@v3 diff --git a/peakina/datasource.py b/peakina/datasource.py index 5bbfad6f..1fa58b4c 100644 --- a/peakina/datasource.py +++ b/peakina/datasource.py @@ -13,7 +13,7 @@ from urllib.parse import urlparse, uses_netloc, uses_params, uses_relative import pandas as pd -from pydantic import ConfigDict, __version__ as pydantic_version +from pydantic import ConfigDict from pydantic.dataclasses import dataclass from slugify import slugify @@ -36,9 +36,6 @@ PD_VALID_URLS = set(uses_relative + uses_netloc + uses_params) | AVAILABLE_SCHEMES -_PYDANTIC_VERSION_ONE = pydantic_version.startswith("1.") - - @dataclass class DataSource: uri: str @@ -48,33 +45,17 @@ class DataSource: reader_kwargs: dict[str, Any] = field(default_factory=dict) fetcher_kwargs: dict[str, Any] = field(default_factory=dict) - # TODO: This is temporary, in the future we will only support V2 - # and get rid of this condition + update the CI (link/test) - if _PYDANTIC_VERSION_ONE: - - def __post_init_post_parse__(self) -> None: - self._fetcher: Fetcher | None = None - self.scheme = urlparse(self.uri).scheme - if self.scheme not in PD_VALID_URLS: - raise AttributeError(f"Invalid scheme {self.scheme!r}") - - self.type = self.type or detect_type(urlparse(self.uri).path, is_regex=bool(self.match)) - - validate_kwargs(self.reader_kwargs, self.type) - - else: - - def __post_init__(self) -> None: - self._fetcher: Fetcher | None = None # type: ignore[no-redef] - self.scheme = urlparse(self.uri).scheme - if self.scheme not in PD_VALID_URLS: - raise AttributeError(f"Invalid scheme {self.scheme!r}") + def __post_init__(self) -> None: + self._fetcher: Fetcher | None = None + self.scheme = urlparse(self.uri).scheme + if self.scheme not in PD_VALID_URLS: + raise AttributeError(f"Invalid scheme {self.scheme!r}") - self.type = self.type or detect_type(urlparse(self.uri).path, is_regex=bool(self.match)) + self.type = self.type or detect_type(urlparse(self.uri).path, is_regex=bool(self.match)) - validate_kwargs(self.reader_kwargs, self.type) + validate_kwargs(self.reader_kwargs, self.type) - model_config = ConfigDict(arbitrary_types_allowed=True) + model_config = ConfigDict(arbitrary_types_allowed=True) @property def fetcher(self) -> Fetcher: From b7827c75a38f0161c237c18bf0e4fba08a89f100 Mon Sep 17 00:00:00 2001 From: sanix-darker Date: Wed, 17 Jan 2024 03:56:17 +0100 Subject: [PATCH 2/3] chore(deps): fully support for pydantic v2 --- poetry.lock | 3 ++- pyproject.toml | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/poetry.lock b/poetry.lock index 77088b07..75d8c083 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1023,6 +1023,7 @@ files = [ {file = "jq-1.6.0-cp37-cp37m-musllinux_1_1_i686.whl", hash = "sha256:227b178b22a7f91ae88525810441791b1ca1fc71c86f03190911793be15cec3d"}, {file = "jq-1.6.0-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:780eb6383fbae12afa819ef676fc93e1548ae4b076c004a393af26a04b460742"}, {file = "jq-1.6.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:08ded6467f4ef89fec35b2bf310f210f8cd13fbd9d80e521500889edf8d22441"}, + {file = "jq-1.6.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:49e44ed677713f4115bd5bf2dbae23baa4cd503be350e12a1c1f506b0687848f"}, {file = "jq-1.6.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:984f33862af285ad3e41e23179ac4795f1701822473e1a26bf87ff023e5a89ea"}, {file = "jq-1.6.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:f42264fafc6166efb5611b5d4cb01058887d050a6c19334f6a3f8a13bb369df5"}, {file = "jq-1.6.0-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:a67154f150aaf76cc1294032ed588436eb002097dd4fd1e283824bf753a05080"}, @@ -2946,4 +2947,4 @@ multidict = ">=4.0" [metadata] lock-version = "2.0" python-versions = "^3.10" -content-hash = "f88563264b2f3e180c150d9c1e2e94e8e2ab0a5caeb7b259821e7eaffc18582c" +content-hash = "c531830e2d9ef5311be6c8879a5b33a4f053eca4f6b40408f087bfb8885c37a1" diff --git a/pyproject.toml b/pyproject.toml index 306c1739..9243e6e5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -23,7 +23,7 @@ chardet = ">=4,<6" jq = "^1.2.1" pandas = ">=1.5.3,<3.0.0" paramiko = ">=2.9.2,<4.0.0" -pydantic = ">=1.9,<3.0" +pydantic = "^2.4.2" python-slugify = ">=5.0.2,<9.0.0" s3fs = ">=2022.1,<2024.0" tables = "^3.7.0" From 0db0a7f4ed84e0ef4464135c664eb56536def541 Mon Sep 17 00:00:00 2001 From: sanix-darker Date: Wed, 17 Jan 2024 03:58:48 +0100 Subject: [PATCH 3/3] chore: add CHANGELOG info --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6dbe15be..9ac81df6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +### Changed + +- Drop support for pydantic V1. + ## [0.12.1] - 2023-11-15 ### Fixed