mm-std 0.1.12__py3-none-any.whl → 0.1.14__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.
mm_std/json_.py CHANGED
@@ -1,4 +1,5 @@
1
1
  import json
2
+ from collections.abc import Callable
2
3
  from dataclasses import asdict, is_dataclass
3
4
  from datetime import date, datetime
4
5
  from decimal import Decimal
@@ -28,8 +29,9 @@ class CustomJSONEncoder(JSONEncoder):
28
29
  return o.model_dump()
29
30
  if isinstance(o, Exception):
30
31
  return str(o)
31
- return JSONEncoder.default(self, o)
32
32
 
33
+ return super().default(o)
33
34
 
34
- def json_dumps(data: object) -> str:
35
- return json.dumps(data, cls=CustomJSONEncoder)
35
+
36
+ def json_dumps(data: object, default: Callable[[object], str] | None = str) -> str:
37
+ return json.dumps(data, cls=CustomJSONEncoder, default=default)
mm_std/print_.py CHANGED
@@ -1,4 +1,5 @@
1
1
  import sys
2
+ from collections.abc import Callable
2
3
  from enum import Enum, unique
3
4
  from typing import Any, NoReturn
4
5
 
@@ -21,13 +22,13 @@ def fatal(message: str, code: int = 1) -> NoReturn:
21
22
  sys.exit(code)
22
23
 
23
24
 
24
- def print_console(*messages: object, print_json: bool = False) -> None:
25
+ def print_console(*messages: object, print_json: bool = False, default: Callable[[object], str] | None = None) -> None:
25
26
  if len(messages) == 1:
26
27
  message = messages[0]
27
28
  if isinstance(message, str):
28
29
  print(message) # noqa: T201
29
30
  elif print_json:
30
- rich.print_json(json_dumps(message))
31
+ rich.print_json(json_dumps(message, default=default))
31
32
  else:
32
33
  rich.print(message)
33
34
  else:
@@ -39,9 +40,9 @@ def print_plain(messages: object, print_format: PrintFormat | None = None) -> No
39
40
  print(messages) # noqa: T201
40
41
 
41
42
 
42
- def print_json(data: object, print_format: PrintFormat | None = None) -> None:
43
+ def print_json(data: object, default: Callable[[object], str] | None = str, print_format: PrintFormat | None = None) -> None:
43
44
  if print_format is None or print_format == PrintFormat.JSON:
44
- rich.print_json(json_dumps(data))
45
+ rich.print_json(json_dumps(data, default=default))
45
46
 
46
47
 
47
48
  def print_table(title: str, columns: list[str], rows: list[list[Any]], print_format: PrintFormat | None = None) -> None:
mm_std/result.py CHANGED
@@ -1,13 +1,11 @@
1
1
  from __future__ import annotations
2
2
 
3
3
  import time
4
- from typing import TYPE_CHECKING, Any, Literal, NoReturn
4
+ from collections.abc import Callable
5
+ from typing import Any, Literal, NoReturn
5
6
 
6
7
  from pydantic_core import core_schema
7
8
 
8
- if TYPE_CHECKING:
9
- from collections.abc import Callable
10
-
11
9
 
12
10
  class Ok[T]:
13
11
  __match_args__ = ("ok",)
@@ -1,10 +1,10 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mm-std
3
- Version: 0.1.12
3
+ Version: 0.1.14
4
4
  Requires-Python: >=3.12
5
5
  Requires-Dist: cryptography~=44.0.0
6
6
  Requires-Dist: httpx[http2,socks]~=0.28.1
7
- Requires-Dist: pydantic~=2.10.5
7
+ Requires-Dist: pydantic~=2.10.6
8
8
  Requires-Dist: pydash~=8.0.5
9
9
  Requires-Dist: python-dotenv~=1.0.1
10
10
  Requires-Dist: pyyaml~=6.0.2
@@ -8,16 +8,16 @@ mm_std/dict.py,sha256=kJBPVG9vEqHiSgKKoji8gVGL1yEBbxAmFNn0zz17AUg,180
8
8
  mm_std/env.py,sha256=5zaR9VeIfObN-4yfgxoFeU5IM1GDeZZj9SuYf7t9sOA,125
9
9
  mm_std/fs.py,sha256=RwarNRJq3tIMG6LVX_g03hasfYpjYFh_O27oVDt5IPQ,291
10
10
  mm_std/http_.py,sha256=QaPPXVb-rOS0BpoKdYQ0ABm_-mcR5dNa7Uqn-SeW_kE,4119
11
- mm_std/json_.py,sha256=VWjJsfLt-dQJiwc7vgpTElMr69NxpzX_mpmBoCkeoT8,999
11
+ mm_std/json_.py,sha256=jAL-JrSMPIwxu3y87xNoTcwhOOEHGHrTpX1BTj44Uhw,1091
12
12
  mm_std/log.py,sha256=6ux6njNKc_ZCQlvWn1FZR6vcSY2Cem-mQzmNXvsg5IE,913
13
13
  mm_std/net.py,sha256=qdRCBIDneip6FaPNe5mx31UtYVmzqam_AoUF7ydEyjA,590
14
- mm_std/print_.py,sha256=HAhaiEMZZLV3CpG6UfwoUb6-Ftcun16YFC-CRcAcXOY,1525
14
+ mm_std/print_.py,sha256=w6qXqR7iNhFtrbOBDY11B579VzuUudOLz61liUM-pww,1691
15
15
  mm_std/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
16
16
  mm_std/random_.py,sha256=OuUX4VJeSd13NZBya4qrGpR2TfN7_87tfebOY6DBUnI,1113
17
- mm_std/result.py,sha256=w2Y1dji0LozcJpPMnFkqN0UbxJUm1C8Kc5ZB1vLXx20,7443
17
+ mm_std/result.py,sha256=KtYZbVJMkwwCPcV-Tnt0TkTNyDgiALvQB1DtIEp1prc,7405
18
18
  mm_std/str.py,sha256=jS7VAI7i_a3iqnfaW4Iw2LZRTv0Tml4kmMbP2S2IUF4,3067
19
19
  mm_std/types_.py,sha256=hvZlnvBWyB8CL_MeEWWD0Y0nN677plibYn3yD-5g7xs,99
20
20
  mm_std/zip.py,sha256=2EXcae4HO5U4kObj2Lj8jl5F2OUpT-WRlJybTyFzt6I,370
21
- mm_std-0.1.12.dist-info/METADATA,sha256=XX3oZLg7Z156pVNb0E9_Rw9jthMj1-SEC3ZPM8fUKxU,307
22
- mm_std-0.1.12.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
23
- mm_std-0.1.12.dist-info/RECORD,,
21
+ mm_std-0.1.14.dist-info/METADATA,sha256=hlTbkE6A5eGvwWSZ_KI4zCfTHD1jiR4J_8AXZuyh71E,307
22
+ mm_std-0.1.14.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
23
+ mm_std-0.1.14.dist-info/RECORD,,