Skip to content

Commit

Permalink
⬆ Upgrade to Pydantic V2 (#8)
Browse files Browse the repository at this point in the history
* pydantic

* latest poetry

* pydantic settings and python version

* setuptools bc pkg_resources

* black

* update publish

* add tomli
  • Loading branch information
rafalstapinski authored Feb 22, 2024
1 parent 869643c commit d336751
Show file tree
Hide file tree
Showing 7 changed files with 629 additions and 952 deletions.
6 changes: 2 additions & 4 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ jobs:
python-version: '3.10.0'

# Install poetry
- uses: abatilo/actions-poetry@v2.0.0
with:
poetry-version: "1.1.12"
- uses: abatilo/actions-poetry@v2.3.0

# Install deps
- run: poetry install
Expand All @@ -30,4 +28,4 @@ jobs:
- run: poetry build

# Publish
- run: poetry publish --username ${{ secrets.PYPI_USERNAME }} --password ${{ secrets.PYPI_PASSWORD }}
- run: poetry publish --username __token__ --password ${{ secrets.PYPI_TOKEN }}
6 changes: 2 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:

strategy:
matrix:
python-version: ["3.8", "3.9", "3.10"]
python-version: ["3.10", "3.11", "3.12"]
fail-fast: false

steps:
Expand All @@ -29,9 +29,7 @@ jobs:
python-version: ${{ matrix.python-version }}

- name: Install poetry
uses: abatilo/actions-poetry@v2.0.0
with:
poetry-version: "1.1.12"
uses: abatilo/actions-poetry@v2.3.0

- name: Install dependencies
run: poetry install
Expand Down
1,526 changes: 605 additions & 921 deletions poetry.lock

Large diffs are not rendered by default.

25 changes: 13 additions & 12 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,19 @@ repository = "https://github.com/rafalstapinski/redispatcher"
[tool.poetry.dependencies]
python = "^3.8"
aioredis = "^1.3.1"
pydantic = "^1.8.1"

[tool.poetry.dev-dependencies]
black = "^22.3.0"
pylint = "^2.13.5"
isort = "^5.10.1"
pytest = "^7.1.1"
elastic-apm = "^6.9.1"
mkdocs = "^1.3.0"
mkdocs-material = "^8.2.9"
pytest-redis = "^2.4.0"
pytest-asyncio = "^0.18.3"
pydantic = "^2.6.1"
pydantic-settings = "^2.2.1"

[tool.poetry.group.dev.dependencies]
black = "^24.2.0"
pylint = "^3.0.3"
isort = "^5.13.2"
pytest = "^8.0.1"
pytest-redis = "^3.0.2"
pytest-asyncio = "^0.23.5"
elastic-apm = "^6.20.0"
setuptools = "^69.1.0"
tomli = "^2.0.1"

[tool.poetry.scripts]
monitor = "redispatcher.monitor:monitor_cli"
Expand Down
3 changes: 2 additions & 1 deletion redispatcher/config.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from threading import Event
from typing import List, Optional, Type, Union

from pydantic import BaseModel, BaseSettings, RedisDsn
from pydantic import BaseModel, RedisDsn
from pydantic_settings import BaseSettings

from redispatcher.base_consumer import BaseConsumer
from redispatcher.types import LoggerType
Expand Down
12 changes: 4 additions & 8 deletions redispatcher/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
class RedispatcherException(Exception):
...
class RedispatcherException(Exception): ...


class UndefinedQueue(RedispatcherException):
...
class UndefinedQueue(RedispatcherException): ...


class UndefinedMessage(RedispatcherException):
...
class UndefinedMessage(RedispatcherException): ...


class InvalidConfig(RedispatcherException):
...
class InvalidConfig(RedispatcherException): ...
3 changes: 1 addition & 2 deletions test/fixtures/consumers.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ class Message(BaseConsumer.Message):
id: int
text: str

async def process_message(self, message: Message, headers: BaseConsumer.Headers):
...
async def process_message(self, message: Message, headers: BaseConsumer.Headers): ...


class ConsumerTwo(BaseConsumer):
Expand Down

0 comments on commit d336751

Please sign in to comment.