Skip to content

Commit

Permalink
Merge pull request #162 from SEKOIA-IO/feat/Pydantic2.0
Browse files Browse the repository at this point in the history
SDK: Move to Pydantic V2
  • Loading branch information
squioc authored Feb 5, 2025
2 parents e919f55 + 4947f3c commit 83f184e
Show file tree
Hide file tree
Showing 23 changed files with 1,396 additions and 1,412 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

## 1.18.3

### Changed

- Move to Pydantic V2 as dependency

## 1.18.2

### Changed
Expand Down
2,752 changes: 1,365 additions & 1,387 deletions poetry.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ build-backend = "poetry.core.masonry.api"
[tool.poetry]
name = "sekoia-automation-sdk"

version = "1.18.2"
version = "1.18.3"
description = "SDK to create Sekoia.io playbook modules"
license = "MIT"
readme = "README.md"
Expand Down Expand Up @@ -37,7 +37,7 @@ tenacity = "*"
boto3 = "<1.36"
s3path = "^0.5"
orjson = "^3.8"
pydantic = "^1.10"
pydantic = "^2.10"
typer = { extras = ["all"], version = "^0.12"}
cookiecutter = "^2.1"
python-slugify = "^5.0.2"
Expand Down
4 changes: 2 additions & 2 deletions sekoia_automation/action.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import orjson
import requests
import sentry_sdk
from pydantic import validate_arguments
from pydantic.v1 import validate_arguments
from requests import RequestException, Response
from tenacity import (
RetryError,
Expand Down Expand Up @@ -63,7 +63,7 @@ def __init__(self, module: Module | None = None, data_path: Path | None = None):
self._update_secrets = False
logging.getLogger().addHandler(ActionLogHandler(self))

# Make sure arguments are validated/coerced by pydantic
# Make sure arguments are validated/coerced by pydantic.v1
# if a type annotation is defined
self.run = validate_arguments()(self.run) # type: ignore

Expand Down
2 changes: 1 addition & 1 deletion sekoia_automation/aio/helpers/aws/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from aiobotocore.session import AioCredentials, AioSession, ClientCreatorContext
from botocore.credentials import CredentialProvider
from pydantic import BaseModel, Field
from pydantic.v1 import BaseModel, Field


class AwsConfiguration(BaseModel):
Expand Down
4 changes: 2 additions & 2 deletions sekoia_automation/aio/helpers/http/token_refresher.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
from typing import Generic, TypeVar

from aiohttp import ClientSession
from pydantic import BaseModel
from pydantic.generics import GenericModel
from pydantic.v1 import BaseModel
from pydantic.v1.generics import GenericModel

HttpTokenT = TypeVar("HttpTokenT", bound=BaseModel)

Expand Down
2 changes: 1 addition & 1 deletion sekoia_automation/connector/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import orjson
import requests
import sentry_sdk
from pydantic import BaseModel
from pydantic.v1 import BaseModel
from requests import Response
from tenacity import (
Retrying,
Expand Down
4 changes: 2 additions & 2 deletions sekoia_automation/http/aio/token_refresher.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
from typing import Generic, TypeVar

from aiohttp import ClientSession
from pydantic import BaseModel
from pydantic.generics import GenericModel
from pydantic.v1 import BaseModel
from pydantic.v1.generics import GenericModel

HttpTokenT = TypeVar("HttpTokenT", bound=BaseModel)

Expand Down
2 changes: 1 addition & 1 deletion sekoia_automation/http/rate_limiter.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Optional

from pydantic import BaseModel
from pydantic.v1 import BaseModel


class RateLimiterConfig(BaseModel):
Expand Down
2 changes: 1 addition & 1 deletion sekoia_automation/http/retry.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Optional

from pydantic import BaseModel
from pydantic.v1 import BaseModel


class RetryPolicy(BaseModel):
Expand Down
2 changes: 1 addition & 1 deletion sekoia_automation/loguru/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import sys

from loguru import logger
from pydantic import BaseModel, validator
from pydantic.v1 import BaseModel, validator

from .formatters import format_record
from .handlers import InterceptHandler
Expand Down
2 changes: 1 addition & 1 deletion sekoia_automation/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import requests
import sentry_sdk
from botocore.exceptions import ClientError
from pydantic import BaseModel
from pydantic.v1 import BaseModel
from requests import RequestException, Response

from sekoia_automation.config import load_config
Expand Down
2 changes: 1 addition & 1 deletion sekoia_automation/scripts/files_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from uuid import UUID, uuid5

import typer
from pydantic import BaseModel
from pydantic.v1 import BaseModel
from rich import print

from sekoia_automation.action import Action
Expand Down
2 changes: 1 addition & 1 deletion sekoia_automation/trigger.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import requests
import sentry_sdk
from botocore.exceptions import ClientError, ConnectionError, HTTPClientError
from pydantic import BaseModel
from pydantic.v1 import BaseModel
from requests import HTTPError
from tenacity import retry, stop_after_attempt, wait_exponential

Expand Down
2 changes: 1 addition & 1 deletion sekoia_automation/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from inspect import get_annotations, getmro

import sentry_sdk
from pydantic import BaseModel
from pydantic.v1 import BaseModel
from tenacity import RetryCallState


Expand Down
2 changes: 1 addition & 1 deletion tests/aio/helpers/http/test_http_client_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import pytest
from aioresponses import aioresponses
from pydantic import BaseModel
from pydantic.v1 import BaseModel

from sekoia_automation.aio.helpers.http.http_client import HttpClient
from sekoia_automation.aio.helpers.http.token_refresher import (
Expand Down
2 changes: 1 addition & 1 deletion tests/aio/helpers/http/test_http_token_refresher.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import pytest
from aioresponses import aioresponses
from pydantic import BaseModel
from pydantic.v1 import BaseModel

from sekoia_automation.aio.helpers.http.token_refresher import (
GenericTokenRefresher,
Expand Down
2 changes: 1 addition & 1 deletion tests/data/sample_module/sample.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from pydantic import BaseModel, Field
from pydantic.v1 import BaseModel, Field

from sekoia_automation.action import Action
from sekoia_automation.connector import Connector
Expand Down
2 changes: 1 addition & 1 deletion tests/http/aio/test_http_token_refresher.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import pytest
from aioresponses import aioresponses
from pydantic import BaseModel
from pydantic.v1 import BaseModel

from sekoia_automation.http.aio.token_refresher import (
GenericTokenRefresher,
Expand Down
2 changes: 1 addition & 1 deletion tests/loguru/test_loguru_config.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Config tests."""

import pytest
from pydantic import ValidationError
from pydantic.v1 import ValidationError

from sekoia_automation.loguru.config import LoggingConfig

Expand Down
2 changes: 1 addition & 1 deletion tests/test_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import pytest
import requests_mock
from pydantic import BaseModel, ValidationError
from pydantic.v1 import BaseModel, ValidationError

# third parties
from requests import Timeout
Expand Down
2 changes: 1 addition & 1 deletion tests/test_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

# third parties
import pytest
from pydantic import BaseModel
from pydantic.v1 import BaseModel
from sentry_sdk import get_isolation_scope

# internal
Expand Down
2 changes: 1 addition & 1 deletion tests/test_trigger.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import requests
import requests_mock
from botocore.exceptions import ClientError, ConnectionError
from pydantic import BaseModel
from pydantic.v1 import BaseModel
from tenacity import wait_none

from sekoia_automation.exceptions import (
Expand Down

0 comments on commit 83f184e

Please sign in to comment.