mxm-types 0.1.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.
- mxm_types-0.1.0/LICENSE +21 -0
- mxm_types-0.1.0/PKG-INFO +128 -0
- mxm_types-0.1.0/README.md +104 -0
- mxm_types-0.1.0/pyproject.toml +69 -0
- mxm_types-0.1.0/src/mxm/types/__init__.py +57 -0
- mxm_types-0.1.0/src/mxm/types/py.typed +0 -0
mxm_types-0.1.0/LICENSE
ADDED
|
@@ -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.
|
mxm_types-0.1.0/PKG-INFO
ADDED
|
@@ -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
|
+

|
|
27
|
+

|
|
28
|
+

|
|
29
|
+
[](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,104 @@
|
|
|
1
|
+
# `mxm-types`
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+

|
|
5
|
+

|
|
6
|
+
[](https://microsoft.github.io/pyright/)
|
|
7
|
+
|
|
8
|
+
Shared typing primitives for the Money Ex Machina ecosystem.
|
|
9
|
+
|
|
10
|
+
`mxm-types` provides a canonical, dependency-free set of JSON/path aliases and micro-protocols used across MXM packages.
|
|
11
|
+
It is intentionally small, stable, and domain-agnostic. All domain models live in their respective packages.
|
|
12
|
+
|
|
13
|
+
## Install
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
pip install mxm-types
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Overview
|
|
20
|
+
|
|
21
|
+
`mxm-types` defines:
|
|
22
|
+
|
|
23
|
+
- **Strict JSON tree types** for use across configuration, metadata, requests, and portable data structures.
|
|
24
|
+
- **Lightweight aliases** for common patterns (e.g., path-like values).
|
|
25
|
+
- **Micro-protocols** for cross-cutting interfaces (e.g., objects with a `get` method).
|
|
26
|
+
- **PEP 561 typing support** (`py.typed` included in the wheel).
|
|
27
|
+
|
|
28
|
+
The package has **no runtime dependencies**.
|
|
29
|
+
|
|
30
|
+
## Public API
|
|
31
|
+
|
|
32
|
+
The following names form the stable public API of `mxm-types`.
|
|
33
|
+
All other names are private and may change across releases.
|
|
34
|
+
|
|
35
|
+
### JSON Types
|
|
36
|
+
|
|
37
|
+
| Name | Description |
|
|
38
|
+
|---------------|-------------|
|
|
39
|
+
| `JSONScalar` | `str \| int \| float \| bool \| None` |
|
|
40
|
+
| `JSONValue` | Strict recursive JSON tree: scalars, `list[JSONValue]`, `dict[str, JSONValue]` |
|
|
41
|
+
| `JSONLike` | Permissive tree for accepting general `Sequence`/`Mapping` inputs |
|
|
42
|
+
| `JSONObj` | `Mapping[str, JSONValue]` — preferred for function parameters |
|
|
43
|
+
| `JSONMap` | `dict[str, JSONValue]` — preferred for concrete, mutable results |
|
|
44
|
+
|
|
45
|
+
### Paths
|
|
46
|
+
|
|
47
|
+
| Name | Description |
|
|
48
|
+
|------------|-------------|
|
|
49
|
+
| `StrPath` | `str \| PathLike[str]` |
|
|
50
|
+
|
|
51
|
+
### Protocols and TypedDicts
|
|
52
|
+
|
|
53
|
+
| Name | Description |
|
|
54
|
+
|--------------------|-------------|
|
|
55
|
+
| `KVReadable` | Minimal protocol: objects exposing a `get(key, default)` method |
|
|
56
|
+
| `CLIFormatOptions` | Optional formatting hints for CLI output (`"plain" \| "rich" \| "json"`) |
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
## Usage
|
|
61
|
+
|
|
62
|
+
```python
|
|
63
|
+
from mxm.types import (
|
|
64
|
+
JSONValue,
|
|
65
|
+
JSONObj,
|
|
66
|
+
JSONMap,
|
|
67
|
+
StrPath,
|
|
68
|
+
KVReadable,
|
|
69
|
+
CLIFormatOptions,
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
def load_metadata(path: StrPath) -> JSONObj:
|
|
73
|
+
...
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
For permissive JSON acceptance (e.g., reading config from arbitrary Python structures):
|
|
77
|
+
|
|
78
|
+
```python
|
|
79
|
+
from mxm.types import JSONLike
|
|
80
|
+
|
|
81
|
+
def normalise(data: JSONLike) -> JSONValue:
|
|
82
|
+
...
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## Design Principles
|
|
86
|
+
|
|
87
|
+
- **Minimal surface**: only house-style primitives, no domain models.
|
|
88
|
+
- **Dependency-free**: safe to import everywhere, including low-level layers.
|
|
89
|
+
- **PEP 695 `type` aliases**: modern, expressive, static-typing-friendly.
|
|
90
|
+
- **Strict JSON encouraged**: permissive types optional and explicit.
|
|
91
|
+
|
|
92
|
+
## Development
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
poetry install
|
|
96
|
+
poetry run ruff check .
|
|
97
|
+
poetry run pyright
|
|
98
|
+
poetry run pytest -q
|
|
99
|
+
poetry build
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## License
|
|
103
|
+
|
|
104
|
+
MIT License. See [LICENSE](LICENSE).
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
[tool.poetry]
|
|
2
|
+
name = "mxm-types"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "Shared typing primitives for Money Ex Machina."
|
|
5
|
+
authors = ["mxm <contact@moneyexmachina.com>"]
|
|
6
|
+
license = "MIT"
|
|
7
|
+
readme = "README.md"
|
|
8
|
+
keywords = ["money-ex-machina", "typing", "json", "types", "pep561"]
|
|
9
|
+
classifiers = [
|
|
10
|
+
"Development Status :: 3 - Alpha",
|
|
11
|
+
"Intended Audience :: Developers",
|
|
12
|
+
"Programming Language :: Python :: 3",
|
|
13
|
+
"License :: OSI Approved :: MIT License",
|
|
14
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
15
|
+
"Typing :: Typed",
|
|
16
|
+
]
|
|
17
|
+
packages = [{ include = "mxm", from = "src" }]
|
|
18
|
+
include = [
|
|
19
|
+
{ path = "LICENSE" },
|
|
20
|
+
{ path = "src/mxm/types/py.typed", format = "wheel" },
|
|
21
|
+
]
|
|
22
|
+
|
|
23
|
+
[tool.poetry.urls]
|
|
24
|
+
"Homepage" = "https://github.com/moneyexmachina/"
|
|
25
|
+
"Repository" = "https://github.com/moneyexmachina/mxm-types"
|
|
26
|
+
"Issues" = "https://github.com/moneyexmachina/mxm-types/issues"
|
|
27
|
+
|
|
28
|
+
[tool.poetry.dependencies]
|
|
29
|
+
python = ">=3.13,<3.15"
|
|
30
|
+
|
|
31
|
+
[tool.poetry.group.dev.dependencies]
|
|
32
|
+
ruff = "^0.14.3"
|
|
33
|
+
black = "^25.9.0"
|
|
34
|
+
isort = "^7.0.0"
|
|
35
|
+
ipython = "^9.5.0"
|
|
36
|
+
pytest = "^8.4.2"
|
|
37
|
+
pyright = "^1.1.407"
|
|
38
|
+
|
|
39
|
+
[tool.poetry.scripts]
|
|
40
|
+
# (none)
|
|
41
|
+
|
|
42
|
+
[build-system]
|
|
43
|
+
requires = ["poetry-core>=2.0.0,<3.0.0"]
|
|
44
|
+
build-backend = "poetry.core.masonry.api"
|
|
45
|
+
|
|
46
|
+
[tool.ruff]
|
|
47
|
+
line-length = 88
|
|
48
|
+
target-version = "py313"
|
|
49
|
+
exclude = ["build", "dist", ".venv"]
|
|
50
|
+
|
|
51
|
+
[tool.ruff.lint]
|
|
52
|
+
select = ["E","F","B","UP","C90","RUF"]
|
|
53
|
+
ignore = ["E203","E501","I001","I002"]
|
|
54
|
+
|
|
55
|
+
[tool.black]
|
|
56
|
+
line-length = 88
|
|
57
|
+
target-version = ["py313"]
|
|
58
|
+
|
|
59
|
+
[tool.isort]
|
|
60
|
+
profile = "black"
|
|
61
|
+
line_length = 88
|
|
62
|
+
known_first_party = ["mxm"]
|
|
63
|
+
combine_as_imports = true
|
|
64
|
+
force_sort_within_sections = true
|
|
65
|
+
lines_between_types = 1
|
|
66
|
+
|
|
67
|
+
[tool.pytest.ini_options]
|
|
68
|
+
addopts = "-q"
|
|
69
|
+
pythonpath = ["src"]
|
|
@@ -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
|
+
]
|
|
File without changes
|