mathema-language 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.
Files changed (163) hide show
  1. mathema_language-0.1.0/.github/ISSUE_TEMPLATE/missing-language.md +21 -0
  2. mathema_language-0.1.0/.github/workflows/publish.yml +142 -0
  3. mathema_language-0.1.0/.github/workflows/tests.yml +98 -0
  4. mathema_language-0.1.0/.gitignore +12 -0
  5. mathema_language-0.1.0/CHANGELOG.md +42 -0
  6. mathema_language-0.1.0/LICENSE +202 -0
  7. mathema_language-0.1.0/NOTICE +2 -0
  8. mathema_language-0.1.0/PKG-INFO +375 -0
  9. mathema_language-0.1.0/README.md +318 -0
  10. mathema_language-0.1.0/SECURITY.md +11 -0
  11. mathema_language-0.1.0/docs/adaptor-dataclass.md +80 -0
  12. mathema_language-0.1.0/docs/adaptor-django.md +108 -0
  13. mathema_language-0.1.0/docs/adaptor-jsonschema.md +85 -0
  14. mathema_language-0.1.0/docs/adaptor-pydantic.md +78 -0
  15. mathema_language-0.1.0/docs/adaptor-sqlalchemy.md +89 -0
  16. mathema_language-0.1.0/docs/adaptor-text.md +74 -0
  17. mathema_language-0.1.0/docs/adaptor-typeddict.md +73 -0
  18. mathema_language-0.1.0/docs/adaptors.md +136 -0
  19. mathema_language-0.1.0/docs/catalogue.md +238 -0
  20. mathema_language-0.1.0/docs/families.md +48 -0
  21. mathema_language-0.1.0/docs/formats.md +214 -0
  22. mathema_language-0.1.0/docs/how-to-narrow-a-language.md +150 -0
  23. mathema_language-0.1.0/docs/index.md +107 -0
  24. mathema_language-0.1.0/docs/json.md +98 -0
  25. mathema_language-0.1.0/docs/languages.md +81 -0
  26. mathema_language-0.1.0/docs/paths.md +63 -0
  27. mathema_language-0.1.0/docs/python-api.md +42 -0
  28. mathema_language-0.1.0/docs/records.md +179 -0
  29. mathema_language-0.1.0/docs/reference.yml +39 -0
  30. mathema_language-0.1.0/docs/refinements.md +55 -0
  31. mathema_language-0.1.0/docs/text.md +265 -0
  32. mathema_language-0.1.0/docs/trees.md +160 -0
  33. mathema_language-0.1.0/docs/tutorial-choosing-inputs.md +133 -0
  34. mathema_language-0.1.0/docs/tutorial-first-claim.md +270 -0
  35. mathema_language-0.1.0/docs/tutorial-formats.md +131 -0
  36. mathema_language-0.1.0/docs/tutorial-reading-a-result.md +213 -0
  37. mathema_language-0.1.0/docs/tutorial-records.md +213 -0
  38. mathema_language-0.1.0/docs/tutorial-trees.md +122 -0
  39. mathema_language-0.1.0/docs/vocabulary.md +49 -0
  40. mathema_language-0.1.0/docs/writing-a-language.md +65 -0
  41. mathema_language-0.1.0/examples/shop/__init__.py +5 -0
  42. mathema_language-0.1.0/examples/shop/config.py +22 -0
  43. mathema_language-0.1.0/examples/shop/db.py +32 -0
  44. mathema_language-0.1.0/examples/shop/formats.py +64 -0
  45. mathema_language-0.1.0/examples/shop/forms.py +57 -0
  46. mathema_language-0.1.0/examples/shop/reviews.py +41 -0
  47. mathema_language-0.1.0/examples/shop/search.py +24 -0
  48. mathema_language-0.1.0/examples/shop/shipping.py +25 -0
  49. mathema_language-0.1.0/examples/shop/skus.py +31 -0
  50. mathema_language-0.1.0/examples/shop/text.py +89 -0
  51. mathema_language-0.1.0/examples/shop/threads.py +28 -0
  52. mathema_language-0.1.0/examples/shop/uploads.py +16 -0
  53. mathema_language-0.1.0/examples/shop/urls.py +18 -0
  54. mathema_language-0.1.0/examples/shop/webhooks.py +26 -0
  55. mathema_language-0.1.0/pyproject.toml +131 -0
  56. mathema_language-0.1.0/src/mathema_language/__init__.py +22 -0
  57. mathema_language-0.1.0/src/mathema_language/_lexicon_models/__init__.py +5 -0
  58. mathema_language-0.1.0/src/mathema_language/_lexicon_models/db.py +22 -0
  59. mathema_language-0.1.0/src/mathema_language/_lexicon_models/forms.py +9 -0
  60. mathema_language-0.1.0/src/mathema_language/_lexicon_models/reviews.py +24 -0
  61. mathema_language-0.1.0/src/mathema_language/_lexicon_models/search.py +14 -0
  62. mathema_language-0.1.0/src/mathema_language/_lexicon_models/webhooks.py +13 -0
  63. mathema_language-0.1.0/src/mathema_language/_surface.py +47 -0
  64. mathema_language-0.1.0/src/mathema_language/adaptor_priority.py +31 -0
  65. mathema_language-0.1.0/src/mathema_language/conformance.py +170 -0
  66. mathema_language-0.1.0/src/mathema_language/families/__init__.py +241 -0
  67. mathema_language-0.1.0/src/mathema_language/induction.py +359 -0
  68. mathema_language-0.1.0/src/mathema_language/lexicon.py +610 -0
  69. mathema_language-0.1.0/src/mathema_language/narrowing.py +163 -0
  70. mathema_language-0.1.0/src/mathema_language/py.typed +0 -0
  71. mathema_language-0.1.0/src/mathema_language/refinements.py +278 -0
  72. mathema_language-0.1.0/src/mathema_language/schema/__init__.py +22 -0
  73. mathema_language-0.1.0/src/mathema_language/schema/adaptors/__init__.py +28 -0
  74. mathema_language-0.1.0/src/mathema_language/schema/adaptors/_hints.py +201 -0
  75. mathema_language-0.1.0/src/mathema_language/schema/adaptors/dataclass.py +39 -0
  76. mathema_language-0.1.0/src/mathema_language/schema/adaptors/django.py +122 -0
  77. mathema_language-0.1.0/src/mathema_language/schema/adaptors/jsonschema.py +147 -0
  78. mathema_language-0.1.0/src/mathema_language/schema/adaptors/pydantic.py +45 -0
  79. mathema_language-0.1.0/src/mathema_language/schema/adaptors/sqlalchemy.py +129 -0
  80. mathema_language-0.1.0/src/mathema_language/schema/adaptors/typeddict.py +39 -0
  81. mathema_language-0.1.0/src/mathema_language/schema/checks.py +418 -0
  82. mathema_language-0.1.0/src/mathema_language/schema/ecosystems/__init__.py +8 -0
  83. mathema_language-0.1.0/src/mathema_language/schema/ecosystems/_base.py +35 -0
  84. mathema_language-0.1.0/src/mathema_language/schema/ecosystems/django.py +66 -0
  85. mathema_language-0.1.0/src/mathema_language/schema/ecosystems/jsonschema.py +57 -0
  86. mathema_language-0.1.0/src/mathema_language/schema/ecosystems/plain.py +63 -0
  87. mathema_language-0.1.0/src/mathema_language/schema/ecosystems/pydantic.py +75 -0
  88. mathema_language-0.1.0/src/mathema_language/schema/ecosystems/sqlalchemy.py +109 -0
  89. mathema_language-0.1.0/src/mathema_language/schema/generate.py +472 -0
  90. mathema_language-0.1.0/src/mathema_language/schema/languages.py +583 -0
  91. mathema_language-0.1.0/src/mathema_language/schema/model.py +222 -0
  92. mathema_language-0.1.0/src/mathema_language/schema/structure.py +87 -0
  93. mathema_language-0.1.0/src/mathema_language/text/__init__.py +101 -0
  94. mathema_language-0.1.0/src/mathema_language/text/_kit.py +75 -0
  95. mathema_language-0.1.0/src/mathema_language/text/alphabets.py +183 -0
  96. mathema_language-0.1.0/src/mathema_language/text/generate.py +65 -0
  97. mathema_language-0.1.0/src/mathema_language/text/hazards.py +109 -0
  98. mathema_language-0.1.0/src/mathema_language/text/json_structure.py +78 -0
  99. mathema_language-0.1.0/src/mathema_language/text/predicates.py +294 -0
  100. mathema_language-0.1.0/src/mathema_language/text/regex.py +122 -0
  101. mathema_language-0.1.0/src/mathema_language/tree.py +10 -0
  102. mathema_language-0.1.0/src/mathema_language/vocabulary/__init__.py +10 -0
  103. mathema_language-0.1.0/src/mathema_language/vocabulary/text.py +103 -0
  104. mathema_language-0.1.0/src/mathema_language/vocabulary/tree.py +121 -0
  105. mathema_language-0.1.0/tests/__init__.py +2 -0
  106. mathema_language-0.1.0/tests/_django_shapes.py +57 -0
  107. mathema_language-0.1.0/tests/_jsonschema_shapes.py +17 -0
  108. mathema_language-0.1.0/tests/_length_changing.py +9 -0
  109. mathema_language-0.1.0/tests/_narrowing_shapes.py +30 -0
  110. mathema_language-0.1.0/tests/_nested_orders.py +54 -0
  111. mathema_language-0.1.0/tests/_pydantic_shapes.py +17 -0
  112. mathema_language-0.1.0/tests/_recursive_pydantic.py +16 -0
  113. mathema_language-0.1.0/tests/_recursive_shapes.py +103 -0
  114. mathema_language-0.1.0/tests/_shop_pages.py +128 -0
  115. mathema_language-0.1.0/tests/_sqlalchemy_shapes.py +57 -0
  116. mathema_language-0.1.0/tests/_text_bugs.py +22 -0
  117. mathema_language-0.1.0/tests/data/lexicon_golden.json +372 -0
  118. mathema_language-0.1.0/tests/test_adaptor_dataclass.py +80 -0
  119. mathema_language-0.1.0/tests/test_adaptor_django.py +56 -0
  120. mathema_language-0.1.0/tests/test_adaptor_jsonschema.py +69 -0
  121. mathema_language-0.1.0/tests/test_adaptor_pydantic.py +61 -0
  122. mathema_language-0.1.0/tests/test_adaptor_registry.py +89 -0
  123. mathema_language-0.1.0/tests/test_adaptor_sqlalchemy.py +115 -0
  124. mathema_language-0.1.0/tests/test_adaptor_text.py +22 -0
  125. mathema_language-0.1.0/tests/test_adaptor_typeddict.py +59 -0
  126. mathema_language-0.1.0/tests/test_byte_offsets.py +62 -0
  127. mathema_language-0.1.0/tests/test_catalogue.py +65 -0
  128. mathema_language-0.1.0/tests/test_docs_pages.py +151 -0
  129. mathema_language-0.1.0/tests/test_drawing_checks_each_record_once.py +38 -0
  130. mathema_language-0.1.0/tests/test_encoding_safe.py +81 -0
  131. mathema_language-0.1.0/tests/test_explain_paths.py +44 -0
  132. mathema_language-0.1.0/tests/test_format_languages_offer_every_spelling.py +51 -0
  133. mathema_language-0.1.0/tests/test_import_contract.py +94 -0
  134. mathema_language-0.1.0/tests/test_induction.py +125 -0
  135. mathema_language-0.1.0/tests/test_integration.py +260 -0
  136. mathema_language-0.1.0/tests/test_language_names.py +32 -0
  137. mathema_language-0.1.0/tests/test_len_refinement.py +66 -0
  138. mathema_language-0.1.0/tests/test_length_bound_fills.py +38 -0
  139. mathema_language-0.1.0/tests/test_length_safe.py +82 -0
  140. mathema_language-0.1.0/tests/test_lexicon.py +187 -0
  141. mathema_language-0.1.0/tests/test_lexicon_covers_the_package.py +71 -0
  142. mathema_language-0.1.0/tests/test_narrow_a_language_to_what_a_function_accepts.py +81 -0
  143. mathema_language-0.1.0/tests/test_orm_rows.py +67 -0
  144. mathema_language-0.1.0/tests/test_page_claims.py +73 -0
  145. mathema_language-0.1.0/tests/test_readme.py +45 -0
  146. mathema_language-0.1.0/tests/test_records_are_their_class.py +58 -0
  147. mathema_language-0.1.0/tests/test_recursive_schemas.py +145 -0
  148. mathema_language-0.1.0/tests/test_row_language.py +196 -0
  149. mathema_language-0.1.0/tests/test_schema_model.py +62 -0
  150. mathema_language-0.1.0/tests/test_self_claims.py +73 -0
  151. mathema_language-0.1.0/tests/test_shrinking_reaches_nested_records.py +67 -0
  152. mathema_language-0.1.0/tests/test_structure_bounds_are_visited.py +63 -0
  153. mathema_language-0.1.0/tests/test_structure_hazards.py +113 -0
  154. mathema_language-0.1.0/tests/test_structure_refinements.py +144 -0
  155. mathema_language-0.1.0/tests/test_text_alphabets.py +142 -0
  156. mathema_language-0.1.0/tests/test_text_generate.py +40 -0
  157. mathema_language-0.1.0/tests/test_text_hazards.py +42 -0
  158. mathema_language-0.1.0/tests/test_text_hazards_find_real_bugs.py +41 -0
  159. mathema_language-0.1.0/tests/test_text_predicates.py +95 -0
  160. mathema_language-0.1.0/tests/test_tree_words.py +42 -0
  161. mathema_language-0.1.0/tests/test_vocabulary_short_paths.py +33 -0
  162. mathema_language-0.1.0/tests/test_vocabulary_text.py +52 -0
  163. mathema_language-0.1.0/tests/test_what_each_schema_library_accepts.py +96 -0
@@ -0,0 +1,21 @@
1
+ ---
2
+ name: Missing language
3
+ about: A language, an alphabet or a schema kind that a claim should be able to name but cannot
4
+ title: "Missing language: <name>"
5
+ labels: enhancement
6
+ ---
7
+
8
+ **The language**
9
+
10
+ What set of strings or values it is (e.g. RFC 5322 addresses, ISO 8601
11
+ durations, a pandera schema), and the name you would write in `L[...]`.
12
+
13
+ **An exact membership test**
14
+
15
+ The standard-library or library call that decides membership exactly
16
+ (e.g. `email.utils.parseaddr`, `datetime.fromisoformat`), if one exists.
17
+
18
+ **The hazards**
19
+
20
+ The members a probe must visit because real code mishandles them, with
21
+ the exact strings where you have them.
@@ -0,0 +1,142 @@
1
+ # .github/workflows/publish.yml
2
+ #
3
+ # Tag-triggered release: verify, build, publish. Publishing uses PyPI
4
+ # Trusted Publishing (OIDC), so no API token is stored anywhere.
5
+ #
6
+ # One-time setup this workflow assumes:
7
+ # TestPyPI: a pending trusted publisher for project "mathema-language":
8
+ # owner tetrionlabs, repository mathema-language, workflow
9
+ # publish.yml, environment testpypi.
10
+ # PyPI: the same, environment pypi.
11
+ # GitHub repository -> Settings -> Environments: "testpypi" (no
12
+ # protection) and "pypi" with a required reviewer, so the final
13
+ # publish is an explicit click.
14
+ #
15
+ # Release procedure: set __version__ in src/mathema_language/__init__.py,
16
+ # add the CHANGELOG entry, commit, tag vX.Y.Z on main, push the tag.
17
+
18
+ name: publish
19
+
20
+ on:
21
+ push:
22
+ tags: ["v*"]
23
+ # A rehearsal: the whole pipeline (version guard, suite, lint, build,
24
+ # artefact checks), stopping before either publish.
25
+ workflow_dispatch:
26
+ inputs:
27
+ version:
28
+ description: "Version to rehearse; must equal mathema_language.__version__"
29
+ required: true
30
+
31
+ permissions:
32
+ contents: read
33
+
34
+ concurrency:
35
+ group: publish-${{ github.ref }}
36
+ cancel-in-progress: false
37
+
38
+ jobs:
39
+ validate:
40
+ runs-on: ubuntu-latest
41
+ timeout-minutes: 5
42
+ outputs:
43
+ version: ${{ steps.ver.outputs.version }}
44
+ steps:
45
+ - uses: actions/checkout@v4
46
+ - uses: actions/setup-python@v5
47
+ with:
48
+ python-version: "3.12"
49
+ - name: Version from tag matches the package
50
+ id: ver
51
+ run: |
52
+ if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
53
+ TAG_VERSION="${{ inputs.version }}"
54
+ else
55
+ TAG_VERSION="${GITHUB_REF_NAME#v}"
56
+ fi
57
+ PKG_VERSION="$(python -c 'import re,pathlib;print(re.search(r"__version__ = \"([^\"]+)\"", pathlib.Path("src/mathema_language/__init__.py").read_text()).group(1))')"
58
+ if [ "$TAG_VERSION" != "$PKG_VERSION" ]; then
59
+ echo "tag $TAG_VERSION != package $PKG_VERSION" >&2; exit 1
60
+ fi
61
+ echo "version=$TAG_VERSION" >> "$GITHUB_OUTPUT"
62
+
63
+ # The tagged commit is not covered by the push and pull-request runs,
64
+ # so the whole suite (every ecosystem, every Python, ruff and mypy)
65
+ # runs again here and the build depends on it.
66
+ tests:
67
+ needs: validate
68
+ uses: ./.github/workflows/tests.yml
69
+
70
+ build:
71
+ needs: [validate, tests]
72
+ runs-on: ubuntu-latest
73
+ timeout-minutes: 15
74
+ steps:
75
+ - uses: actions/checkout@v4
76
+ - uses: actions/setup-python@v5
77
+ with:
78
+ python-version: "3.12"
79
+ - name: Build sdist and wheel
80
+ run: |
81
+ python -m pip install --quiet build twine
82
+ python -m build
83
+ python -m twine check dist/*
84
+ - name: The artefacts carry the licence and the entry points
85
+ run: |
86
+ python - <<'PY'
87
+ import glob, tarfile, zipfile
88
+ version = "${{ needs.validate.outputs.version }}"
89
+ wheel = glob.glob(f"dist/mathema_language-{version}-*.whl")
90
+ assert wheel, f"no wheel for {version}"
91
+ with zipfile.ZipFile(wheel[0]) as z:
92
+ names = z.namelist()
93
+ assert any(n.endswith("/LICENSE") for n in names), "no LICENSE in the wheel"
94
+ assert any(n.endswith("/NOTICE") for n in names), "no NOTICE in the wheel"
95
+ eps = z.read(next(n for n in names if n.endswith("entry_points.txt"))).decode()
96
+ for group in ("mathema.languages", "mathema.language_adaptors",
97
+ "mathema.claim_families", "mathema.language_refinements",
98
+ "mathema.lexicon"):
99
+ assert f"[{group}]" in eps, f"entry point group {group} missing"
100
+ sdist = glob.glob(f"dist/mathema_language-{version}.tar.gz")
101
+ assert sdist, f"no sdist for {version}"
102
+ with tarfile.open(sdist[0]) as tar:
103
+ assert any(n.endswith("/LICENSE") for n in tar.getnames()), "no LICENSE in the sdist"
104
+ print(f"mathema-language {version}: wheel and sdist verified")
105
+ PY
106
+ - uses: actions/upload-artifact@v4
107
+ with:
108
+ name: dist
109
+ path: dist/
110
+
111
+ publish-testpypi:
112
+ # never on a rehearsal
113
+ if: github.event_name == 'push'
114
+ needs: build
115
+ runs-on: ubuntu-latest
116
+ environment: testpypi
117
+ permissions:
118
+ id-token: write
119
+ steps:
120
+ - uses: actions/download-artifact@v4
121
+ with:
122
+ name: dist
123
+ path: dist/
124
+ - uses: pypa/gh-action-pypi-publish@release/v1
125
+ with:
126
+ repository-url: https://test.pypi.org/legacy/
127
+ skip-existing: true
128
+
129
+ publish-pypi:
130
+ # gated by the "pypi" environment's required reviewer
131
+ if: github.event_name == 'push'
132
+ needs: publish-testpypi
133
+ runs-on: ubuntu-latest
134
+ environment: pypi
135
+ permissions:
136
+ id-token: write
137
+ steps:
138
+ - uses: actions/download-artifact@v4
139
+ with:
140
+ name: dist
141
+ path: dist/
142
+ - uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,98 @@
1
+ name: tests
2
+
3
+ on:
4
+ push:
5
+ pull_request:
6
+ workflow_call:
7
+
8
+ # Every job installs core from its 0.6.1 release branch until mathema
9
+ # 0.6.1 is on PyPI, then this package without dependency resolution,
10
+ # then only what that job is about. An adaptor that quietly depends on
11
+ # another ecosystem being present fails its own job.
12
+
13
+ jobs:
14
+ base:
15
+ # no ecosystem at all: the text languages, the families, the
16
+ # dataclass and TypedDict adaptors, and every adaptor answering
17
+ # "not mine" without importing its ecosystem
18
+ runs-on: ubuntu-latest
19
+ strategy:
20
+ fail-fast: false
21
+ matrix:
22
+ python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
23
+ steps:
24
+ - uses: actions/checkout@v4
25
+ - uses: actions/setup-python@v5
26
+ with:
27
+ python-version: ${{ matrix.python-version }}
28
+ - run: pip install "mathema @ git+https://github.com/tetrionlabs/mathema@feature/release-0.6.1"
29
+ - run: pip install --no-deps . && pip install pytest annotated-types
30
+ - name: no ecosystem is installed
31
+ run: |
32
+ python - <<'PY'
33
+ import importlib.util
34
+ present = [m for m in ("pydantic", "jsonschema", "sqlalchemy", "django")
35
+ if importlib.util.find_spec(m) is not None]
36
+ assert not present, present
37
+ PY
38
+ - name: licence headers
39
+ run: |
40
+ status=0
41
+ for f in $(git ls-files '*.py'); do
42
+ if [ "$(sed -n 1p "$f")" != "# SPDX-License-Identifier: Apache-2.0" ] ||
43
+ [ "$(sed -n 2p "$f")" != "# Copyright 2026 Tetrion Ltd" ]; then
44
+ echo "$f: missing licence header lines"; status=1
45
+ fi
46
+ done
47
+ exit $status
48
+ - run: pytest -v
49
+
50
+ adaptor:
51
+ # one ecosystem per job, at its lowest supported version and its
52
+ # latest release
53
+ runs-on: ubuntu-latest
54
+ strategy:
55
+ fail-fast: false
56
+ matrix:
57
+ include:
58
+ - {ecosystem: pydantic, spec: "pydantic==2.0", python-version: "3.11"}
59
+ - {ecosystem: pydantic, spec: "pydantic", python-version: "3.13"}
60
+ - {ecosystem: jsonschema, spec: "jsonschema==4.22.0", python-version: "3.11"}
61
+ - {ecosystem: jsonschema, spec: "jsonschema", python-version: "3.13"}
62
+ - {ecosystem: sqlalchemy, spec: "sqlalchemy==2.0.0", python-version: "3.11"}
63
+ - {ecosystem: sqlalchemy, spec: "sqlalchemy", python-version: "3.13"}
64
+ - {ecosystem: django, spec: "django==4.2", python-version: "3.11"}
65
+ - {ecosystem: django, spec: "django", python-version: "3.13"}
66
+ name: adaptor (${{ matrix.spec }}, Python ${{ matrix.python-version }})
67
+ steps:
68
+ - uses: actions/checkout@v4
69
+ - uses: actions/setup-python@v5
70
+ with:
71
+ python-version: ${{ matrix.python-version }}
72
+ - run: pip install "mathema @ git+https://github.com/tetrionlabs/mathema@feature/release-0.6.1"
73
+ - run: pip install --no-deps . && pip install pytest annotated-types "${{ matrix.spec }}"
74
+ - name: only this ecosystem is installed
75
+ env:
76
+ ECOSYSTEM: ${{ matrix.ecosystem }}
77
+ run: |
78
+ python - <<'PY'
79
+ import importlib.util, os
80
+ others = [m for m in ("pydantic", "jsonschema", "sqlalchemy", "django")
81
+ if m != os.environ["ECOSYSTEM"] and importlib.util.find_spec(m) is not None]
82
+ assert not others, others
83
+ PY
84
+ - run: pytest -v
85
+
86
+ everything:
87
+ # every ecosystem together, and the static checks
88
+ runs-on: ubuntu-latest
89
+ steps:
90
+ - uses: actions/checkout@v4
91
+ - uses: actions/setup-python@v5
92
+ with:
93
+ python-version: "3.12"
94
+ - run: pip install "mathema @ git+https://github.com/tetrionlabs/mathema@feature/release-0.6.1"
95
+ - run: pip install --no-deps . && pip install pytest ruff mypy annotated-types pydantic jsonschema sqlalchemy django
96
+ - run: ruff check .
97
+ - run: mypy src
98
+ - run: pytest -v
@@ -0,0 +1,12 @@
1
+ __pycache__/
2
+ *.pyc
3
+ .pytest_cache/
4
+ .mypy_cache/
5
+ .ruff_cache/
6
+ dist/
7
+ build/
8
+ *.egg-info/
9
+ .venv/
10
+ .smd/
11
+ *.smd
12
+ .DS_Store
@@ -0,0 +1,42 @@
1
+ # Changelog
2
+
3
+ Notable changes to mathema-language are recorded here from its first
4
+ release onward.
5
+
6
+ ## 0.1.0
7
+
8
+ The first release, for mathema 0.6.1 (`mathema>=0.6.1,<0.7`).
9
+
10
+ - Text languages for `L[...]`: `unicode`, `printable`, `latin-1`,
11
+ `ascii`, the ASCII `digit`, `alpha` and `alnum`, `unicode_alpha` and
12
+ `unicode_alnum` for any script, and `identifier`. Each brings its own
13
+ hazards, the inputs code most often gets wrong, which mathema tries
14
+ before random members.
15
+ - Format languages defined by the parser Python already has: `json`,
16
+ `uuid`, `iso_date`, `iso_datetime`, `ipv4`, `ipv6`, `base64`, `hex`,
17
+ `slug` and `shell_safe`. `iso_date` and `iso_datetime` offer every
18
+ spelling the running Python's parser reads, so a claim true only of
19
+ the canonical spelling is falsified.
20
+ - The hazard alphabets `control`, `invisible`, `combining`, `surrogate`,
21
+ `compatibility` and `astral`.
22
+ - Refinements inside the brackets: `len` for text, and `depth`, `nodes`
23
+ and `width` for trees and JSON documents.
24
+ - Record languages from the schema a project already has: dataclasses,
25
+ TypedDicts, pydantic models, JSON Schema, SQLAlchemy tables and Django
26
+ models, each deciding membership with its own library's validation,
27
+ plus `Annotated[str, ...]` text annotations.
28
+ - Paths into a record (`o.lines[*].qty`) and the absent and hole rule of
29
+ mathema 0.6.1: a bound on a path means the value is there, and
30
+ `| {absent}` keeps a record whose path reaches nothing.
31
+ - Structural induction over recursive record trees, so a fold over a
32
+ tree bounded by `depth` is proven, not only tested.
33
+ - The built-in claims `is_encoding_safe` and `is_length_safe`.
34
+ - `refused_inputs` and `narrow_language`, to see what a function refuses
35
+ and to quantify over what it accepts.
36
+ - A text vocabulary (`mathema_language.text`) and a tree vocabulary
37
+ (`mathema_language.tree`) for use inside claims, bound with `let`.
38
+ - A lexicon of worked claims, checked by the test suite against its
39
+ pinned verdicts.
40
+ - Documentation: a six-page tutorial, a how-to, and a reference for
41
+ every language, refinement, adaptor and built-in claim, with every
42
+ example run by the test suite.
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright 2026 Aaron Byrne
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,2 @@
1
+ mathema-language
2
+ Copyright 2026 Tetrion Ltd