mxm-types 0.1.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.
mxm/types/__init__.py ADDED
@@ -0,0 +1,57 @@
1
+ """
2
+ Tiny, stable, dependency-free: canonical JSON/path aliases and a micro-protocol
3
+ shared across Money Ex Machina packages.
4
+ """
5
+
6
+ from __future__ import annotations
7
+
8
+ from collections.abc import Mapping, Sequence
9
+ from os import PathLike
10
+ from typing import Any, Protocol, TypedDict, runtime_checkable
11
+ from typing import Literal # stricter options for CLIFormatOptions.format
12
+
13
+ # JSON types ---------------------------------------------------------------------------
14
+
15
+ # Scalars exactly representable in JSON (+ None)
16
+ type JSONScalar = str | int | float | bool | None
17
+
18
+ # Strict JSON: only list/dict at inner nodes. Best for real JSON round-trips.
19
+ type JSONValue = JSONScalar | list[JSONValue] | dict[str, JSONValue]
20
+
21
+ # Permissive JSON-like: accept any Sequence/Mapping at inner nodes (for inputs).
22
+ type JSONLike = JSONScalar | Sequence[JSONLike] | Mapping[str, JSONLike]
23
+
24
+ # Top-level mapping conveniences
25
+ type JSONObj = Mapping[str, JSONValue] # preferred for params (read-only interface)
26
+ type JSONMap = dict[str, JSONValue] # preferred for concrete, mutable results
27
+
28
+ # Path-like ----------------------------------------------------------------------------
29
+
30
+ type StrPath = str | PathLike[str]
31
+
32
+ # Minimal shared protocol(s) -----------------------------------------------------------
33
+
34
+
35
+ @runtime_checkable
36
+ class KVReadable(Protocol):
37
+ """Any mapping-like with a `get` method (without requiring full Mapping)."""
38
+
39
+ def get(self, key: str, default: Any = ...) -> Any: ...
40
+
41
+
42
+ class CLIFormatOptions(TypedDict, total=False):
43
+ """Optional CLI format hints used across MXM command outputs."""
44
+
45
+ format: Literal["plain", "rich", "json"]
46
+
47
+
48
+ __all__ = [
49
+ "CLIFormatOptions",
50
+ "JSONLike",
51
+ "JSONMap",
52
+ "JSONObj",
53
+ "JSONScalar",
54
+ "JSONValue",
55
+ "KVReadable",
56
+ "StrPath",
57
+ ]
mxm/types/py.typed ADDED
File without changes
@@ -0,0 +1,128 @@
1
+ Metadata-Version: 2.4
2
+ Name: mxm-types
3
+ Version: 0.1.0
4
+ Summary: Shared typing primitives for Money Ex Machina.
5
+ License: MIT
6
+ License-File: LICENSE
7
+ Keywords: money-ex-machina,typing,json,types,pep561
8
+ Author: mxm
9
+ Author-email: contact@moneyexmachina.com
10
+ Requires-Python: >=3.13,<3.15
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.13
16
+ Classifier: Programming Language :: Python :: 3.14
17
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
18
+ Classifier: Typing :: Typed
19
+ Project-URL: Homepage, https://github.com/moneyexmachina/
20
+ Project-URL: Issues, https://github.com/moneyexmachina/mxm-types/issues
21
+ Project-URL: Repository, https://github.com/moneyexmachina/mxm-types
22
+ Description-Content-Type: text/markdown
23
+
24
+ # `mxm-types`
25
+
26
+ ![Version](https://img.shields.io/github/v/release/moneyexmachina/mxm-types)
27
+ ![License](https://img.shields.io/github/license/moneyexmachina/mxm-types)
28
+ ![Python](https://img.shields.io/badge/python-3.13+-blue)
29
+ [![Checked with pyright](https://microsoft.github.io/pyright/img/pyright_badge.svg)](https://microsoft.github.io/pyright/)
30
+
31
+ Shared typing primitives for the Money Ex Machina ecosystem.
32
+
33
+ `mxm-types` provides a canonical, dependency-free set of JSON/path aliases and micro-protocols used across MXM packages.
34
+ It is intentionally small, stable, and domain-agnostic. All domain models live in their respective packages.
35
+
36
+ ## Install
37
+
38
+ ```bash
39
+ pip install mxm-types
40
+ ```
41
+
42
+ ## Overview
43
+
44
+ `mxm-types` defines:
45
+
46
+ - **Strict JSON tree types** for use across configuration, metadata, requests, and portable data structures.
47
+ - **Lightweight aliases** for common patterns (e.g., path-like values).
48
+ - **Micro-protocols** for cross-cutting interfaces (e.g., objects with a `get` method).
49
+ - **PEP 561 typing support** (`py.typed` included in the wheel).
50
+
51
+ The package has **no runtime dependencies**.
52
+
53
+ ## Public API
54
+
55
+ The following names form the stable public API of `mxm-types`.
56
+ All other names are private and may change across releases.
57
+
58
+ ### JSON Types
59
+
60
+ | Name | Description |
61
+ |---------------|-------------|
62
+ | `JSONScalar` | `str \| int \| float \| bool \| None` |
63
+ | `JSONValue` | Strict recursive JSON tree: scalars, `list[JSONValue]`, `dict[str, JSONValue]` |
64
+ | `JSONLike` | Permissive tree for accepting general `Sequence`/`Mapping` inputs |
65
+ | `JSONObj` | `Mapping[str, JSONValue]` — preferred for function parameters |
66
+ | `JSONMap` | `dict[str, JSONValue]` — preferred for concrete, mutable results |
67
+
68
+ ### Paths
69
+
70
+ | Name | Description |
71
+ |------------|-------------|
72
+ | `StrPath` | `str \| PathLike[str]` |
73
+
74
+ ### Protocols and TypedDicts
75
+
76
+ | Name | Description |
77
+ |--------------------|-------------|
78
+ | `KVReadable` | Minimal protocol: objects exposing a `get(key, default)` method |
79
+ | `CLIFormatOptions` | Optional formatting hints for CLI output (`"plain" \| "rich" \| "json"`) |
80
+
81
+ ---
82
+
83
+ ## Usage
84
+
85
+ ```python
86
+ from mxm.types import (
87
+ JSONValue,
88
+ JSONObj,
89
+ JSONMap,
90
+ StrPath,
91
+ KVReadable,
92
+ CLIFormatOptions,
93
+ )
94
+
95
+ def load_metadata(path: StrPath) -> JSONObj:
96
+ ...
97
+ ```
98
+
99
+ For permissive JSON acceptance (e.g., reading config from arbitrary Python structures):
100
+
101
+ ```python
102
+ from mxm.types import JSONLike
103
+
104
+ def normalise(data: JSONLike) -> JSONValue:
105
+ ...
106
+ ```
107
+
108
+ ## Design Principles
109
+
110
+ - **Minimal surface**: only house-style primitives, no domain models.
111
+ - **Dependency-free**: safe to import everywhere, including low-level layers.
112
+ - **PEP 695 `type` aliases**: modern, expressive, static-typing-friendly.
113
+ - **Strict JSON encouraged**: permissive types optional and explicit.
114
+
115
+ ## Development
116
+
117
+ ```bash
118
+ poetry install
119
+ poetry run ruff check .
120
+ poetry run pyright
121
+ poetry run pytest -q
122
+ poetry build
123
+ ```
124
+
125
+ ## License
126
+
127
+ MIT License. See [LICENSE](LICENSE).
128
+
@@ -0,0 +1,6 @@
1
+ mxm/types/__init__.py,sha256=lXmThrbVQq3x7_CWQLSvrcifU9BkCq-4v91Fuf_j4J4,1791
2
+ mxm/types/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
+ mxm_types-0.1.0.dist-info/METADATA,sha256=AhpdeDziLM5O5u9o9xgjIP95HPi3G3gux9tP8XUSAjo,3938
4
+ mxm_types-0.1.0.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
5
+ mxm_types-0.1.0.dist-info/licenses/LICENSE,sha256=xq8z6L9uQsxwFsDj_rw0gXHSqp5V--ukyKkts-q4Zsc,1101
6
+ mxm_types-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: poetry-core 2.2.1
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Money Ex Machina
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the “Software”), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.