hocon-parser 1.8.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 (52) hide show
  1. hocon_parser-1.8.0/.github/workflows/lint.yml +36 -0
  2. hocon_parser-1.8.0/.github/workflows/release.yml +105 -0
  3. hocon_parser-1.8.0/.github/workflows/test.yml +61 -0
  4. hocon_parser-1.8.0/.gitignore +30 -0
  5. hocon_parser-1.8.0/CHANGELOG.md +80 -0
  6. hocon_parser-1.8.0/CONTRIBUTING.md +79 -0
  7. hocon_parser-1.8.0/LICENSE +202 -0
  8. hocon_parser-1.8.0/Makefile +61 -0
  9. hocon_parser-1.8.0/PKG-INFO +493 -0
  10. hocon_parser-1.8.0/README.ja.md +392 -0
  11. hocon_parser-1.8.0/README.md +473 -0
  12. hocon_parser-1.8.0/SECURITY.md +20 -0
  13. hocon_parser-1.8.0/benchmarks/bench.py +69 -0
  14. hocon_parser-1.8.0/docs/spec-compliance.md +858 -0
  15. hocon_parser-1.8.0/pyproject.toml +58 -0
  16. hocon_parser-1.8.0/src/hocon/__init__.py +68 -0
  17. hocon_parser-1.8.0/src/hocon/_internal/__init__.py +4 -0
  18. hocon_parser-1.8.0/src/hocon/_internal/lexer/__init__.py +1 -0
  19. hocon_parser-1.8.0/src/hocon/_internal/lexer/lexer.py +500 -0
  20. hocon_parser-1.8.0/src/hocon/_internal/lexer/token.py +65 -0
  21. hocon_parser-1.8.0/src/hocon/_internal/parser/__init__.py +1 -0
  22. hocon_parser-1.8.0/src/hocon/_internal/parser/ast.py +120 -0
  23. hocon_parser-1.8.0/src/hocon/_internal/parser/empty_check.py +29 -0
  24. hocon_parser-1.8.0/src/hocon/_internal/parser/parser.py +533 -0
  25. hocon_parser-1.8.0/src/hocon/_internal/properties/__init__.py +4 -0
  26. hocon_parser-1.8.0/src/hocon/_internal/properties/properties.py +84 -0
  27. hocon_parser-1.8.0/src/hocon/_internal/resolver/__init__.py +1 -0
  28. hocon_parser-1.8.0/src/hocon/_internal/resolver/fold_self_ref.py +282 -0
  29. hocon_parser-1.8.0/src/hocon/_internal/resolver/include_loader.py +252 -0
  30. hocon_parser-1.8.0/src/hocon/_internal/resolver/resolver.py +95 -0
  31. hocon_parser-1.8.0/src/hocon/_internal/resolver/structure_builder.py +184 -0
  32. hocon_parser-1.8.0/src/hocon/_internal/resolver/substitution_resolver.py +407 -0
  33. hocon_parser-1.8.0/src/hocon/_internal/resolver/types.py +162 -0
  34. hocon_parser-1.8.0/src/hocon/_internal/resolver/utils.py +144 -0
  35. hocon_parser-1.8.0/src/hocon/coerce.py +257 -0
  36. hocon_parser-1.8.0/src/hocon/config.py +524 -0
  37. hocon_parser-1.8.0/src/hocon/errors.py +71 -0
  38. hocon_parser-1.8.0/src/hocon/numeric_array.py +51 -0
  39. hocon_parser-1.8.0/src/hocon/parse.py +122 -0
  40. hocon_parser-1.8.0/src/hocon/py.typed +0 -0
  41. hocon_parser-1.8.0/src/hocon/value.py +111 -0
  42. hocon_parser-1.8.0/src/hocon/value_factory.py +71 -0
  43. hocon_parser-1.8.0/tests/conformance/test_conformance.py +150 -0
  44. hocon_parser-1.8.0/tests/conformance/test_error_fixtures.py +167 -0
  45. hocon_parser-1.8.0/tests/test_deferred_resolution_fixtures.py +546 -0
  46. hocon_parser-1.8.0/tests/test_hocon_json_adapter.py +172 -0
  47. hocon_parser-1.8.0/tests/test_include_package_fixtures.py +240 -0
  48. hocon_parser-1.8.0/tests/test_period.py +101 -0
  49. hocon_parser-1.8.0/tests/test_properties_conflict_fixtures.py +103 -0
  50. hocon_parser-1.8.0/tests/test_smoke.py +95 -0
  51. hocon_parser-1.8.0/tests/test_units_default.py +194 -0
  52. hocon_parser-1.8.0/tools/hocon_json.py +56 -0
@@ -0,0 +1,36 @@
1
+ name: Lint
2
+
3
+ on:
4
+ pull_request:
5
+ branches: [develop, main]
6
+ push:
7
+ branches: [develop, main]
8
+
9
+ jobs:
10
+ ruff:
11
+ runs-on: ubuntu-latest
12
+ steps:
13
+ - uses: actions/checkout@v5
14
+ - uses: actions/setup-python@v6
15
+ with:
16
+ python-version: "3.13"
17
+ - name: Install
18
+ run: |
19
+ python -m pip install --upgrade pip
20
+ python -m pip install -e . --group dev
21
+ - run: ruff check src tests benchmarks tools
22
+
23
+ typecheck:
24
+ runs-on: ubuntu-latest
25
+ steps:
26
+ - uses: actions/checkout@v5
27
+ # Pinned to the floor of requires-python so stdlib drift in newer
28
+ # versions can't mask a 3.11 incompatibility (mypy python_version=3.11).
29
+ - uses: actions/setup-python@v6
30
+ with:
31
+ python-version: "3.11"
32
+ - name: Install
33
+ run: |
34
+ python -m pip install --upgrade pip
35
+ python -m pip install -e . --group dev
36
+ - run: mypy
@@ -0,0 +1,105 @@
1
+ name: Release
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - "v*"
7
+
8
+ permissions: {}
9
+
10
+ jobs:
11
+ publish:
12
+ name: Publish to PyPI
13
+ runs-on: ubuntu-latest
14
+ # Least-privilege: only the publish job needs write scope (contents for
15
+ # the GitHub Release, id-token for PyPI Trusted Publishing). Workflow-level
16
+ # `permissions: {}` denies by default so future jobs added here don't
17
+ # inherit write access without an explicit declaration.
18
+ permissions:
19
+ contents: write
20
+ id-token: write
21
+
22
+ steps:
23
+ - uses: actions/checkout@v5
24
+
25
+ - name: Set up Python
26
+ uses: actions/setup-python@v6
27
+ with:
28
+ python-version: "3.13"
29
+
30
+ - name: Set version from tag
31
+ # Idempotent: skip the rewrite if pyproject.toml is already at the
32
+ # tag's version, so a release-prep PR that pre-bumped the manifest
33
+ # doesn't break the publish (same convention as the siblings).
34
+ run: |
35
+ TAG_VERSION="${GITHUB_REF#refs/tags/v}"
36
+ CURRENT=$(python -c "import tomllib; print(tomllib.load(open('pyproject.toml', 'rb'))['project']['version'])")
37
+ if [ "$TAG_VERSION" != "$CURRENT" ]; then
38
+ sed -i "s/^version = \"$CURRENT\"/version = \"$TAG_VERSION\"/" pyproject.toml
39
+ else
40
+ echo "pyproject.toml already at $CURRENT — skipping bump"
41
+ fi
42
+
43
+ - name: Fetch conformance corpus
44
+ run: make testdata
45
+
46
+ - name: Install
47
+ run: |
48
+ python -m pip install --upgrade pip
49
+ python -m pip install -e . --group dev
50
+
51
+ - name: Type check
52
+ run: mypy
53
+
54
+ - name: Test
55
+ run: python -m pytest
56
+
57
+ - name: Build distributions
58
+ run: |
59
+ python -m pip install build
60
+ python -m build
61
+
62
+ - name: Extract CHANGELOG section for this tag
63
+ # Pulls the section between `## [VERSION]` and the next `## [`
64
+ # from CHANGELOG.md so the GitHub Release body matches what's
65
+ # already committed and reviewed.
66
+ #
67
+ # Uses `index($0, str) == 1` (prefix match) rather than awk regex
68
+ # so SemVer build metadata (`+...`) and other regex metacharacters
69
+ # in version strings can't break or overmatch the section header.
70
+ #
71
+ # Runs BEFORE the PyPI upload (and the GitHub Release step below)
72
+ # so that a missing/incorrect CHANGELOG heading fails the run
73
+ # without first publishing — PyPI doesn't allow re-uploading the
74
+ # same version, so an irreversible upload followed by a failed
75
+ # release step would leave a half-shipped tag.
76
+ run: |
77
+ VERSION="${GITHUB_REF#refs/tags/v}"
78
+ awk -v ver="$VERSION" '
79
+ index($0, "## [" ver "]") == 1 { flag=1; next }
80
+ flag && index($0, "## [") == 1 { flag=0 }
81
+ flag
82
+ ' CHANGELOG.md > /tmp/release-notes.md
83
+ if [ ! -s /tmp/release-notes.md ]; then
84
+ echo "::error::No CHANGELOG section found for v${VERSION}; aborting release so an empty body doesn't ship"
85
+ exit 1
86
+ fi
87
+
88
+ - name: Create GitHub Release
89
+ # Runs before the PyPI upload so a Release-creation failure doesn't
90
+ # leave a PyPI artifact published without a GitHub Release entry
91
+ # (PyPI forbids re-uploading the same version, so a retry would fail
92
+ # at the upload step and never reach this step again).
93
+ uses: softprops/action-gh-release@v2
94
+ with:
95
+ tag_name: ${{ github.ref_name }}
96
+ name: ${{ github.ref_name }}
97
+ body_path: /tmp/release-notes.md
98
+ fail_on_unmatched_files: false
99
+ make_latest: true
100
+
101
+ - name: Publish to PyPI
102
+ # Trusted Publishing (OIDC) — no API token. Requires this repo +
103
+ # workflow file to be registered as a trusted publisher for the
104
+ # `py.hocon` project on PyPI before the first release.
105
+ uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,61 @@
1
+ name: Test
2
+
3
+ on:
4
+ pull_request:
5
+ branches: [develop, main]
6
+ push:
7
+ branches: [develop, main]
8
+
9
+ jobs:
10
+ test:
11
+ name: py${{ matrix.python }} / ${{ matrix.os }}
12
+ runs-on: ${{ matrix.os }}
13
+ strategy:
14
+ fail-fast: false
15
+ matrix:
16
+ python: ["3.11", "3.12", "3.13"]
17
+ os: [ubuntu-latest]
18
+ include:
19
+ - python: "3.13"
20
+ os: macos-latest
21
+ - python: "3.13"
22
+ os: windows-latest
23
+
24
+ steps:
25
+ - uses: actions/checkout@v5
26
+
27
+ - name: Set up Python
28
+ uses: actions/setup-python@v6
29
+ with:
30
+ python-version: ${{ matrix.python }}
31
+
32
+ # No cache: `make testdata` fetches the whole corpus fresh each run (a
33
+ # small tarball, sha-resolved via `git ls-remote`). Nothing is vendored
34
+ # in this repo, so a partial or stale cache can only subtract
35
+ # correctness — see rs.hocon's stale-fixture regression (#101) that led
36
+ # the siblings to drop fixture caching.
37
+ - name: Fetch conformance corpus
38
+ run: make testdata
39
+
40
+ - name: Install
41
+ run: |
42
+ python -m pip install --upgrade pip
43
+ python -m pip install -e . --group dev
44
+
45
+ - name: Test
46
+ run: python -m pytest
47
+
48
+ - name: Test with coverage
49
+ if: matrix.python == '3.13' && matrix.os == 'ubuntu-latest'
50
+ run: |
51
+ python -m pip install pytest-cov
52
+ python -m pytest --cov=hocon --cov-report=xml
53
+
54
+ - name: Upload coverage to Codecov
55
+ if: matrix.python == '3.13' && matrix.os == 'ubuntu-latest'
56
+ uses: codecov/codecov-action@v5
57
+ with:
58
+ token: ${{ secrets.CODECOV_TOKEN }}
59
+ slug: o3co/py.hocon
60
+ files: coverage.xml
61
+ fail_ci_if_error: false
@@ -0,0 +1,30 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *.egg-info/
5
+ dist/
6
+ build/
7
+
8
+ # Virtualenv
9
+ .venv/
10
+
11
+ # Tool caches
12
+ .pytest_cache/
13
+ .mypy_cache/
14
+ .ruff_cache/
15
+ .coverage
16
+ htmlcov/
17
+
18
+ # Conformance corpus (synced from o3co/xx.hocon via `make testdata`)
19
+ tests/conformance/testdata/
20
+ .xx-hocon-version
21
+
22
+ # Editor / OS
23
+ .DS_Store
24
+ .idea/
25
+ .vscode/
26
+ *.swp
27
+ *.swo
28
+
29
+ # Claude Code (local-only settings)
30
+ .claude/settings.local.json
@@ -0,0 +1,80 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [Unreleased]
9
+
10
+ ## [1.8.0] - 2026-07-16
11
+
12
+ Initial published release. The version is aligned to the sibling o3co
13
+ implementations (go.hocon / rs.hocon / ts.hocon, all at 1.8.0), which move in
14
+ lockstep — py.hocon enters that lockstep at parity rather than starting a
15
+ separate 0.x line. Distributed on PyPI as `hocon-parser` (imported as `hocon`).
16
+
17
+ ### Added
18
+
19
+ - `tools/hocon_json.py` — differential-harness adapter registering py.hocon in
20
+ xx.hocon's cross-impl driver (`generate/DifferentialDriver.java`). Parses +
21
+ resolves a `.conf` and emits canonical JSON to stdout (via the oracle-aligned
22
+ `_render_json_for_test` renderer, mirroring ts.hocon), or a single-line
23
+ `{"__error__":{type,message}}` record + exit 3 on failure. `tests/test_hocon_json_adapter.py`
24
+ runs it over the whole spec-corpus and asserts equality with the
25
+ Lightbend-generated expected JSON (an in-repo oracle differential), plus
26
+ CLI-contract and process-env-resolution checks. `ruff` now also lints `tools`.
27
+ - Conformance-corpus expansion — five new fixture harnesses closing the gap to
28
+ the sibling test surface (full suite: 306 passed / 1 skipped / 4 xfailed):
29
+ - `tests/conformance/test_error_fixtures.py` — 38 error fixtures
30
+ (`-expected-error.json` + `.error` sidecars: subst-tokenize st-err,
31
+ concat-errors, include-reservation, env-var-list, self-ref-lookback sr05,
32
+ path-expr-whitespace pw06, …) with ts-parity error-class pinning; us15 is
33
+ a strict-xfail tripwire for the `+`-reservation gap shared by all siblings
34
+ (ts#73 / rs `#[should_panic]`).
35
+ - `tests/test_units_default.py` — units-default ud/ub/un accessor fixtures
36
+ at rs parity. Known cross-impl note: negative durations stay signed
37
+ (Lightbend/go-faithful; rs rejects only because `std::time::Duration` is
38
+ unsigned) — pinned both ways (passing signed test + strict-xfail rs
39
+ tripwire on ud06).
40
+ - `tests/test_deferred_resolution_fixtures.py` — all 31 E12 scenario-YAML
41
+ fixtures (dr01–dr30 incl. dr11a/b) via a dependency-free purpose-built
42
+ scenario loader, plus dr19/dr29 programmatic companions; consumes dr12 and
43
+ dr17, which the sibling YAML runners skip.
44
+ - `tests/test_properties_conflict_fixtures.py` — pc01–pc04 (S23.4
45
+ object-wins, input-order independent).
46
+ - `tests/test_include_package_fixtures.py` — ipk01–ipk14 E11 scenarios via
47
+ the `package_resolver` kwarg (ipk03 N/A per E11 decision 3, as in ts).
48
+ - `Config.get_period` + `Period(years, months, days)` frozen dataclass —
49
+ S20.1–S20.4 period accessor at rs.hocon parity (ts / go remain ➖ here):
50
+ integer-only per Lightbend `Integer.parseInt` (fractional rejected, up03),
51
+ bare numbers default to days (HOCON.md L1321), lowercase-only units
52
+ (`d`/`day`/`days`, `w`/`week`/`weeks` folded into days, `m`/`mo`/`month`/
53
+ `months`, `y`/`year`/`years`), negative periods permitted, i32-bounded.
54
+ - Initial parser implementation, ported from `@o3co/ts.hocon` with the same
55
+ 3-stage pipeline (Lexer → Parser → Resolver):
56
+ - **Lexer** — full HOCON whitespace set, quoted / triple-quoted / unquoted
57
+ strings, `${...}` / `${?...}` substitutions with the `[]` list suffix (S13c),
58
+ path-expression whitespace tracking (E13).
59
+ - **Parser** — objects, arrays, value concatenation, path expressions with
60
+ space-concat (S10.8), `+=` append, `include` (bare / `file(...)` /
61
+ `package(...)` / `required(...)`), `include` key-path reservation (S12.5).
62
+ - **Resolver** — two-phase build/resolve, substitution resolution with
63
+ self-reference lookback and chained-self-append folding (S13a, #118/#120),
64
+ delayed object merge, env-var and env-var-list fallback (S13c), numeric
65
+ object → array conversion (S15), `.properties` includes (S23).
66
+ - **Config accessors** (rs.hocon-style snake_case): `get` / `get_string` /
67
+ `get_number` / `get_int` / `get_float` / `get_boolean` / `get_duration` /
68
+ `get_bytes` / `get_config` / `get_list` / `get_value` / `has` / `keys` /
69
+ `to_object`, plus deferred resolution (`resolve` / `resolve_with` /
70
+ `with_fallback`, E12) and `from_map` / `empty` value factories.
71
+ - Duration / byte-size coercion with case-sensitive duration units (S19.8) and
72
+ power-of-two single-letter byte abbreviations (S21.4).
73
+ - Conformance harness against the shared o3co/xx.hocon corpus: **134/134 spec
74
+ corpus** and **14/16 Lightbend suite** (the 2 held-out fixtures reference JVM
75
+ system properties `${?java.version}` / `${?user.home}` — every non-JVM parser
76
+ caps at 14/16). At parity with go.hocon and rs.hocon.
77
+ - Project scaffold: package layout mirroring the sibling implementations, error
78
+ type hierarchy (`ParseError`, `ResolveError`, `PackageLookupError`,
79
+ `ConfigError`, `NotResolvedError`), and tooling (hatchling, pytest, mypy
80
+ strict, ruff) with the `make testdata` corpus-sync target.
@@ -0,0 +1,79 @@
1
+ # Contributing to py.hocon
2
+
3
+ Thank you for your interest in contributing!
4
+
5
+ ## Reporting Bugs
6
+
7
+ Please open a [GitHub Issue](https://github.com/o3co/py.hocon/issues) and include:
8
+
9
+ - Python version (`python --version`)
10
+ - py.hocon version
11
+ - A minimal reproducing HOCON snippet
12
+ - Expected vs. actual behavior
13
+
14
+ ## Proposing Features
15
+
16
+ Open an issue first to discuss the proposal before sending a PR. This avoids
17
+ wasted effort if the direction doesn't fit the project scope.
18
+
19
+ ## Development Setup
20
+
21
+ Requires Python 3.11+.
22
+
23
+ ```bash
24
+ git clone https://github.com/o3co/py.hocon.git
25
+ cd py.hocon
26
+ make setup # creates .venv and installs the package + dev tools (editable)
27
+ make check # ruff + mypy --strict + pytest
28
+ ```
29
+
30
+ `make setup` uses `python3.11` by default; override with `make setup PYTHON=python3.12`.
31
+
32
+ ## Running Tests
33
+
34
+ ```bash
35
+ # All tests (unit + conformance)
36
+ make test
37
+
38
+ # Lint / type-check / tests together
39
+ make check
40
+
41
+ # Sync the shared conformance corpus from o3co/xx.hocon, then run it
42
+ make testdata
43
+ make test
44
+
45
+ # Micro-benchmarks
46
+ make bench
47
+ ```
48
+
49
+ The conformance suite (`tests/conformance/`) drives every fixture from
50
+ [o3co/xx.hocon](https://github.com/o3co/xx.hocon) through the parser and compares
51
+ the resolved output against Lightbend-generated expected JSON. Run `make testdata`
52
+ once to fetch the corpus (git-ignored); the suite skips gracefully if it is absent.
53
+
54
+ ## Code Style
55
+
56
+ - `mypy --strict` throughout — no untyped defs, no implicit `Any`
57
+ - `ruff` for lint + import ordering (`make lint`)
58
+ - Keep the public API consistent with ts.hocon / rs.hocon (throwing typed getters,
59
+ snake_case accessor names)
60
+ - New features must include tests; spec-relevant changes should add or update a
61
+ conformance fixture in xx.hocon, not just a local test
62
+ - Modules under `hocon._internal` are **not** part of the public API
63
+ - Preserve cross-language parity: this parser mirrors
64
+ [ts.hocon](https://github.com/o3co/ts.hocon)'s 3-stage pipeline
65
+ (Lexer → Parser → Resolver). A spec-behavior change here should be reconciled
66
+ with the sibling implementations.
67
+
68
+ ## Submitting a Pull Request
69
+
70
+ 1. Fork the repository and create a branch from `main`
71
+ 2. Write tests for your change
72
+ 3. Ensure `make check` passes (ruff + mypy --strict + pytest)
73
+ 4. Update `CHANGELOG.md` under `[Unreleased]` for any user-facing change
74
+ 5. Open a PR against `main` with a clear description of what and why
75
+
76
+ ## License
77
+
78
+ By contributing, you agree that your contributions will be licensed under the
79
+ [Apache License 2.0](LICENSE).
@@ -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 1o1 Co. Ltd.
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,61 @@
1
+ PYTHON ?= python3.11
2
+ VENV := .venv
3
+
4
+ TESTDATA_REPO := o3co/xx.hocon
5
+ TESTDATA_REF := main
6
+ TESTDATA_DIR := tests/conformance/testdata
7
+
8
+ .PHONY: setup test lint typecheck check bench testdata clean
9
+
10
+ # Bootstrap the dev venv (idempotent).
11
+ setup:
12
+ test -d $(VENV) || $(PYTHON) -m venv $(VENV)
13
+ $(VENV)/bin/pip install --quiet --upgrade pip
14
+ $(VENV)/bin/pip install --quiet -e . --group dev
15
+
16
+ test:
17
+ $(VENV)/bin/python -m pytest
18
+
19
+ lint:
20
+ $(VENV)/bin/ruff check src tests benchmarks tools
21
+
22
+ typecheck:
23
+ $(VENV)/bin/mypy
24
+
25
+ check: lint typecheck test
26
+
27
+ bench:
28
+ $(VENV)/bin/python benchmarks/bench.py
29
+
30
+ # Sync the conformance corpus (fixtures + Lightbend-generated expected JSON)
31
+ # from o3co/xx.hocon. Skips the download when the pinned sha is current.
32
+ # The sha is resolved via `git ls-remote` (not api.github.com) so CI runners
33
+ # sharing an egress IP don't trip the unauthenticated API rate limit, and the
34
+ # tarball is fetched by that sha so the recorded pin is exactly what landed
35
+ # (same convention as rs.hocon).
36
+ testdata:
37
+ @set -e; \
38
+ sha="$$(git ls-remote "https://github.com/$(TESTDATA_REPO).git" "$(TESTDATA_REF)" | head -1 | cut -f1)"; \
39
+ if [ -z "$$sha" ]; then \
40
+ echo "error: could not resolve $(TESTDATA_REPO)@$(TESTDATA_REF) SHA via git ls-remote" >&2; \
41
+ exit 1; \
42
+ fi; \
43
+ if [ -f .xx-hocon-version ] && [ -d "$(TESTDATA_DIR)/hocon" ] && [ -d "$(TESTDATA_DIR)/expected" ] && \
44
+ [ "$$sha" = "$$(cat .xx-hocon-version)" ]; then \
45
+ echo "Conformance corpus up to date ($$sha)"; \
46
+ exit 0; \
47
+ fi; \
48
+ tmpdir="$$(mktemp -d)"; \
49
+ trap 'rm -rf "$$tmpdir"' EXIT INT TERM; \
50
+ curl -sfL "https://github.com/$(TESTDATA_REPO)/archive/$$sha.tar.gz" -o "$$tmpdir/archive.tar.gz"; \
51
+ tar xzf "$$tmpdir/archive.tar.gz" -C "$$tmpdir" --strip-components=1; \
52
+ rm -rf "$(TESTDATA_DIR)/hocon" "$(TESTDATA_DIR)/expected"; \
53
+ mkdir -p "$(TESTDATA_DIR)"; \
54
+ cp -R "$$tmpdir/testdata/hocon" "$(TESTDATA_DIR)/hocon"; \
55
+ cp -R "$$tmpdir/expected/hocon" "$(TESTDATA_DIR)/expected"; \
56
+ printf '%s\n' "$$sha" > .xx-hocon-version; \
57
+ echo "Done. Fetched $$sha"
58
+
59
+ clean:
60
+ rm -rf $(VENV) dist build .pytest_cache .mypy_cache .ruff_cache
61
+ find . -type d -name __pycache__ -exec rm -rf {} +