Repository navigation
Conversation
…python -OO (agentrust-io#484) - Add explicit encoding="utf-8" to bare Path.read_text() and Path.write_text() calls in tests/, conformance/tests/ (including test_manifest_ref_draft_vectors.py and manifest-ref-v0.3-draft/generate.py), and examples/verifier-token-conformance/gen_corpus.py, and decode git/pytest subprocess output as UTF-8 in tools/review_bar.py. - Guard module __doc__ access under python -OO (PYTHONOPTIMIZE=2) in tools/review_bar.py and tools/check_dashes.py. - Raise the referencing dependency floor from >=0.28 to >=0.28.4 in pyproject.toml and requirements/dev.in so it is satisfiable alongside jsonschema>=4.26.0. - Add a CI portability step in .github/workflows/ci.yml running LC_ALL=C PYTHONUTF8=0 pytest and PYTHONOPTIMIZE=2 pytest tests/test_review_bar.py. Closes agentrust-io#484 Signed-off-by: Raghuvar Durga <177662415+drk-ram@users.noreply.github.com> Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…path (agentrust-io#484) Under LC_ALL=C PYTHONUTF8=0 on POSIX, sys.getfilesystemencoding() is 'ascii' with 'surrogateescape', so os.fsencode("test_été.py") raises UnicodeEncodeError before git is ever reached. Guard test_a_test_path_git_would_quote_is_still_found with os.fsencode() so it skips cleanly in the ASCII C-locale portability step while still running in the default UTF-8 test step. Signed-off-by: Raghuvar Durga <177662415+drk-ram@users.noreply.github.com> Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
rajnisht7
left a comment
There was a problem hiding this comment.
Encoding fix looks good, fixing encoding in several conformance/tests/ files (conftest, anchor/manifest-ref vectors, measurement harness, unit loader/runner/CLI, generator). The new CI step is:
LC_ALL=C PYTHONUTF8=0 pytest
PYTHONOPTIMIZE=2 pytest tests/test_review_bar.pyRoot pyproject.toml has testpaths = ["tests"], so that only runs root tests/. conformance-ci.yml still runs under a normal UTF-8 locale. So the conformance portability fixes aren’t regression-protected.
kindly add a non-UTF-8 run for conformance as well (in ci.yml or conformance-ci.yml), e.g. something that actually executes conformance/tests under LC_ALL=C PYTHONUTF8=0.
Also minor:
PYTHONOPTIMIZE=2only exercises test_review_bar.py. tools/check_dashes.py was also fixed for -OO but isn’t run under -OO in CI, worth adding PYTHONOPTIMIZE=2 python tools/check_dashes.py.- In
review_bar.py, preferdescription=(__doc__ or "").split("\n\n")[0]so the-OOguard doesn’t change the existing “first paragraph” split behavior.
imran-siddique
left a comment
There was a problem hiding this comment.
Approving 68b778c. This is the scope agreed on #484. The red test (3.11) and (3.12) on 8803282 was the new LC_ALL=C job doing its job on the non-ASCII filename test, and 68b778c skips that one case. On Windows cp1252 the git-quoted path test fails on #537, #538 and #539 heads and passes here. python -OO tools/check_dashes.py --help and tools/review_bar.py --help crash with AttributeError on 2bbecec and work here. Ruff and check_dashes are clean.
|
|
||
| def test_a_test_path_git_would_quote_is_still_found(tmp_path): | ||
| try: | ||
| os.fsencode("test_été.py") |
There was a problem hiding this comment.
The portability job is now the one place this test never runs. Fine, but say so in the skip reason.
| def main() -> int: | ||
| parser = argparse.ArgumentParser(description=__doc__.splitlines()[0]) | ||
| parser = argparse.ArgumentParser( | ||
| description=(__doc__ or "").splitlines()[0] if __doc__ else "" |
There was a problem hiding this comment.
(__doc__ or "") is redundant next to if __doc__ else "".
|
|
||
| def main(argv: list[str] | None = None) -> int: | ||
| parser = argparse.ArgumentParser(description=__doc__.split("\n\n")[0]) | ||
| parser = argparse.ArgumentParser(description=(__doc__ or "").split("\n", 1)[0]) |
There was a problem hiding this comment.
This also changes the help text from the first paragraph to the first line. Intended?
What this changes
Closes #484.
Contributor: Raghuvar Durga (@drk-ram)
Makes the test suite, conformance suite, fixture generators, and repository tooling portable across non-UTF-8 default encodings (
LC_ALL=C PYTHONUTF8=0/ Windowscp1252) andpython -OO(PYTHONOPTIMIZE=2), and raises thereferencingdependency floor so it is satisfiable alongsidejsonschema>=4.26.0, per@imran-siddique's scope ruling on #484:encoding="utf-8"to all barePath.read_text()andPath.write_text()calls acrosstests/(26 files),conformance/tests/(8 files, includingconformance/tests/test_manifest_ref_draft_vectors.pyandconformance/tests/vectors/manifest-ref-v0.3-draft/generate.pywithnewline="\n"), andexamples/verifier-token-conformance/gen_corpus.py.encoding="utf-8"tosubprocess.run(..., text=True)intools/review_bar.pysogit diff -zpath output andpytestoutput decode as UTF-8 underLC_ALL=C PYTHONUTF8=0.conformance/tests/test_measurement_harness.pysopython tools/check_dashes.pycontinues to pass once that file is edited past itsconformance/import-manifest.jsonsnapshot.__doc__underpython -OO(PYTHONOPTIMIZE=2):description=(__doc__ or "").split("\n", 1)[0]intools/review_bar.pyanddescription=(__doc__ or "").splitlines()[0] if __doc__ else ""intools/check_dashes.py.referencingfloor to>=0.28.4:referencing>=0.28toreferencing>=0.28.4inpyproject.tomlandrequirements/dev.into matchjsonschema>=4.26.0's requirement..github/workflows/ci.ymlrunningLC_ALL=C PYTHONUTF8=0 pytestandPYTHONOPTIMIZE=2 pytest tests/test_review_bar.py.Cold-reader review:
code-reviewsub-agent over the full diff against the Test suite and tools are not portable across default encodings andpython -OO;referencingfloor is unsatisfiable #484 scope and verified via AST inspection that zero bare.read_text()or.write_text()calls remain anywhere in the repository; the cold reader reported no issues.tests/test_review_bar.pyunderPYTHONUTF8=0during verification exposed thattools/review_bar.py'sgit()helper also usedsubprocess.run(..., text=True)withoutencoding="utf-8", causingtest_a_test_path_git_would_quote_is_still_foundto misdecode UTF-8 paths emitted bygit diff -z; addedencoding="utf-8"there as well.Type of change
Spec section
None (test suite, tooling, CI workflow, and package dependency metadata only).
Tests for a fix
Not a library or schema verification fix (
src/agentrust_trace/andschema/are unchanged), but the portability fixes are directly exercised by existing tests that fail onmainwhen the changes are switched off:PYTHONUTF8=0 pytest tests/test_regex_surface_parity.py tests/test_schema_regex_semantics.py tests/test_build_provenance_depth_doc.pyandPYTHONUTF8=0 pytest conformance/tests/test_manifest_ref_draft_vectors.pyfail withUnicodeDecodeError/ fixture mismatch without the explicitencoding="utf-8"reads and pass with them (conformance/tests: 778 passed, 5 xpassed; roottests/: 3,734 passed).PYTHONOPTIMIZE=2 pytest tests/test_review_bar.py -k "test_the_command_line_writes_the_summary_and_never_fails_the_build or test_an_error_inside_the_tool_still_writes_a_report_and_exits_zero"andpython -OO tools/check_dashes.pyfail withAttributeError: 'NoneType' object has no attribute 'split'/'splitlines'without the__doc__guards and pass with them.ruff check src tests scripts,python tools/check_dashes.py, andmypy src/agentrust_traceall pass.Checklist
git commit -s)CHANGELOG.mdupdated (for any normative change)<!-- CHANGED: #NNN: description -->in spec text