biased 0.1.2.dev12__tar.gz → 0.1.2.dev13__tar.gz
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.
- {biased-0.1.2.dev12 → biased-0.1.2.dev13}/PKG-INFO +1 -1
- {biased-0.1.2.dev12 → biased-0.1.2.dev13}/pyproject.toml +2 -1
- biased-0.1.2.dev13/src/biased/django/utils/get_user_agent.py +5 -0
- biased-0.1.2.dev13/src/biased/django/validators/pydantic.py +28 -0
- biased-0.1.2.dev13/src/biased/pydantic/base64_pydantic_model.py +37 -0
- biased-0.1.2.dev13/src/biased/structlog/__init__.py +0 -0
- biased-0.1.2.dev13/src/biased/utils/__init__.py +0 -0
- {biased-0.1.2.dev12 → biased-0.1.2.dev13}/README.md +0 -0
- {biased-0.1.2.dev12 → biased-0.1.2.dev13}/src/biased/__init__.py +0 -0
- {biased-0.1.2.dev12 → biased-0.1.2.dev13}/src/biased/consts.py +0 -0
- {biased-0.1.2.dev12 → biased-0.1.2.dev13}/src/biased/django/__init__.py +0 -0
- {biased-0.1.2.dev12 → biased-0.1.2.dev13}/src/biased/django/admin.py +0 -0
- {biased-0.1.2.dev12 → biased-0.1.2.dev13}/src/biased/django/apps.py +0 -0
- {biased-0.1.2.dev12 → biased-0.1.2.dev13}/src/biased/django/aws_waf/__init__.py +0 -0
- {biased-0.1.2.dev12 → biased-0.1.2.dev13}/src/biased/django/aws_waf/aws_waf_regex_pattern.py +0 -0
- {biased-0.1.2.dev12 → biased-0.1.2.dev13}/src/biased/django/aws_waf/aws_waf_whitelist_middleware.py +0 -0
- {biased-0.1.2.dev12 → biased-0.1.2.dev13}/src/biased/django/aws_waf/url_patterns.py +0 -0
- {biased-0.1.2.dev12 → biased-0.1.2.dev13}/src/biased/django/dtos.py +0 -0
- {biased-0.1.2.dev12 → biased-0.1.2.dev13}/src/biased/django/filters/__init__.py +0 -0
- {biased-0.1.2.dev12 → biased-0.1.2.dev13}/src/biased/django/filters/entity_filter.py +0 -0
- {biased-0.1.2.dev12 → biased-0.1.2.dev13}/src/biased/django/filters/input_filter.py +0 -0
- {biased-0.1.2.dev12 → biased-0.1.2.dev13}/src/biased/django/forms/__init__.py +0 -0
- {biased-0.1.2.dev12 → biased-0.1.2.dev13}/src/biased/django/forms/json_editor_widget.py +0 -0
- {biased-0.1.2.dev12 → biased-0.1.2.dev13}/src/biased/django/forms/pydantic_model_form_field.py +0 -0
- {biased-0.1.2.dev12 → biased-0.1.2.dev13}/src/biased/django/forms/ulid_form_field.py +0 -0
- {biased-0.1.2.dev12 → biased-0.1.2.dev13}/src/biased/django/models/__init__.py +0 -0
- {biased-0.1.2.dev12 → biased-0.1.2.dev13}/src/biased/django/models/bank_account.py +0 -0
- {biased-0.1.2.dev12 → biased-0.1.2.dev13}/src/biased/django/models/char_field.py +0 -0
- {biased-0.1.2.dev12 → biased-0.1.2.dev13}/src/biased/django/models/created_at_modified_at_mixin.py +0 -0
- {biased-0.1.2.dev12 → biased-0.1.2.dev13}/src/biased/django/models/default_money_amount_field.py +0 -0
- {biased-0.1.2.dev12 → biased-0.1.2.dev13}/src/biased/django/models/deleted_at_mixin.py +0 -0
- {biased-0.1.2.dev12 → biased-0.1.2.dev13}/src/biased/django/models/multi_select_field.py +0 -0
- {biased-0.1.2.dev12 → biased-0.1.2.dev13}/src/biased/django/models/pydantic_model_field.py +0 -0
- {biased-0.1.2.dev12 → biased-0.1.2.dev13}/src/biased/django/templates/actions_change_form.html +0 -0
- {biased-0.1.2.dev12 → biased-0.1.2.dev13}/src/biased/django/templates/admin/input_filter.html +0 -0
- {biased-0.1.2.dev12 → biased-0.1.2.dev13}/src/biased/django/utils/__init__.py +0 -0
- {biased-0.1.2.dev12 → biased-0.1.2.dev13}/src/biased/django/utils/choices.py +0 -0
- {biased-0.1.2.dev12 → biased-0.1.2.dev13}/src/biased/django/utils/get_client_ip.py +0 -0
- {biased-0.1.2.dev12 → biased-0.1.2.dev13}/src/biased/django/utils/reverse.py +0 -0
- {biased-0.1.2.dev12/src/biased/django_jsonform → biased-0.1.2.dev13/src/biased/django/validators}/__init__.py +0 -0
- {biased-0.1.2.dev12/src/biased/django_redis → biased-0.1.2.dev13/src/biased/django_jsonform}/__init__.py +0 -0
- {biased-0.1.2.dev12 → biased-0.1.2.dev13}/src/biased/django_jsonform/apps.py +0 -0
- {biased-0.1.2.dev12 → biased-0.1.2.dev13}/src/biased/django_jsonform/jsonform_action.py +0 -0
- {biased-0.1.2.dev12 → biased-0.1.2.dev13}/src/biased/django_jsonform/templates/admin_form_action/django_jsonform_form.html +0 -0
- {biased-0.1.2.dev12/src/biased/dtos → biased-0.1.2.dev13/src/biased/django_redis}/__init__.py +0 -0
- {biased-0.1.2.dev12 → biased-0.1.2.dev13}/src/biased/django_redis/pydantic_serializer.py +0 -0
- {biased-0.1.2.dev12/src/biased/logging → biased-0.1.2.dev13/src/biased/dtos}/__init__.py +0 -0
- {biased-0.1.2.dev12 → biased-0.1.2.dev13}/src/biased/dtos/base.py +0 -0
- {biased-0.1.2.dev12 → biased-0.1.2.dev13}/src/biased/dtos/env_file_paths.py +0 -0
- {biased-0.1.2.dev12 → biased-0.1.2.dev13}/src/biased/dtos/logging.py +0 -0
- {biased-0.1.2.dev12/src/biased/ninja → biased-0.1.2.dev13/src/biased/logging}/__init__.py +0 -0
- {biased-0.1.2.dev12 → biased-0.1.2.dev13}/src/biased/logging/dict_config.py +0 -0
- {biased-0.1.2.dev12 → biased-0.1.2.dev13}/src/biased/logging/settings.py +0 -0
- {biased-0.1.2.dev12 → biased-0.1.2.dev13}/src/biased/logging/utils.py +0 -0
- {biased-0.1.2.dev12/src/biased/structlog → biased-0.1.2.dev13/src/biased/ninja}/__init__.py +0 -0
- {biased-0.1.2.dev12 → biased-0.1.2.dev13}/src/biased/ninja/json_renderrer.py +0 -0
- {biased-0.1.2.dev12/src/biased/utils → biased-0.1.2.dev13/src/biased/pydantic}/__init__.py +0 -0
- {biased-0.1.2.dev12 → biased-0.1.2.dev13}/src/biased/structlog/processors.py +0 -0
- {biased-0.1.2.dev12 → biased-0.1.2.dev13}/src/biased/structlog/structlog_json_encoder.py +0 -0
- {biased-0.1.2.dev12 → biased-0.1.2.dev13}/src/biased/types.py +0 -0
- {biased-0.1.2.dev12 → biased-0.1.2.dev13}/src/biased/utils/aba_routing_number.py +0 -0
- {biased-0.1.2.dev12 → biased-0.1.2.dev13}/src/biased/utils/attrgetter_default.py +0 -0
- {biased-0.1.2.dev12 → biased-0.1.2.dev13}/src/biased/utils/calculate_age.py +0 -0
- {biased-0.1.2.dev12 → biased-0.1.2.dev13}/src/biased/utils/default_json_encoder.py +0 -0
- {biased-0.1.2.dev12 → biased-0.1.2.dev13}/src/biased/utils/filter_not_none_values.py +0 -0
- {biased-0.1.2.dev12 → biased-0.1.2.dev13}/src/biased/utils/time.py +0 -0
- {biased-0.1.2.dev12 → biased-0.1.2.dev13}/src/biased/utils/ulid.py +0 -0
- {biased-0.1.2.dev12 → biased-0.1.2.dev13}/src/biased/utils/uuid.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: biased
|
|
3
|
-
Version: 0.1.2.
|
|
3
|
+
Version: 0.1.2.dev13
|
|
4
4
|
Summary: Various reusable components, helpers, and utilities which I would like to use in any Python project
|
|
5
5
|
Author: Dmitry Tatarkin
|
|
6
6
|
Author-email: Dmitry Tatarkin <tatarkin@gmail.com>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "biased"
|
|
3
|
-
version = "0.1.2.
|
|
3
|
+
version = "0.1.2.dev13"
|
|
4
4
|
description = "Various reusable components, helpers, and utilities which I would like to use in any Python project"
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
authors = [
|
|
@@ -35,5 +35,6 @@ build-backend = "uv_build"
|
|
|
35
35
|
|
|
36
36
|
[dependency-groups]
|
|
37
37
|
dev = [
|
|
38
|
+
"pytest>=9.0.2",
|
|
38
39
|
"rust-just>=1.43.0",
|
|
39
40
|
]
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
from typing import Any
|
|
2
|
+
|
|
3
|
+
from django.core.exceptions import ValidationError
|
|
4
|
+
from django.utils.module_loading import import_string
|
|
5
|
+
from pydantic import TypeAdapter
|
|
6
|
+
from pydantic import ValidationError as PydanticValidationError
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class PydanticDjangoValidator:
|
|
10
|
+
def __init__(self, dotted_path_to_type: str):
|
|
11
|
+
self._dotted_path_to_type = dotted_path_to_type
|
|
12
|
+
self._adapter = TypeAdapter(import_string(dotted_path_to_type))
|
|
13
|
+
|
|
14
|
+
def __call__(self, value: Any):
|
|
15
|
+
try:
|
|
16
|
+
self._adapter.validate_python(value)
|
|
17
|
+
except PydanticValidationError as e:
|
|
18
|
+
raise ValidationError([error["msg"] for error in e.errors()]) from e
|
|
19
|
+
|
|
20
|
+
def deconstruct(self):
|
|
21
|
+
return (
|
|
22
|
+
f"{self.__class__.__module__}.{self.__class__.__qualname__}",
|
|
23
|
+
(),
|
|
24
|
+
dict(dotted_path_to_type=self._dotted_path_to_type),
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
def __eq__(self, other):
|
|
28
|
+
return isinstance(other, self.__class__) and self._dotted_path_to_type == other._dotted_path_to_type
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import base64
|
|
2
|
+
import binascii
|
|
3
|
+
import json
|
|
4
|
+
from json import JSONDecodeError
|
|
5
|
+
from typing import Annotated, Any, TypeVar
|
|
6
|
+
|
|
7
|
+
from pydantic import BaseModel, BeforeValidator, PlainSerializer
|
|
8
|
+
|
|
9
|
+
T = TypeVar("T", bound=BaseModel)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def _decode_b64_json(v: Any) -> Any:
|
|
13
|
+
"""Decodes a Base64 string into a Python dictionary."""
|
|
14
|
+
if isinstance(v, str):
|
|
15
|
+
try:
|
|
16
|
+
decoded_bytes = base64.b64decode(v)
|
|
17
|
+
return json.loads(decoded_bytes.decode())
|
|
18
|
+
except (binascii.Error, JSONDecodeError):
|
|
19
|
+
# If decoding fails, we pass it through so Pydantic
|
|
20
|
+
# can raise a standard validation error later.
|
|
21
|
+
return v
|
|
22
|
+
return v
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def _encode_b64_json(v: Any) -> str:
|
|
26
|
+
"""Serializes a Pydantic model into a Base64 encoded JSON string."""
|
|
27
|
+
if isinstance(v, BaseModel):
|
|
28
|
+
json_str = v.model_dump_json()
|
|
29
|
+
return base64.b64encode(json_str.encode()).decode()
|
|
30
|
+
return str(v)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
Base64PydanticModel = Annotated[
|
|
34
|
+
T,
|
|
35
|
+
BeforeValidator(_decode_b64_json),
|
|
36
|
+
PlainSerializer(_encode_b64_json),
|
|
37
|
+
]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{biased-0.1.2.dev12 → biased-0.1.2.dev13}/src/biased/django/aws_waf/aws_waf_regex_pattern.py
RENAMED
|
File without changes
|
{biased-0.1.2.dev12 → biased-0.1.2.dev13}/src/biased/django/aws_waf/aws_waf_whitelist_middleware.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{biased-0.1.2.dev12 → biased-0.1.2.dev13}/src/biased/django/forms/pydantic_model_form_field.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{biased-0.1.2.dev12 → biased-0.1.2.dev13}/src/biased/django/models/created_at_modified_at_mixin.py
RENAMED
|
File without changes
|
{biased-0.1.2.dev12 → biased-0.1.2.dev13}/src/biased/django/models/default_money_amount_field.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{biased-0.1.2.dev12 → biased-0.1.2.dev13}/src/biased/django/templates/actions_change_form.html
RENAMED
|
File without changes
|
{biased-0.1.2.dev12 → biased-0.1.2.dev13}/src/biased/django/templates/admin/input_filter.html
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{biased-0.1.2.dev12/src/biased/dtos → biased-0.1.2.dev13/src/biased/django_redis}/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|