Skip to content

Commit 95ed152

Browse files
redjaxredjax
and
redjax
authored
refactor(submodules): Refactor all submodules (#222) (#224)
* Topic/db utils (#220) * feat(pyproject): Update pyproject & pdm lockfile (#217) Co-authored-by: redjax <[email protected]> * Feat/add db utils (#219) * feat(pyproject): Update pyproject & pdm lockfile (#216) Co-authored-by: redjax <[email protected]> * feat(db-utils): Add db utils Add utilities for SQLAlchemy. Add connection models (dataclasses) Add SQLAlchemy utils (i.e. get_engine(), get_session()) Add declartive Base object --------- Co-authored-by: redjax <[email protected]> --------- Co-authored-by: redjax <[email protected]> * refactor(submodules): Refactor all submodules (#222) Remove PDM package definitions. Submodules are modules, not Python packages. Add some missing imports Add docstrings & comments Co-authored-by: redjax <[email protected]> --------- Co-authored-by: redjax <[email protected]>
1 parent 5bf8908 commit 95ed152

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+147
-2874
lines changed

red_utils/__init__.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import pkgutil
44

5-
## Import modules with only stdblit dependencies directly
5+
## Import modules with only stdlib dependencies directly
66
from .context_managers import DictProtect, ListProtect, async_benchmark, benchmark
77
from .dict_utils import debug_dict, merge_dicts, update_dict, validate_dict
88
from .file_utils import crawl_dir, default_json_dir, export_json, ts
@@ -23,6 +23,8 @@
2323
trim_uuid,
2424
)
2525

26+
## Use pkgutil to only load modules
27+
# if dependencies are met
2628
if pkgutil.find_loader("diskcache"):
2729
from . import diskcache_utils
2830

@@ -39,3 +41,6 @@
3941
if pkgutil.find_loader("fastapi"):
4042
if pkgutil.find_loader("uvicorn"):
4143
from . import fastapi_utils
44+
45+
if pkgutil.find_loader("sqlalchemy"):
46+
from . import sqlalchemy_utils

red_utils/context_managers/benchmarks/fn_benchmarks.py

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
from contextlib import asynccontextmanager, contextmanager
44
import time
55

6-
76
@contextmanager
87
def benchmark(description: str = "Unnamed function timer") -> None:
98
"""Time a function call.

red_utils/context_managers/object_managers/protect.py

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import inspect
55
import json
66

7-
87
class ListProtect:
98
"""Protect a list during modification by modifying a copy instead of the original.
109

red_utils/dict_utils/.gitignore

-162
This file was deleted.

red_utils/dict_utils/__init__.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
from __future__ import annotations
22

3-
from .src import debug_dict, merge_dicts, update_dict, validate_dict
3+
from .operations import debug_dict, merge_dicts, update_dict
4+
from .validators import validate_dict

red_utils/dict_utils/src/operations.py renamed to red_utils/dict_utils/operations.py

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
from .validators import validate_dict
66

7-
87
def debug_dict(in_dict: dict = None) -> None:
98
"""Debug print a dict by looping overkeys and printing.
109

red_utils/dict_utils/pdm.lock

-9
This file was deleted.

red_utils/dict_utils/pyproject.toml

-15
This file was deleted.

red_utils/dict_utils/src/__init__.py

-4
This file was deleted.

red_utils/dict_utils/src/validators.py renamed to red_utils/dict_utils/validators.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from __future__ import annotations
22

3-
43
def validate_dict(_dict: dict[str, str] = None) -> dict[str, str]:
54
if not _dict:
65
raise ValueError("Missing dict to evaluate")

0 commit comments

Comments
 (0)