python3-commons 0.16.1__tar.gz → 0.16.2__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.
Files changed (73) hide show
  1. {python3_commons-0.16.1 → python3_commons-0.16.2}/PKG-INFO +1 -2
  2. {python3_commons-0.16.1 → python3_commons-0.16.2}/pyproject.toml +0 -1
  3. {python3_commons-0.16.1 → python3_commons-0.16.2}/src/python3_commons/log/formatters.py +20 -13
  4. {python3_commons-0.16.1 → python3_commons-0.16.2}/src/python3_commons.egg-info/PKG-INFO +1 -2
  5. {python3_commons-0.16.1 → python3_commons-0.16.2}/src/python3_commons.egg-info/requires.txt +0 -1
  6. {python3_commons-0.16.1 → python3_commons-0.16.2}/uv.lock +0 -25
  7. {python3_commons-0.16.1 → python3_commons-0.16.2}/.coveragerc +0 -0
  8. {python3_commons-0.16.1 → python3_commons-0.16.2}/.devcontainer/Dockerfile +0 -0
  9. {python3_commons-0.16.1 → python3_commons-0.16.2}/.devcontainer/devcontainer.json +0 -0
  10. {python3_commons-0.16.1 → python3_commons-0.16.2}/.devcontainer/docker-compose.yml +0 -0
  11. {python3_commons-0.16.1 → python3_commons-0.16.2}/.env_template +0 -0
  12. {python3_commons-0.16.1 → python3_commons-0.16.2}/.github/workflows/checks.yml +0 -0
  13. {python3_commons-0.16.1 → python3_commons-0.16.2}/.github/workflows/python-publish.yaml +0 -0
  14. {python3_commons-0.16.1 → python3_commons-0.16.2}/.github/workflows/release-on-tag-push.yml +0 -0
  15. {python3_commons-0.16.1 → python3_commons-0.16.2}/.gitignore +0 -0
  16. {python3_commons-0.16.1 → python3_commons-0.16.2}/.pre-commit-config.yaml +0 -0
  17. {python3_commons-0.16.1 → python3_commons-0.16.2}/.python-version +0 -0
  18. {python3_commons-0.16.1 → python3_commons-0.16.2}/AUTHORS.rst +0 -0
  19. {python3_commons-0.16.1 → python3_commons-0.16.2}/CHANGELOG.rst +0 -0
  20. {python3_commons-0.16.1 → python3_commons-0.16.2}/LICENSE +0 -0
  21. {python3_commons-0.16.1 → python3_commons-0.16.2}/README.md +0 -0
  22. {python3_commons-0.16.1 → python3_commons-0.16.2}/README.rst +0 -0
  23. {python3_commons-0.16.1 → python3_commons-0.16.2}/docs/Makefile +0 -0
  24. {python3_commons-0.16.1 → python3_commons-0.16.2}/docs/_static/.gitignore +0 -0
  25. {python3_commons-0.16.1 → python3_commons-0.16.2}/docs/authors.rst +0 -0
  26. {python3_commons-0.16.1 → python3_commons-0.16.2}/docs/changelog.rst +0 -0
  27. {python3_commons-0.16.1 → python3_commons-0.16.2}/docs/conf.py +0 -0
  28. {python3_commons-0.16.1 → python3_commons-0.16.2}/docs/index.rst +0 -0
  29. {python3_commons-0.16.1 → python3_commons-0.16.2}/docs/license.rst +0 -0
  30. {python3_commons-0.16.1 → python3_commons-0.16.2}/setup.cfg +0 -0
  31. {python3_commons-0.16.1 → python3_commons-0.16.2}/src/python3_commons/__init__.py +0 -0
  32. {python3_commons-0.16.1 → python3_commons-0.16.2}/src/python3_commons/api_client.py +0 -0
  33. {python3_commons-0.16.1 → python3_commons-0.16.2}/src/python3_commons/async_functools.py +0 -0
  34. {python3_commons-0.16.1 → python3_commons-0.16.2}/src/python3_commons/audit.py +0 -0
  35. {python3_commons-0.16.1 → python3_commons-0.16.2}/src/python3_commons/auth.py +0 -0
  36. {python3_commons-0.16.1 → python3_commons-0.16.2}/src/python3_commons/cache.py +0 -0
  37. {python3_commons-0.16.1 → python3_commons-0.16.2}/src/python3_commons/conf.py +0 -0
  38. {python3_commons-0.16.1 → python3_commons-0.16.2}/src/python3_commons/db/__init__.py +0 -0
  39. {python3_commons-0.16.1 → python3_commons-0.16.2}/src/python3_commons/db/helpers.py +0 -0
  40. {python3_commons-0.16.1 → python3_commons-0.16.2}/src/python3_commons/db/models/__init__.py +0 -0
  41. {python3_commons-0.16.1 → python3_commons-0.16.2}/src/python3_commons/db/models/auth.py +0 -0
  42. {python3_commons-0.16.1 → python3_commons-0.16.2}/src/python3_commons/db/models/common.py +0 -0
  43. {python3_commons-0.16.1 → python3_commons-0.16.2}/src/python3_commons/db/models/rbac.py +0 -0
  44. {python3_commons-0.16.1 → python3_commons-0.16.2}/src/python3_commons/db/models/users.py +0 -0
  45. {python3_commons-0.16.1 → python3_commons-0.16.2}/src/python3_commons/exceptions.py +0 -0
  46. {python3_commons-0.16.1 → python3_commons-0.16.2}/src/python3_commons/fs.py +0 -0
  47. {python3_commons-0.16.1 → python3_commons-0.16.2}/src/python3_commons/generators.py +0 -0
  48. {python3_commons-0.16.1 → python3_commons-0.16.2}/src/python3_commons/helpers.py +0 -0
  49. {python3_commons-0.16.1 → python3_commons-0.16.2}/src/python3_commons/log/__init__.py +0 -0
  50. {python3_commons-0.16.1 → python3_commons-0.16.2}/src/python3_commons/log/filters.py +0 -0
  51. {python3_commons-0.16.1 → python3_commons-0.16.2}/src/python3_commons/object_storage.py +0 -0
  52. {python3_commons-0.16.1 → python3_commons-0.16.2}/src/python3_commons/permissions.py +0 -0
  53. {python3_commons-0.16.1 → python3_commons-0.16.2}/src/python3_commons/serializers/__init__.py +0 -0
  54. {python3_commons-0.16.1 → python3_commons-0.16.2}/src/python3_commons/serializers/common.py +0 -0
  55. {python3_commons-0.16.1 → python3_commons-0.16.2}/src/python3_commons/serializers/json.py +0 -0
  56. {python3_commons-0.16.1 → python3_commons-0.16.2}/src/python3_commons/serializers/msgpack.py +0 -0
  57. {python3_commons-0.16.1 → python3_commons-0.16.2}/src/python3_commons/serializers/msgspec.py +0 -0
  58. {python3_commons-0.16.1 → python3_commons-0.16.2}/src/python3_commons.egg-info/SOURCES.txt +0 -0
  59. {python3_commons-0.16.1 → python3_commons-0.16.2}/src/python3_commons.egg-info/dependency_links.txt +0 -0
  60. {python3_commons-0.16.1 → python3_commons-0.16.2}/src/python3_commons.egg-info/top_level.txt +0 -0
  61. {python3_commons-0.16.1 → python3_commons-0.16.2}/tests/__init__.py +0 -0
  62. {python3_commons-0.16.1 → python3_commons-0.16.2}/tests/integration/__init__.py +0 -0
  63. {python3_commons-0.16.1 → python3_commons-0.16.2}/tests/integration/test_cache.py +0 -0
  64. {python3_commons-0.16.1 → python3_commons-0.16.2}/tests/integration/test_osc.py +0 -0
  65. {python3_commons-0.16.1 → python3_commons-0.16.2}/tests/unit/__init__.py +0 -0
  66. {python3_commons-0.16.1 → python3_commons-0.16.2}/tests/unit/conftest.py +0 -0
  67. {python3_commons-0.16.1 → python3_commons-0.16.2}/tests/unit/log/__init__.py +0 -0
  68. {python3_commons-0.16.1 → python3_commons-0.16.2}/tests/unit/log/test_formatters.py +0 -0
  69. {python3_commons-0.16.1 → python3_commons-0.16.2}/tests/unit/test_async_functools.py +0 -0
  70. {python3_commons-0.16.1 → python3_commons-0.16.2}/tests/unit/test_audit.py +0 -0
  71. {python3_commons-0.16.1 → python3_commons-0.16.2}/tests/unit/test_helpers.py +0 -0
  72. {python3_commons-0.16.1 → python3_commons-0.16.2}/tests/unit/test_msgpack.py +0 -0
  73. {python3_commons-0.16.1 → python3_commons-0.16.2}/tests/unit/test_msgspec.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python3-commons
3
- Version: 0.16.1
3
+ Version: 0.16.2
4
4
  Summary: Re-usable Python3 code
5
5
  Author-email: Oleg Korsak <kamikaze.is.waiting.you@gmail.com>
6
6
  License-Expression: GPL-3.0
@@ -19,7 +19,6 @@ Requires-Dist: lxml~=6.1.0
19
19
  Requires-Dist: msgpack~=1.1.2
20
20
  Requires-Dist: msgspec==0.21.1
21
21
  Requires-Dist: object-storage-client==0.0.22
22
- Requires-Dist: orjson==3.11.8
23
22
  Requires-Dist: pydantic-settings~=2.14.0
24
23
  Requires-Dist: SQLAlchemy[asyncio]~=2.0.49
25
24
  Requires-Dist: valkey[libvalkey]~=6.1.1
@@ -25,7 +25,6 @@ dependencies = [
25
25
  "msgpack~=1.1.2",
26
26
  "msgspec==0.21.1",
27
27
  "object-storage-client==0.0.22",
28
- "orjson==3.11.8",
29
28
  "pydantic-settings~=2.14.0",
30
29
  "SQLAlchemy[asyncio]~=2.0.49",
31
30
  "valkey[libvalkey]~=6.1.1",
@@ -5,7 +5,7 @@ from datetime import UTC, datetime, date
5
5
  from decimal import Decimal
6
6
  from typing import Any, Final, Callable
7
7
 
8
- import orjson
8
+ import msgspec
9
9
 
10
10
  correlation_id: ContextVar[str | None] = ContextVar('correlation_id', default=None)
11
11
 
@@ -36,7 +36,7 @@ _STD_LOG_FIELDS: Final[frozenset[str]] = frozenset(
36
36
  )
37
37
 
38
38
 
39
- # Keep normalization minimal and branch-based (faster than dict dispatch)
39
+ # Keep normalization minimal and branch-based (unchanged)
40
40
  def _normalize(v: Any) -> Any:
41
41
  if isinstance(v, datetime | date):
42
42
  return v.isoformat()
@@ -54,29 +54,38 @@ def _normalize(v: Any) -> Any:
54
54
 
55
55
 
56
56
  class JSONFormatter(logging.Formatter):
57
- __slots__ = ('_get_correlation_id', '_max_tb_chars')
57
+ __slots__ = ('_get_correlation_id', '_max_tb_chars', '_encoder')
58
58
 
59
59
  def __init__(
60
- self,
61
- *,
62
- get_correlation_id: Callable[[], str | None] = lambda: correlation_id.get(),
63
- max_exc_tb_chars: int = _DEFAULT_MAX_TB_CHARS,
64
- **kwargs: Any,
60
+ self,
61
+ *,
62
+ get_correlation_id: Callable[[], str | None] = lambda: correlation_id.get(),
63
+ max_exc_tb_chars: int = _DEFAULT_MAX_TB_CHARS,
64
+ **kwargs: Any,
65
65
  ) -> None:
66
66
  super().__init__(**kwargs)
67
+
67
68
  self._get_correlation_id = get_correlation_id
68
69
  self._max_tb_chars = max_exc_tb_chars
70
+ self._encoder = msgspec.json.Encoder()
69
71
 
70
72
  def format(self, record: logging.LogRecord) -> str:
71
- # --- message (fast path, avoid Formatter.formatMessage) ---
73
+ # -------------------------
74
+ # message (fast path)
75
+ # -------------------------
72
76
  try:
73
77
  message = record.getMessage()
74
78
  except Exception:
75
79
  message = str(record.msg)
76
80
 
77
- # --- timestamp (no Formatter.formatTime overhead) ---
81
+ # -------------------------
82
+ # timestamp (no Formatter overhead)
83
+ # -------------------------
78
84
  timestamp = datetime.fromtimestamp(record.created, UTC).isoformat().replace('+00:00', 'Z')
79
85
 
86
+ # -------------------------
87
+ # base log object (plain dict)
88
+ # -------------------------
80
89
  log: dict[str, Any] = {
81
90
  'message': message,
82
91
  'level': record.levelname,
@@ -94,7 +103,6 @@ class JSONFormatter(logging.Formatter):
94
103
  log['exc_value'] = str(exc_value)
95
104
 
96
105
  tb = ''.join(traceback.format_exception(exc_type, exc_value, exc_tb)).rstrip()
97
-
98
106
  cap = self._max_tb_chars
99
107
 
100
108
  if cap and len(tb) > cap:
@@ -112,7 +120,6 @@ class JSONFormatter(logging.Formatter):
112
120
  for k, v in record_dict.items():
113
121
  if k[0] == '_' or k in std_log_fields:
114
122
  continue
115
-
116
123
  out_set(k, normalize(v))
117
124
 
118
- return orjson.dumps(log).decode('utf-8')
125
+ return self._encoder.encode(log).decode('utf-8')
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python3-commons
3
- Version: 0.16.1
3
+ Version: 0.16.2
4
4
  Summary: Re-usable Python3 code
5
5
  Author-email: Oleg Korsak <kamikaze.is.waiting.you@gmail.com>
6
6
  License-Expression: GPL-3.0
@@ -19,7 +19,6 @@ Requires-Dist: lxml~=6.1.0
19
19
  Requires-Dist: msgpack~=1.1.2
20
20
  Requires-Dist: msgspec==0.21.1
21
21
  Requires-Dist: object-storage-client==0.0.22
22
- Requires-Dist: orjson==3.11.8
23
22
  Requires-Dist: pydantic-settings~=2.14.0
24
23
  Requires-Dist: SQLAlchemy[asyncio]~=2.0.49
25
24
  Requires-Dist: valkey[libvalkey]~=6.1.1
@@ -5,7 +5,6 @@ lxml~=6.1.0
5
5
  msgpack~=1.1.2
6
6
  msgspec==0.21.1
7
7
  object-storage-client==0.0.22
8
- orjson==3.11.8
9
8
  pydantic-settings~=2.14.0
10
9
  SQLAlchemy[asyncio]~=2.0.49
11
10
  valkey[libvalkey]~=6.1.1
@@ -677,29 +677,6 @@ wheels = [
677
677
  { url = "https://files.pythonhosted.org/packages/ee/73/4af6bf9dc086e9c0a69988d2258d2f6f5d02d00ef891d9df3d6d08c3355a/object_storage_client-0.0.22-cp314-cp314-win_amd64.whl", hash = "sha256:df863a2a3f8f1c77d06bdc547d674b321878dca7cb7db94606b763cb9cc7e508", size = 2095414, upload-time = "2026-04-21T12:36:38.966Z" },
678
678
  ]
679
679
 
680
- [[package]]
681
- name = "orjson"
682
- version = "3.11.8"
683
- source = { registry = "https://pypi.org/simple" }
684
- sdist = { url = "https://files.pythonhosted.org/packages/9d/1b/2024d06792d0779f9dbc51531b61c24f76c75b9f4ce05e6f3377a1814cea/orjson-3.11.8.tar.gz", hash = "sha256:96163d9cdc5a202703e9ad1b9ae757d5f0ca62f4fa0cc93d1f27b0e180cc404e", size = 5603832, upload-time = "2026-03-31T16:16:27.878Z" }
685
- wheels = [
686
- { url = "https://files.pythonhosted.org/packages/6d/35/b01910c3d6b85dc882442afe5060cbf719c7d1fc85749294beda23d17873/orjson-3.11.8-cp314-cp314-macosx_10_15_x86_64.macosx_11_0_arm64.macosx_10_15_universal2.whl", hash = "sha256:ec795530a73c269a55130498842aaa762e4a939f6ce481a7e986eeaa790e9da4", size = 229171, upload-time = "2026-03-31T16:16:00.651Z" },
687
- { url = "https://files.pythonhosted.org/packages/c2/56/c9ec97bd11240abef39b9e5d99a15462809c45f677420fd148a6c5e6295e/orjson-3.11.8-cp314-cp314-macosx_15_0_arm64.whl", hash = "sha256:c492a0e011c0f9066e9ceaa896fbc5b068c54d365fea5f3444b697ee01bc8625", size = 128746, upload-time = "2026-03-31T16:16:02.673Z" },
688
- { url = "https://files.pythonhosted.org/packages/3b/e4/66d4f30a90de45e2f0cbd9623588e8ae71eef7679dbe2ae954ed6d66a41f/orjson-3.11.8-cp314-cp314-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:883206d55b1bd5f5679ad5e6ddd3d1a5e3cac5190482927fdb8c78fb699193b5", size = 131867, upload-time = "2026-03-31T16:16:04.342Z" },
689
- { url = "https://files.pythonhosted.org/packages/19/30/2a645fc9286b928675e43fa2a3a16fb7b6764aa78cc719dc82141e00f30b/orjson-3.11.8-cp314-cp314-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:5774c1fdcc98b2259800b683b19599c133baeb11d60033e2095fd9d4667b82db", size = 124664, upload-time = "2026-03-31T16:16:05.837Z" },
690
- { url = "https://files.pythonhosted.org/packages/db/44/77b9a86d84a28d52ba3316d77737f6514e17118119ade3f91b639e859029/orjson-3.11.8-cp314-cp314-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:8ac7381c83dd3d4a6347e6635950aa448f54e7b8406a27c7ecb4a37e9f1ae08b", size = 129701, upload-time = "2026-03-31T16:16:07.407Z" },
691
- { url = "https://files.pythonhosted.org/packages/b3/ea/eff3d9bfe47e9bc6969c9181c58d9f71237f923f9c86a2d2f490cd898c82/orjson-3.11.8-cp314-cp314-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:14439063aebcb92401c11afc68ee4e407258d2752e62d748b6942dad20d2a70d", size = 141202, upload-time = "2026-03-31T16:16:09.48Z" },
692
- { url = "https://files.pythonhosted.org/packages/52/c8/90d4b4c60c84d62068d0cf9e4d8f0a4e05e76971d133ac0c60d818d4db20/orjson-3.11.8-cp314-cp314-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:fa72e71977bff96567b0f500fc5bfd2fdf915f34052c782a4c6ebbdaa97aa858", size = 127194, upload-time = "2026-03-31T16:16:11.02Z" },
693
- { url = "https://files.pythonhosted.org/packages/8d/c7/ea9e08d1f0ba981adffb629811148b44774d935171e7b3d780ae43c4c254/orjson-3.11.8-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7679bc2f01bb0d219758f1a5f87bb7c8a81c0a186824a393b366876b4948e14f", size = 133639, upload-time = "2026-03-31T16:16:13.434Z" },
694
- { url = "https://files.pythonhosted.org/packages/6c/8c/ddbbfd6ba59453c8fc7fe1d0e5983895864e264c37481b2a791db635f046/orjson-3.11.8-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:14f7b8fcb35ef403b42fa5ecfa4ed032332a91f3dc7368fbce4184d59e1eae0d", size = 141914, upload-time = "2026-03-31T16:16:14.955Z" },
695
- { url = "https://files.pythonhosted.org/packages/4e/31/dbfbefec9df060d34ef4962cd0afcb6fa7a9ec65884cb78f04a7859526c3/orjson-3.11.8-cp314-cp314-musllinux_1_2_armv7l.whl", hash = "sha256:c2bdf7b2facc80b5e34f48a2d557727d5c5c57a8a450de122ae81fa26a81c1bc", size = 423800, upload-time = "2026-03-31T16:16:16.594Z" },
696
- { url = "https://files.pythonhosted.org/packages/87/cf/f74e9ae9803d4ab46b163494adba636c6d7ea955af5cc23b8aaa94cfd528/orjson-3.11.8-cp314-cp314-musllinux_1_2_i686.whl", hash = "sha256:ccd7ba1b0605813a0715171d39ec4c314cb97a9c85893c2c5c0c3a3729df38bf", size = 147837, upload-time = "2026-03-31T16:16:18.585Z" },
697
- { url = "https://files.pythonhosted.org/packages/64/e6/9214f017b5db85e84e68602792f742e5dc5249e963503d1b356bee611e01/orjson-3.11.8-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:cdbc8c9c02463fef4d3c53a9ba3336d05496ec8e1f1c53326a1e4acc11f5c600", size = 136441, upload-time = "2026-03-31T16:16:20.151Z" },
698
- { url = "https://files.pythonhosted.org/packages/24/dd/3590348818f58f837a75fb969b04cdf187ae197e14d60b5e5a794a38b79d/orjson-3.11.8-cp314-cp314-win32.whl", hash = "sha256:0b57f67710a8cd459e4e54eb96d5f77f3624eba0c661ba19a525807e42eccade", size = 131983, upload-time = "2026-03-31T16:16:21.823Z" },
699
- { url = "https://files.pythonhosted.org/packages/3f/0f/b6cb692116e05d058f31ceee819c70f097fa9167c82f67fabe7516289abc/orjson-3.11.8-cp314-cp314-win_amd64.whl", hash = "sha256:735e2262363dcbe05c35e3a8869898022af78f89dde9e256924dc02e99fe69ca", size = 127396, upload-time = "2026-03-31T16:16:23.685Z" },
700
- { url = "https://files.pythonhosted.org/packages/c0/d1/facb5b5051fabb0ef9d26c6544d87ef19a939a9a001198655d0d891062dd/orjson-3.11.8-cp314-cp314-win_arm64.whl", hash = "sha256:6ccdea2c213cf9f3d9490cbd5d427693c870753df41e6cb375bd79bcbafc8817", size = 127330, upload-time = "2026-03-31T16:16:25.496Z" },
701
- ]
702
-
703
680
  [[package]]
704
681
  name = "packaging"
705
682
  version = "26.1"
@@ -1022,7 +999,6 @@ dependencies = [
1022
999
  { name = "msgpack" },
1023
1000
  { name = "msgspec" },
1024
1001
  { name = "object-storage-client" },
1025
- { name = "orjson" },
1026
1002
  { name = "pydantic-settings" },
1027
1003
  { name = "sqlalchemy", extra = ["asyncio"] },
1028
1004
  { name = "valkey", extra = ["libvalkey"] },
@@ -1055,7 +1031,6 @@ requires-dist = [
1055
1031
  { name = "msgpack", specifier = "~=1.1.2" },
1056
1032
  { name = "msgspec", specifier = "==0.21.1" },
1057
1033
  { name = "object-storage-client", specifier = "==0.0.22" },
1058
- { name = "orjson", specifier = "==3.11.8" },
1059
1034
  { name = "pydantic-settings", specifier = "~=2.14.0" },
1060
1035
  { name = "sqlalchemy", extras = ["asyncio"], specifier = "~=2.0.49" },
1061
1036
  { name = "valkey", extras = ["libvalkey"], specifier = "~=6.1.1" },