Skip to content

Commit

Permalink
Remove pydantic dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
seedofjoy committed Oct 30, 2022
1 parent 677500b commit 546c03f
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGES.rst
Expand Up @@ -3,6 +3,10 @@
Changelog
---------

0.11.1 (unreleased)
...................
* Remove ``pydantic`` dependency

0.11.0 (2022-08-03)
...................
* Added ability to optionally pass ``ctx`` to the task, like this:
Expand Down
2 changes: 1 addition & 1 deletion darq/cli.py
Expand Up @@ -6,11 +6,11 @@
from signal import Signals

import click
from pydantic.utils import import_string

from .app import Darq
from .logs import default_log_config
from .scheduler import run_scheduler
from .utils import import_string
from .version import __version__
from .worker import check_health
from .worker import create_worker
Expand Down
3 changes: 1 addition & 2 deletions darq/cron.py
Expand Up @@ -4,11 +4,10 @@
from datetime import datetime
from datetime import timedelta

from pydantic.utils import import_string

from .types import CoroutineType
from .types import DarqTask
from .utils import get_function_name
from .utils import import_string
from .utils import SecondsTimedelta
from .utils import to_seconds

Expand Down
23 changes: 23 additions & 0 deletions darq/utils.py
Expand Up @@ -20,6 +20,29 @@
SecondsTimedelta = Union[int, float, timedelta]


def import_string(dotted_path: str) -> Any:
"""
Stolen approximately from Django. Import a dotted module path and return
the attribute/class designated by the last name in the path.
Raise ImportError if the import fails.
"""
from importlib import import_module

try:
module_path, class_name = dotted_path.strip(' ').rsplit('.', 1)
except ValueError as e:
raise ImportError(
f'"{dotted_path}" doesn\'t look like a module path') from e

module = import_module(module_path)
try:
return getattr(module, class_name)
except AttributeError as e:
raise ImportError(
f'Module "{module_path}" does not define a "{class_name}" '
f'attribute') from e


def as_int(f: float) -> int:
return int(round(f))

Expand Down
1 change: 0 additions & 1 deletion setup.py
Expand Up @@ -47,7 +47,6 @@ def readfile(filename: str) -> str:
'async-timeout>=3.0.0, <5.0',
'aioredis>=1.1.0, <2.0',
'click>=6.7',
'pydantic>=0.20',
'typing_extensions>=4.0; python_version<"3.8"',
],
extras_require={
Expand Down

0 comments on commit 546c03f

Please sign in to comment.