python-base-toolkit 1.1.2__py3-none-any.whl → 1.2.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- python_base_toolkit/base_structures/base_pydantic_model.py +4 -5
- python_base_toolkit/ci/task_files/lint.yml +3 -5
- python_base_toolkit/consts/units/__init__.py +1 -2
- python_base_toolkit/utils/data_serialization.py +16 -17
- {python_base_toolkit-1.1.2.dist-info → python_base_toolkit-1.2.0.dist-info}/METADATA +1 -8
- {python_base_toolkit-1.1.2.dist-info → python_base_toolkit-1.2.0.dist-info}/RECORD +9 -9
- {python_base_toolkit-1.1.2.dist-info → python_base_toolkit-1.2.0.dist-info}/WHEEL +1 -1
- {python_base_toolkit-1.1.2.dist-info → python_base_toolkit-1.2.0.dist-info}/licenses/LICENSE +0 -0
- {python_base_toolkit-1.1.2.dist-info → python_base_toolkit-1.2.0.dist-info}/top_level.txt +0 -0
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
from typing import Any
|
|
2
|
-
from pydantic import BaseModel
|
|
1
|
+
from typing import Any
|
|
3
2
|
|
|
4
|
-
|
|
3
|
+
from pydantic import BaseModel
|
|
5
4
|
|
|
6
5
|
|
|
7
6
|
class BasePydanticModel(BaseModel):
|
|
@@ -10,11 +9,11 @@ class BasePydanticModel(BaseModel):
|
|
|
10
9
|
def __str__(self) -> str:
|
|
11
10
|
return f"{self.__class__.__name__}({self.model_dump()})"
|
|
12
11
|
|
|
13
|
-
def to_dict(self, **kwargs) -> dict[str, Any]:
|
|
12
|
+
def to_dict(self, **kwargs: Any) -> dict[str, Any]:
|
|
14
13
|
"""Wrapper for model_dump."""
|
|
15
14
|
return self.model_dump(**kwargs)
|
|
16
15
|
|
|
17
|
-
def to_json(self, **kwargs) -> str:
|
|
16
|
+
def to_json(self, **kwargs: Any) -> str:
|
|
18
17
|
"""Wrapper for model_dump_json."""
|
|
19
18
|
return self.model_dump_json(**kwargs)
|
|
20
19
|
|
|
@@ -4,8 +4,6 @@ tasks:
|
|
|
4
4
|
pre-commit:
|
|
5
5
|
desc: Pre-commit all files.
|
|
6
6
|
cmds:
|
|
7
|
-
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
set +a
|
|
11
|
-
"{{.UV_BIN}}" run pre-commit run --all-files
|
|
7
|
+
- echo "Running pre-commit hooks on all files..."
|
|
8
|
+
- '"{{.UV_BIN}}" run pre-commit run --all-files'
|
|
9
|
+
- defer: { task: ":infra:deploy:clean" }
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import json
|
|
2
|
+
from collections.abc import Callable
|
|
2
3
|
from dataclasses import is_dataclass
|
|
3
4
|
from datetime import date, datetime, time
|
|
4
5
|
from decimal import Decimal
|
|
@@ -15,25 +16,23 @@ from python_base_toolkit.consts.general import LOGGER_NAME
|
|
|
15
16
|
logger = get_logger(LOGGER_NAME)
|
|
16
17
|
|
|
17
18
|
|
|
19
|
+
_TYPE_SERIALIZERS: tuple[tuple[type | tuple[type, ...], Callable[[Any], object]], ...] = (
|
|
20
|
+
(BaseModel, lambda obj: obj.model_dump()),
|
|
21
|
+
(type, lambda obj: obj.__name__),
|
|
22
|
+
(Enum, lambda obj: obj.value),
|
|
23
|
+
((set, tuple), list),
|
|
24
|
+
((datetime, date, time), lambda obj: obj.isoformat()),
|
|
25
|
+
(Decimal, float),
|
|
26
|
+
(Path, str),
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
|
|
18
30
|
def default_serialize(obj: object) -> object:
|
|
19
|
-
if isinstance(obj, BaseModel):
|
|
20
|
-
return obj.model_dump()
|
|
21
|
-
if isinstance(obj, type):
|
|
22
|
-
return obj.__name__
|
|
23
|
-
if is_dataclass(obj) and not isinstance(obj, type):
|
|
31
|
+
if is_dataclass(obj) and not isinstance(obj, type | BaseModel):
|
|
24
32
|
return obj.__dict__
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
return list(obj)
|
|
29
|
-
if isinstance(obj, tuple):
|
|
30
|
-
return list(obj)
|
|
31
|
-
if isinstance(obj, datetime | date | time):
|
|
32
|
-
return obj.isoformat()
|
|
33
|
-
if isinstance(obj, Decimal):
|
|
34
|
-
return float(obj)
|
|
35
|
-
if isinstance(obj, Path):
|
|
36
|
-
return str(obj)
|
|
33
|
+
for types, serializer in _TYPE_SERIALIZERS:
|
|
34
|
+
if isinstance(obj, types):
|
|
35
|
+
return serializer(obj)
|
|
37
36
|
if obj is pd.NA:
|
|
38
37
|
return None
|
|
39
38
|
logger.error(f"Object is not serializable: {obj}")
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: python-base-toolkit
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.2.0
|
|
4
4
|
Summary: A Python package for managing pytest plugins.
|
|
5
5
|
Author: Avi Zaguri
|
|
6
6
|
License: MIT
|
|
@@ -16,21 +16,14 @@ Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
|
16
16
|
Requires-Python: >=3.12
|
|
17
17
|
Description-Content-Type: text/markdown
|
|
18
18
|
License-File: LICENSE
|
|
19
|
-
Requires-Dist: build>=1.3.0
|
|
20
|
-
Requires-Dist: colorlog>=6.10.1
|
|
21
19
|
Requires-Dist: custom-python-logger>=4.0.0
|
|
22
20
|
Requires-Dist: pandas>=2.3.3
|
|
23
|
-
Requires-Dist: pathlib>=1.0.1
|
|
24
|
-
Requires-Dist: pre-commit>=4.5.0
|
|
25
21
|
Requires-Dist: pydantic>=2.12.5
|
|
26
22
|
Requires-Dist: pyfiglet>=1.0.4
|
|
27
23
|
Requires-Dist: python-dotenv>=1.2.1
|
|
28
24
|
Requires-Dist: pyyaml>=6.0.3
|
|
29
25
|
Requires-Dist: requests>=2.32.5
|
|
30
|
-
Requires-Dist: setuptools>=80.9.0
|
|
31
26
|
Requires-Dist: tqdm>=4.67.1
|
|
32
|
-
Requires-Dist: twine>=6.2.0
|
|
33
|
-
Requires-Dist: wheel>=0.45.1
|
|
34
27
|
Dynamic: license-file
|
|
35
28
|
|
|
36
29
|

|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
python_base_toolkit/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
2
|
python_base_toolkit/base_structures/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
3
3
|
python_base_toolkit/base_structures/base_enum.py,sha256=pnKIBvGGudkwAbbE7C2dITVdZGclXWOvvVuat3erLMo,1324
|
|
4
|
-
python_base_toolkit/base_structures/base_pydantic_model.py,sha256=
|
|
4
|
+
python_base_toolkit/base_structures/base_pydantic_model.py,sha256=HEKjsGhHwsVpxALAclCLam4hPY0wqVFal9cYqia8LQY,1200
|
|
5
5
|
python_base_toolkit/ci/task_files/default.yml,sha256=7NKbXXZP366t-K34MfRj1XJqhhm19YaRpraV1Na4c90,145
|
|
6
6
|
python_base_toolkit/ci/task_files/dependencies.yml,sha256=jqdNAugfDWoiH7YDBD-5QWMX9z4tZkSGGV9PNp6wpFA,891
|
|
7
7
|
python_base_toolkit/ci/task_files/deploy.yml,sha256=uKvRJjNImWGPk_xqKV08HlIhDoPepEvf5M54l7Bk_6I,537
|
|
8
8
|
python_base_toolkit/ci/task_files/docker.yml,sha256=XbviD1Yixbi-DWG-EQPqfxsmaiTWTjn1WIytW8BrC0Y,2378
|
|
9
9
|
python_base_toolkit/ci/task_files/includes.yml,sha256=nXAFvcJWUHAZJMAQ1xrqkQM-qLZkEmqxho7DexTcRNM,179
|
|
10
10
|
python_base_toolkit/ci/task_files/install.yml,sha256=D5SmBR4wKvnN57f-4ZDb98xxRpdJu0thziyonagYlec,1555
|
|
11
|
-
python_base_toolkit/ci/task_files/lint.yml,sha256=
|
|
11
|
+
python_base_toolkit/ci/task_files/lint.yml,sha256=4HbS0kDTLil8YO4cKhgoQJM_OaT6jmbKFvaDGz3sYLQ,235
|
|
12
12
|
python_base_toolkit/ci/task_files/vars.yml,sha256=AP-OMdJdfsnLsjooYPZCM9hGII6F6FDL_8ziXf24wBs,889
|
|
13
13
|
python_base_toolkit/consts/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
14
14
|
python_base_toolkit/consts/general.py,sha256=kbrqVucBNdTiyLucm4oQ13aI7nPsDRfLhCUZB6bCA9s,36
|
|
15
15
|
python_base_toolkit/consts/operating_system.py,sha256=8cnaHVz80AecTDhQjhU-i-s88bf1UZ-u0ouxHXxDsmA,80
|
|
16
|
-
python_base_toolkit/consts/units/__init__.py,sha256=
|
|
16
|
+
python_base_toolkit/consts/units/__init__.py,sha256=MHhJ-ofW4QHB7iy3xPQAqIpDVwWGilrJLRRtknSpa8U,123
|
|
17
17
|
python_base_toolkit/consts/units/binary_units.py,sha256=fgRAP6HXIis6OX4uK8woD-OVD7HtBOBDuhDxJ6AGZVE,412
|
|
18
18
|
python_base_toolkit/consts/units/time_units.py,sha256=aDwRnRR_mbOn2B7NUB9b2-qO98CLFzNE8-ZKfwUZ09Q,216
|
|
19
19
|
python_base_toolkit/decorators/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -24,7 +24,7 @@ python_base_toolkit/instances/instance_manager.py,sha256=u8Tj2LlNnMfe2VRCbEcJkRj
|
|
|
24
24
|
python_base_toolkit/scripts/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
25
25
|
python_base_toolkit/scripts/remove_build_files.py,sha256=461h7BkuwhaCBK17fbxDc3n_nQhL5aCXm3VP52s8sW8,694
|
|
26
26
|
python_base_toolkit/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
27
|
-
python_base_toolkit/utils/data_serialization.py,sha256=
|
|
27
|
+
python_base_toolkit/utils/data_serialization.py,sha256=IAkIoMXNUDX8mJGicMHnTtDxTuza8hTpVm6urjkMJO4,1382
|
|
28
28
|
python_base_toolkit/utils/date_time.py,sha256=MAJ1QQ5HGfwKSk5kPtViGkwC3jhZOdPUvdecvjWREnY,636
|
|
29
29
|
python_base_toolkit/utils/execute.py,sha256=6QYQWd1Z15Ofb4gcAtXCx90l1D-REwTWDZNybU6OibM,1560
|
|
30
30
|
python_base_toolkit/utils/file_utils.py,sha256=pv1bYhvn6EhShB_7S-y0x8g8hazpDUILIk_Bf9dwNnU,8856
|
|
@@ -37,8 +37,8 @@ python_base_toolkit/utils/pycache.py,sha256=Stda4S2ZHwt4u67tue3_9brH_wd4mGM5t-0B
|
|
|
37
37
|
python_base_toolkit/utils/random_utils.py,sha256=gTH6k1MKKGNZvBTLc5H-eSmtEGvXEdLqtzXN9aHuu-A,2730
|
|
38
38
|
python_base_toolkit/utils/shorten_url.py,sha256=zsyW3wloFJdVb9s3fhR-olL6ekT03FDlFm2xbFY4viw,359
|
|
39
39
|
python_base_toolkit/utils/venv_details.py,sha256=d1WlZr1LuWz2SXdFP0Hqh6VHXXXSIuXB0oTmWXJrGqM,210
|
|
40
|
-
python_base_toolkit-1.
|
|
41
|
-
python_base_toolkit-1.
|
|
42
|
-
python_base_toolkit-1.
|
|
43
|
-
python_base_toolkit-1.
|
|
44
|
-
python_base_toolkit-1.
|
|
40
|
+
python_base_toolkit-1.2.0.dist-info/licenses/LICENSE,sha256=cSikHY6SZFsPZSBizCDAJ0-Bjjzxt-JtX6TVbKxwimo,1067
|
|
41
|
+
python_base_toolkit-1.2.0.dist-info/METADATA,sha256=OMfXc5VRGKWle05SJV7XyjjkAfw-3hbeReTE-hqkfvY,2780
|
|
42
|
+
python_base_toolkit-1.2.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
|
|
43
|
+
python_base_toolkit-1.2.0.dist-info/top_level.txt,sha256=I9kK6FGKq_6z3aGySoWamY68GRgg0xsL6sS-uyaxJ2k,20
|
|
44
|
+
python_base_toolkit-1.2.0.dist-info/RECORD,,
|
{python_base_toolkit-1.1.2.dist-info → python_base_toolkit-1.2.0.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|
|
File without changes
|