chutils 2.7.4__tar.gz → 2.9.0__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 (94) hide show
  1. {chutils-2.7.4 → chutils-2.9.0}/PKG-INFO +52 -3
  2. {chutils-2.7.4 → chutils-2.9.0}/README.md +380 -341
  3. {chutils-2.7.4 → chutils-2.9.0}/pyproject.toml +40 -2
  4. {chutils-2.7.4 → chutils-2.9.0}/src/chutils/__init__.py +56 -0
  5. chutils-2.9.0/src/chutils/__init__.pyi +485 -0
  6. chutils-2.9.0/src/chutils/__main__.py +4 -0
  7. {chutils-2.7.4 → chutils-2.9.0}/src/chutils/cache/base.py +17 -15
  8. {chutils-2.7.4 → chutils-2.9.0}/src/chutils/cache/decorator.py +8 -8
  9. {chutils-2.7.4 → chutils-2.9.0}/src/chutils/cache/in_memory.py +48 -7
  10. chutils-2.9.0/src/chutils/cli.py +112 -0
  11. {chutils-2.7.4 → chutils-2.9.0}/src/chutils/cli_booster.py +21 -18
  12. {chutils-2.7.4 → chutils-2.9.0}/src/chutils/cli_utils.py +48 -14
  13. {chutils-2.7.4 → chutils-2.9.0}/src/chutils/commands/base.py +6 -3
  14. {chutils-2.7.4 → chutils-2.9.0}/src/chutils/commands/config.py +87 -11
  15. chutils-2.9.0/src/chutils/commands/dev.py +352 -0
  16. {chutils-2.7.4 → chutils-2.9.0}/src/chutils/commands/init.py +15 -8
  17. {chutils-2.7.4 → chutils-2.9.0}/src/chutils/commands/paths.py +5 -3
  18. {chutils-2.7.4 → chutils-2.9.0}/src/chutils/commands/secrets.py +32 -21
  19. {chutils-2.7.4 → chutils-2.9.0}/src/chutils/commands/template.py +29 -12
  20. {chutils-2.7.4 → chutils-2.9.0}/src/chutils/commands/validate.py +30 -16
  21. {chutils-2.7.4 → chutils-2.9.0}/src/chutils/config/__init__.py +35 -15
  22. chutils-2.9.0/src/chutils/config/ast_fallback_parser.py +137 -0
  23. {chutils-2.7.4 → chutils-2.9.0}/src/chutils/config/core.py +112 -33
  24. chutils-2.9.0/src/chutils/config/dev.py +142 -0
  25. {chutils-2.7.4 → chutils-2.9.0}/src/chutils/config/diagnostics.py +13 -7
  26. {chutils-2.7.4 → chutils-2.9.0}/src/chutils/config/generator.py +21 -17
  27. {chutils-2.7.4 → chutils-2.9.0}/src/chutils/config/getters.py +58 -47
  28. {chutils-2.7.4 → chutils-2.9.0}/src/chutils/config/manager.py +72 -47
  29. {chutils-2.7.4 → chutils-2.9.0}/src/chutils/config/providers.py +75 -37
  30. {chutils-2.7.4 → chutils-2.9.0}/src/chutils/config/schema.py +28 -22
  31. {chutils-2.7.4 → chutils-2.9.0}/src/chutils/config/utils.py +111 -10
  32. {chutils-2.7.4 → chutils-2.9.0}/src/chutils/config/watcher.py +15 -10
  33. {chutils-2.7.4 → chutils-2.9.0}/src/chutils/context.py +15 -7
  34. chutils-2.9.0/src/chutils/crypto.py +163 -0
  35. chutils-2.9.0/src/chutils/decorators.py +418 -0
  36. chutils-2.9.0/src/chutils/dev/__init__.py +12 -0
  37. chutils-2.9.0/src/chutils/dev/ai_lint.py +314 -0
  38. {chutils-2.7.4 → chutils-2.9.0}/src/chutils/dev/ast_indexer.py +206 -42
  39. {chutils-2.7.4 → chutils-2.9.0}/src/chutils/dev/models.py +22 -3
  40. chutils-2.9.0/src/chutils/dev/rules.py +524 -0
  41. chutils-2.9.0/src/chutils/di/__init__.py +9 -0
  42. chutils-2.9.0/src/chutils/di/container.py +302 -0
  43. {chutils-2.7.4 → chutils-2.9.0}/src/chutils/env.py +15 -0
  44. chutils-2.9.0/src/chutils/events/__init__.py +23 -0
  45. chutils-2.9.0/src/chutils/events/core.py +257 -0
  46. chutils-2.9.0/src/chutils/exceptions.py +175 -0
  47. {chutils-2.7.4 → chutils-2.9.0}/src/chutils/features.py +22 -18
  48. chutils-2.9.0/src/chutils/fs.py +461 -0
  49. {chutils-2.7.4 → chutils-2.9.0}/src/chutils/lifecycle.py +30 -20
  50. chutils-2.9.0/src/chutils/logger/__init__.py +59 -0
  51. chutils-2.9.0/src/chutils/logger/core.py +224 -0
  52. chutils-2.9.0/src/chutils/logger/formatters.py +78 -0
  53. {chutils-2.7.4 → chutils-2.9.0}/src/chutils/logger/handlers.py +5 -5
  54. chutils-2.9.0/src/chutils/logger/internal/builder.py +424 -0
  55. chutils-2.9.0/src/chutils/logger/internal/levels.py +58 -0
  56. chutils-2.9.0/src/chutils/logger/internal/utils.py +60 -0
  57. {chutils-2.7.4 → chutils-2.9.0}/src/chutils/logger/masking.py +25 -11
  58. chutils-2.9.0/src/chutils/metrics/__init__.py +135 -0
  59. chutils-2.9.0/src/chutils/metrics/base.py +43 -0
  60. chutils-2.9.0/src/chutils/metrics/in_memory.py +141 -0
  61. chutils-2.9.0/src/chutils/metrics/prometheus.py +88 -0
  62. chutils-2.9.0/src/chutils/metrics/timer.py +72 -0
  63. chutils-2.9.0/src/chutils/plugins/__init__.py +24 -0
  64. chutils-2.9.0/src/chutils/plugins/core.py +124 -0
  65. chutils-2.9.0/src/chutils/plugins/interfaces.py +74 -0
  66. {chutils-2.7.4 → chutils-2.9.0}/src/chutils/secret_manager/core.py +23 -2
  67. {chutils-2.7.4 → chutils-2.9.0}/src/chutils/secret_manager/providers.py +3 -2
  68. chutils-2.9.0/src/chutils/tasks/__init__.py +22 -0
  69. chutils-2.9.0/src/chutils/tasks/core.py +254 -0
  70. {chutils-2.7.4 → chutils-2.9.0}/src/chutils/testing/fixtures.py +5 -4
  71. chutils-2.9.0/src/chutils/text.py +58 -0
  72. {chutils-2.7.4 → chutils-2.9.0}/src/chutils/time.py +10 -8
  73. {chutils-2.7.4 → chutils-2.9.0}/src/chutils/tracing.py +23 -23
  74. chutils-2.9.0/src/chutils/typing.py +73 -0
  75. chutils-2.7.4/src/chutils/__init__.pyi +0 -226
  76. chutils-2.7.4/src/chutils/cli.py +0 -57
  77. chutils-2.7.4/src/chutils/commands/dev.py +0 -172
  78. chutils-2.7.4/src/chutils/decorators.py +0 -208
  79. chutils-2.7.4/src/chutils/dev/__init__.py +0 -3
  80. chutils-2.7.4/src/chutils/exceptions.py +0 -86
  81. chutils-2.7.4/src/chutils/fs.py +0 -130
  82. chutils-2.7.4/src/chutils/logger/__init__.py +0 -38
  83. chutils-2.7.4/src/chutils/logger/core.py +0 -526
  84. chutils-2.7.4/src/chutils/logger/formatters.py +0 -52
  85. {chutils-2.7.4 → chutils-2.9.0}/LICENSE +0 -0
  86. {chutils-2.7.4 → chutils-2.9.0}/src/chutils/cache/__init__.py +0 -0
  87. {chutils-2.7.4 → chutils-2.9.0}/src/chutils/cache/utils.py +0 -0
  88. {chutils-2.7.4 → chutils-2.9.0}/src/chutils/commands/__init__.py +0 -0
  89. {chutils-2.7.4 → chutils-2.9.0}/src/chutils/commands/utils.py +0 -0
  90. {chutils-2.7.4 → chutils-2.9.0}/src/chutils/config/GEMINI.md +0 -0
  91. {chutils-2.7.4 → chutils-2.9.0}/src/chutils/logger/GEMINI.md +0 -0
  92. {chutils-2.7.4 → chutils-2.9.0}/src/chutils/secret_manager/GEMINI.md +0 -0
  93. {chutils-2.7.4 → chutils-2.9.0}/src/chutils/secret_manager/__init__.py +0 -0
  94. {chutils-2.7.4 → chutils-2.9.0}/src/chutils/testing/__init__.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: chutils
3
- Version: 2.7.4
3
+ Version: 2.9.0
4
4
  Summary: Набор простых и удобных утилит для Python, который избавляет от рутины при работе с конфигурацией и логированием в новых проектах.
5
5
  License-Expression: MIT
6
6
  License-File: LICENSE
@@ -13,15 +13,20 @@ Classifier: Programming Language :: Python :: 3.11
13
13
  Classifier: Programming Language :: Python :: 3.12
14
14
  Classifier: Programming Language :: Python :: 3.13
15
15
  Classifier: Programming Language :: Python :: 3.14
16
+ Provides-Extra: crypto
16
17
  Provides-Extra: date
17
18
  Provides-Extra: full
18
19
  Provides-Extra: json
20
+ Provides-Extra: metrics
19
21
  Provides-Extra: otel
20
22
  Provides-Extra: pydantic
21
23
  Provides-Extra: rich
22
24
  Provides-Extra: secrets
23
25
  Provides-Extra: testing
26
+ Provides-Extra: text
24
27
  Provides-Extra: watch
28
+ Requires-Dist: cryptography (>=42.0.0) ; extra == "crypto"
29
+ Requires-Dist: cryptography (>=42.0.0) ; extra == "full"
25
30
  Requires-Dist: keyring (>=25.7.0)
26
31
  Requires-Dist: keyring (>=25.7.0) ; extra == "full"
27
32
  Requires-Dist: keyring (>=25.7.0) ; extra == "secrets"
@@ -31,6 +36,8 @@ Requires-Dist: opentelemetry-exporter-otlp (>=1.41.1) ; extra == "full"
31
36
  Requires-Dist: opentelemetry-exporter-otlp (>=1.41.1) ; extra == "otel"
32
37
  Requires-Dist: opentelemetry-sdk (>=1.41.1) ; extra == "full"
33
38
  Requires-Dist: opentelemetry-sdk (>=1.41.1) ; extra == "otel"
39
+ Requires-Dist: prometheus-client (>=0.20.0,<1.0.0) ; extra == "full"
40
+ Requires-Dist: prometheus-client (>=0.20.0,<1.0.0) ; extra == "metrics"
34
41
  Requires-Dist: pydantic (>=2.13.4) ; extra == "full"
35
42
  Requires-Dist: pydantic (>=2.13.4,<3.0.0) ; extra == "pydantic"
36
43
  Requires-Dist: pytest (>=8.0.0) ; (python_full_version < "3.10.0") and (extra == "full")
@@ -44,8 +51,11 @@ Requires-Dist: python-dotenv (>=1.2.2) ; python_full_version >= "3.10.0"
44
51
  Requires-Dist: python-json-logger (>=3.2.1) ; extra == "full"
45
52
  Requires-Dist: python-json-logger (>=3.2.1) ; extra == "json"
46
53
  Requires-Dist: pyyaml (>=6.0.3)
54
+ Requires-Dist: rapidfuzz (>=3.9.0) ; extra == "full"
55
+ Requires-Dist: rapidfuzz (>=3.9.0) ; extra == "text"
47
56
  Requires-Dist: rich (>=15.0.0) ; extra == "full"
48
57
  Requires-Dist: rich (>=15.0.0) ; extra == "rich"
58
+ Requires-Dist: typing-extensions (>=4.15.0,<5.0.0)
49
59
  Requires-Dist: watchdog (>=6.0.0) ; extra == "full"
50
60
  Requires-Dist: watchdog (>=6.0.0) ; extra == "watch"
51
61
  Description-Content-Type: text/markdown
@@ -95,6 +105,10 @@ Every time you start a new project, you have to solve the same tasks:
95
105
  - **🌐 Remote Configuration:** Load settings from HTTP/HTTPS endpoints with background polling and fallback support.
96
106
  - **🔄 Hot-Reload:** Support for automatic configuration reloading on file changes without restart (requires
97
107
  `pip install chutils[watch]`).
108
+ - **🛡️ Secure Paths:** Prevent Path Traversal attacks by safely resolving file paths against a base directory using
109
+ `resolve_safe_path()`.
110
+ - **🤖 AI Linter:** Run static analysis checks on your codebase to ensure AI readiness (strict type hints, structured
111
+ docstrings, API map sync) via `chutils dev ai-lint`.
98
112
  - **⚡ Async Ready:** Most core functions have asynchronous versions (prefixed with `a`) for non-blocking execution.
99
113
  - **🚀 Ready to Use:** Just install and use.
100
114
 
@@ -212,10 +226,10 @@ To use this feature, install `watchdog`:
212
226
  1. Configure and use the logger:
213
227
 
214
228
  ```python
215
- from chutils import setup_logger, ChutilsLogger
229
+ from chutils import setup_logger_from_config, ChutilsLogger
216
230
 
217
231
  # Automatically reads settings from [Logging] section in config.yml
218
- logger: ChutilsLogger = setup_logger()
232
+ logger: ChutilsLogger = setup_logger_from_config()
219
233
 
220
234
  logger.info("Application started.")
221
235
  logger.devdebug("Deep debug message (level 9).")
@@ -282,6 +296,22 @@ In environments like Docker or CI/CD where `keyring` is unavailable, you can sup
282
296
  - Set `CH_DISABLE_KEYRING_WARNING=true` in environment.
283
297
  - Or add `disable_keyring: true` under `secrets` section in `config.yml`.
284
298
 
299
+ ### 4. Safe Path Resolution
300
+
301
+ Safely resolve relative and absolute paths against a base directory to prevent directory traversal vulnerabilities:
302
+
303
+ ```python
304
+ from chutils.fs import resolve_safe_path
305
+ from chutils.exceptions import PathTraversalError
306
+
307
+ try:
308
+ # Resolves path relative to the base directory and checks if it's safe
309
+ safe_path = resolve_safe_path("user_file.txt", base_dir="./sandbox")
310
+ print(f"Safe absolute path: {safe_path}")
311
+ except PathTraversalError as e:
312
+ print(f"Path traversal detected! Attempted: {e.context.get('attempted_path')}")
313
+ ```
314
+
285
315
  ## API Overview
286
316
 
287
317
  ### Configuration (`chutils.config`)
@@ -310,6 +340,11 @@ In environments like Docker or CI/CD where `keyring` is unavailable, you can sup
310
340
  - `@retry`: Automatically retries a function if it fails. Supports sync/async, backoff, jitter, and exception filtering.
311
341
  - `@cli_command`: Turns any function into a standalone CLI script with automatic argument parsing.
312
342
 
343
+ ### File System (`chutils.fs`)
344
+
345
+ - `resolve_safe_path(path, base_dir)`: Safely resolves path and checks for Path Traversal attempts.
346
+ - `ensure_dir(path)`: Ensures directory exists.
347
+
313
348
  ### Time & Dates (`chutils.time`)
314
349
 
315
350
  - `utc_now()`: Returns a timezone-aware UTC datetime.
@@ -388,6 +423,20 @@ Trace exactly where each configuration value comes from:
388
423
  chutils config debug
389
424
  ```
390
425
 
426
+ ### 6. AI-Readiness Linter
427
+
428
+ Perform a static audit of your codebase to ensure it is optimized for AI developers and agents:
429
+
430
+ ```bash
431
+ # Run linter on the current project
432
+ chutils dev ai-lint
433
+
434
+ # Run linter in strict mode with ignored paths
435
+ chutils dev ai-lint --strict --ignore "temp/,build/"
436
+ ```
437
+
438
+ See [docs/ai_lint.md](docs/ai_lint.md) for more details.
439
+
391
440
  ## License
392
441
 
393
442
  The project is distributed under the MIT License.