Repository navigation
build: notices follow-ups (docstring summaries, per-module packaging, Unicode and PyYAML credits) - #2780
Merged
Conversation
The tree-shaking projects under src/Sharpy.Stdlib/modules/ (#696) compile code ported from CPython (Fnmatch, Itertools, Os, Shutil, Difflib, ...) but were packable by default, declaring Apache-2.0 OR MIT and packing no THIRD-PARTY-NOTICES.txt. Nothing packs them today (release.yml packs Cli, Core, Stdlib and Compiler by path; build_tools, .claude/scripts and the Playground pack nothing), so this closes the door before anything does. MSBuild resolves IsPackable to false for Sharpy.Stdlib.Fnmatch and still true for Sharpy.Stdlib (control). Guard: test_package_licenses.py reads the modules' Directory.Build.props (IsPackable set once, to false) and refuses any project-level override. Mutation: IsPackable false -> true in the props: red (1 failed, 13 passed: "Directory.Build.props: sets IsPackable ['true']"); restored with cp + cmp: green (14 passed). Refs #2602 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LGMKZYKjCq2pTmNWtKf2hy
The #2777 review found one-line API summaries copied word for word from CPython 3.15 Lib docstrings, mostly in files the #2602 census marks "behaviour". They are documentation, not code, so the files keep no PSF header; THIRD-PARTY-NOTICES.txt gains one section in the CPython part, "API documentation summaries adapted from CPython docstrings", naming the 17 files (40 summaries: 33 in behaviour files, 7 in the fnmatch and shutil ports), the Lib modules they come from, and the PSF licence text that follows by reference. Method (the reviewer's): a summary matches when its first paragraph (a C# <summary>: its whole text or first sentence), whitespace collapsed, case and a final full stop ignored, equals the first paragraph of a module, class or function docstring longer than 30 characters in CPython 3.15.2's Lib (test packages, idlelib, site-packages not read); C# generated from a .spy file is skipped. No later sentence of a matched summary appears in a CPython docstring. Guard: test_third_party_notices.py runs that matcher over Sharpy.Core and Sharpy.Stdlib against python3.15's Lib (the pytest interpreter when it is 3.15, else python3.15 on PATH, else skip with a reason) and requires the section's list to equal the matched set. Unit tests pin the index rule and both refusal directions without the oracle. Mutations: (a) drop src/Sharpy.Stdlib/spy/heapq.spy from the section: red (1 failed, 60 passed: "heapq.spy: holds CPython docstring text ... but is not under 'Sharpy files holding these summaries:'"); (b) bisect_module.spy's module docstring replaced by bisect.insort's "Insert item x in list a, and keep it sorted assuming a is sorted.": red (1 failed, 60 passed: "bisect_module.spy: holds CPython docstring text ... <- Lib/bisect.py"); each restored with cp + cmp: green (61 passed). Refs #2602 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LGMKZYKjCq2pTmNWtKf2hy
The #2777 review found two derived pieces from non-CPython sources: - src/Sharpy.Core/StringExtensions.Format.cs: the case-folding table (s_caseFoldTable) and the Cherokee ranges in CaseFoldChar, from the Unicode Character Database's CaseFolding.txt. The source records no version; all 125 entries equal CPython 3.15.2's str.casefold, which uses Unicode 17.0.0. - src/Sharpy.Stdlib/Yaml/YamlScalarResolver.cs: Yaml11Int and Yaml11Float, transcribed from PyYAML 6.0.3's implicit resolvers (lib/yaml/resolver.py; checked against the 6.0.3 tag's file). THIRD-PARTY-NOTICES.txt gains a section for each (upstream, version, derived portion, full licence text), placed before the CPython section so the CPython licence stays the file's last 277 lines. Each file gains a short header naming its upstream and pointing at the notices. The intro now says the #2602 audit covered CPython, names these two sources as also listed, and claims no other completeness. Licence texts, fetched 2026-11-20: - PyYAML: https://raw.githubusercontent.com/yaml/pyyaml/6.0.3/LICENSE (sha256 8d3928f9...a577e8a4), verbatim. - Unicode License V3: https://www.unicode.org/license.txt was refused by the network proxy (403); the text is the first section of https://raw.githubusercontent.com/unicode-org/icu/main/LICENSE (the Unicode Consortium's repository), verbatim, and differs from SPDX's Unicode-3.0 text (spdx/license-list-data) only in the copyright years (1991-2026 against 1991-2023). No PackageLicenseExpression changes (the owner's call). Refs #2602 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LGMKZYKjCq2pTmNWtKf2hy
Owner ruling, 2026-11-20. Asked: "should the published NuGet packages'
licence declarations name these two new sources? I'd add them: Core:
add `Unicode-3.0`... Stdlib: add `MIT` for PyYAML... The `sharpyc`
package: add both". Answer, verbatim: "yes".
- SharpyLang.Core: (Apache-2.0 OR MIT) AND Python-2.0 AND Unicode-3.0
- SharpyLang.Stdlib: (Apache-2.0 OR MIT) AND Python-2.0 AND MIT
- sharpyc: (Apache-2.0 OR MIT) AND Python-2.0 AND Unicode-3.0
AND MIT
A local pack of sharpyc carries tools/net10.0/any/Sharpy.Core.dll and
Sharpy.Stdlib.dll (and no per-module Stdlib DLL), so it needs both.
NuGet accepts the repeated MIT: `dotnet-serialized pack src/Sharpy.Stdlib`
and `pack src/Sharpy.Cli` succeed with no warning, and each nuspec keeps
the expression as written (<license type="expression">(Apache-2.0 OR
MIT) AND Python-2.0 AND MIT</license>; the sharpyc one names
Unicode-3.0 too), so the parser neither refuses nor normalises it.
Unicode-3.0 joins NUGET_ACCEPTED: isOsiApproved true (isFsfLibre
unset) in spdx/license-list-data json/licenses.json, read 2026-11-20.
The README test pinned only ids the package expressions add to the
project default, so PyYAML's MIT (already in `Apache-2.0 OR MIT`) was
invisible to it. test_package_licenses.py now pins each expression
whole (PACKAGE_EXPRESSIONS), and README.md's notices line must give each
package exactly the AND-terms its expression adds after
(Apache-2.0 OR MIT), checked per package segment. The README line now
names what each package ships.
Mutations (each restored with cp + cmp; green after: 16 passed):
| mutation | result |
|--------------------------------------------|-------------------------|
| Core drops `AND Unicode-3.0` | red: 2 failed/14 passed |
| | (ruled expression, |
| | README per package) |
| Stdlib drops `AND MIT` (PyYAML) | red: 2 failed/14 passed |
| README drops Core's `Unicode-3.0` | red: 1 failed/15 passed |
| | ("`SharpyLang.Core` is |
| | given ['Python-2.0']") |
| README drops Stdlib's `MIT` | red: 1 failed/15 passed |
Gate: pytest build_tools/tests 2262 passed / 0 failed / 0 skipped;
scorecard_metrics --check OK; Release packs of Stdlib and Cli built
clean.
Refs #2602
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LGMKZYKjCq2pTmNWtKf2hy
Fixes the #2780 independent review of 813d141 ("merge after fixes"). 1. C-implemented docstrings. The index now also reads the __doc__ of every module in sys.builtin_module_names and lib-dynload (test modules aside), of their functions and classes, and of the classes' methods and descriptors. math_module.spy (math.cosh, math.isnan, ...) and the Core/itertools/os/collections files the reviewer found are now matched and listed. 2. Wider matching. Both sides key every paragraph and every sentence (split at . ! ? before a capital), with * and ` markup removed, so a later paragraph's sentence (os.makedirs' "Super-mkdir; ...") and reST-marked text (shlex, glob, secrets) match. The floor is at least 30 characters after a final full stop is dropped (the old "longer than 30 with its full stop", which keeps Path.cs's "The logical parent of the path."). The notices now say verbatim sentences are credited; paraphrases and Doc/*.rst text are not matched, audited or listed. Of the reviewer's named cases, OrderedDict.cs, HtmlFunctions.cs, PlatformModule.cs and bisect_module.spy have no verbatim sentence and stay unlisted (difflib_module.spy's lines are paraphrases too); ChainMap.cs has one and is listed. The section's per-file "Upstream source" list was unguarded and is dropped. The list is the matcher's output exactly: 36 files. 3. Oracle. The CPython minor is read from .python-version. Without that interpreter the guard skips locally and fails when CI is set. A fake-environment unit test pins run/skip/fail, and the section must name the oracle minor. 4. src/Sharpy.Stdlib/Yaml/YamlScalarStyle.cs ports PyYAML's Emitter.analyze_scalar and choose_scalar_style. It is listed in the PyYAML section (lib/yaml/emitter.py, portion and drops described) and carries the PyYAML header. YamlControlEscapes and YamlFloatFormat are not derived. 5. Labels. listed_files reads the CPython list from the CPython heading, the Unicode and PyYAML sections use "Sharpy files derived from this source:", and a new guard requires those lists to equal the files whose header points at THIRD-PARTY-NOTICES.txt without PSF lines. Mutations (each restored with cp, checked with cmp: all "cmp ok"): | # | mutation | result | |---|-------------------------------------------------|-----------------| | 1a| reviewer's len.__doc__ into Len.cs's <summary> | red 1/73 | | 1b| index script: runtime = False | red 3/71 | | 2a| os.makedirs 2nd-paragraph sentence into | red 1/73 | | | bisect_module.spy | | | 2b| "Serialize obj to a JSON formatted str." (json. | red 1/73 | | | dumps, markup stripped) into bisect_module.spy | | | 2c| doc_keys without per-sentence keys | red 4/70 | | 2d| doc_keys without * and ` stripping | red 3/71 | | 3a| resolve_oracle returns "skip" on CI too | red 1/73 | | 3b| .python-version -> 3.16, CI=true | red: 2 errors | | | (without CI: the two oracle tests skip) | + 1 failed | | 4a| YamlScalarStyle.cs dropped from the PyYAML list | red 1/73 | | 4b| YamlScalarStyle.cs header dropped | red 1/73 | | 5a| listed_files searches from the top | red 1/73 | | 5b| PyYAML section takes the CPython label | red 2/72 | (n/m = failed/passed in test_third_party_notices.py; green: 74 passed. In 3b the 1 failure is the section-names-the-oracle pin, which fails with or without CI.) Gate: pytest build_tools/tests (python3.15) 2275 passed / 0 failed / 0 skipped; build sharpy.sln 0 warnings 0 errors; format whitespace --verify-no-changes clean; scorecard_metrics --check OK. No .spy content changed. Refs #2602 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LGMKZYKjCq2pTmNWtKf2hy
The second review of 813d141..978124c said "merge" with four cheap follow-ups: 1. A file counts as pointing at the notices when it names THIRD-PARTY-NOTICES anywhere, in any case ("See ... ." included), and carries no PSF header; the old exact "see THIRD-PARTY-NOTICES.txt" missed natural wording. Today that set is exactly the three listed files: StringExtensions.Format.cs, YamlScalarResolver.cs and YamlScalarStyle.cs. A unit test covers three wordings and the PSF exclusion. 2. The index skips every module whose name contains "test" (e.g. _ctypes_test, which CI's build ships and the _test prefix missed) and the xx example modules, through indexed_module(), embedded in the index script and unit-tested over a stand-in module list. 3. The docstring section must name no CPython minor but the oracle's (every 3.N or 3.N.M in it), not merely contain it. 4. CI counts as set only for "true" or "1", in any case; CI=false, 0 and empty skip. The fake-environment test covers all six. Mutations (each restored with cp, checked with cmp: all "cmp ok"): | # | mutation | result | |---|--------------------------------------------------|---------------| | r1| "// Derived from Foo 1.0 (MIT License). See | red 1/82 | | | THIRD-PARTY-NOTICES.txt." atop unlisted Len.cs | | | r2| indexed_module back to the _test/_xx/xx prefixes | red 1/82 | | | (_ctypes_test read) | | | r3| notices "CPython 3.15's" -> "CPython 3.16's" | red 1/82 | | r4| on_ci = bool(environ.get("CI")) | red 2/81 | | | (CI=false and CI=0 fail instead of skipping) | | (failed/passed in test_third_party_notices.py; green 83 passed.) Gate: test_third_party_notices.py + test_package_licenses.py 99 passed; pytest build_tools/tests (python3.15) 2284 passed / 0 failed / 0 skipped; scorecard_metrics --check OK. Only this test file changed. Refs #2602 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LGMKZYKjCq2pTmNWtKf2hy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
The independent review of #2777 (the CPython notices audit, #2602, charter R-NJ a) raised three follow-ups, and the owner ruled on them on 2026-11-20: "yes to 1-4".
Apache-2.0 OR MITwith no notices.The owner then ruled on the package licence expressions. The question asked: "should the published NuGet packages' licence declarations name these two new sources? I'd add them: Core: add
Unicode-3.0… Stdlib: addMITfor PyYAML… Thesharpycpackage: add both". The owner's answer, verbatim: "yes".Change
Docstrings
THIRD-PARTY-NOTICES.txtgains the section "API documentation summaries adapted from CPython docstrings", inside the CPython part.The guard in
test_third_party_notices.pyrequires that list to equal what its matcher finds over Sharpy.Core and Sharpy.Stdlib. The matcher:__doc__of builtins and of each built-in or C-implemented module, with test modules excluded;*/backtick markup and a final full stop;.spyfile.The oracle minor is read from
.python-version. Without that interpreter the guard skips locally but fails whenCI=true. The notices say that verbatim sentences are credited, and that paraphrases and Doc/*.rst text are not audited.Per-module packages
src/Sharpy.Stdlib/modules/Directory.Build.propssetsIsPackable=false.release.ymlpacks Cli, Core, Stdlib and Compiler by path.test_package_licenses.pyrefuses a packable default or a project override.Unicode and PyYAML
New notices sections give the upstream, version, derived portions and full licence text for:
StringExtensions.Format.cs;YamlScalarResolver.cs(its int and float resolvers) andYamlScalarStyle.cs(Emitter.analyze_scalar/choose_scalar_style).Each derived file gains a header comment. A guard requires these sections' lists to equal the set of non-PSF files that mention the notices.
The licence texts come from two places:
Both sections sit before the CPython section, so the CPython licence's sha256 guard holds.
Licence expressions (the owner's ruling above)
PackageLicenseExpression(Apache-2.0 OR MIT) AND Python-2.0 AND Unicode-3.0(Apache-2.0 OR MIT) AND Python-2.0 AND MIT(Apache-2.0 OR MIT) AND Python-2.0 AND Unicode-3.0 AND MITSharpy.Core.dllandSharpy.Stdlib.dll(measured by a local pack).MITwith no warning and keeps the expression as written.Unicode-3.0is OSI-approved per SPDX, and the SDK's NuGet.Packaging knows it.test_package_licenses.pypins each expression whole, and README.md's notices line names each package's added ids.Mutation record
Each mutation was restored with
cpand checked withcmp.AND Unicode-3.0AND MITUnicode-3.0MITlen.__doc__put into an unlisted<summary>doc_keyswithout per-sentence keysdoc_keyswithout markup strippingresolve_oracleskips on CI.python-versionset to 3.16 withCI=truelisted_filessearches from the topCI=falsetreated as CIGate
Local @
9d31a5ddd(lane worker, measured):pytest build_tools/testsunder python3.15: 2,284 passed / 0 failed / 0 skipped;scorecard_metrics --check: OK.Build (0 warnings, 0 errors) and format were measured @
978124ccb; no C# or project file changed after it.CI gate: 85,541 passed / 0 failed / 10 skipped @
9d31a5ddd(run 44826171510, measured); Gate (Python build tools) green. After #2781 merged, the merge ontodevis clean (tree6e475c6e5), and the notices and licence tests pass on that merge tree (99 passed).Issues
Refs #2602 (closed; this is its follow-up).
Independent review
Independent review @ 978124c: merge; 4 applied, 1 declined (reasons below); fixes 978124c..9d31a5d read by the lead
There were two passes by the same reviewer, both on
git archiveextracts under CPython 3.15.2.The first pass (@
813d1412d) returned merge after fixes:All five were applied in
978124ccb, which with0288f70aewent to the second pass.The second pass checked:
_decimaldropped);Applied from the second pass:
THIRD-PARTY-NOTICESin any wording._ctypes_testships on CI).CIcounts only astrue/1.Declined:
https://claude.ai/code/session_01LGMKZYKjCq2pTmNWtKf2hy
Generated by Claude Code