Skip to content

build: notices follow-ups (docstring summaries, per-module packaging, Unicode and PyYAML credits) - #2780

Merged
antonsynd merged 6 commits into
devfrom
claude/notices-followups
Nov 20, 2026
Merged

antonsynd merged 6 commits into
devfrom
claude/notices-followups

Conversation

@antonsynd

@antonsynd antonsynd commented Nov 20, 2026 •

Copy link
Copy Markdown
Owner

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".

  • API summaries copied from CPython docstrings are not credited.
  • The per-module Stdlib projects compile CPython ports, yet they are packable under Apache-2.0 OR MIT with no notices.
  • Two non-CPython sources are not credited: Unicode's CaseFolding.txt and PyYAML's resolver and emitter.

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: add MIT for PyYAML… The sharpyc package: add both". The owner's answer, verbatim: "yes".

Change

Docstrings

THIRD-PARTY-NOTICES.txt gains the section "API documentation summaries adapted from CPython docstrings", inside the CPython part.

  • It lists 36 files and credits them under the PSF licence by reference.
  • No PSF headers were added. The census "behaviour" files stay header-free.

The guard in test_third_party_notices.py requires that list to equal what its matcher finds over Sharpy.Core and Sharpy.Stdlib. The matcher:

  • indexes CPython 3.15's Lib/ docstrings, plus the __doc__ of builtins and of each built-in or C-implemented module, with test modules excluded;
  • keys every paragraph and every sentence of at least 30 characters;
  • ignores case, whitespace, */backtick markup and a final full stop;
  • skips C# generated from a .spy file.

The oracle minor is read from .python-version. Without that interpreter the guard skips locally but fails when CI=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.props sets IsPackable=false.
  • Nothing packed these projects before: release.yml packs Cli, Core, Stdlib and Compiler by path.
  • test_package_licenses.py refuses a packable default or a project override.

Unicode and PyYAML

New notices sections give the upstream, version, derived portions and full licence text for:

  • Unicode License V3, for the case-fold table in StringExtensions.Format.cs;
  • PyYAML 6.0.3 (MIT), for YamlScalarResolver.cs (its int and float resolvers) and YamlScalarStyle.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:

  • PyYAML's is the 6.0.3 tag's LICENSE, verbatim.
  • Unicode's is the first section of the Unicode Consortium's ICU repository LICENSE, verbatim. unicode.org could not be reached from the session. The text matches SPDX's Unicode-3.0 apart from the copyright years.

Both sections sit before the CPython section, so the CPython licence's sha256 guard holds.

Licence expressions (the owner's ruling above)

Package PackageLicenseExpression
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
  • sharpyc's tool package ships Sharpy.Core.dll and Sharpy.Stdlib.dll (measured by a local pack).
  • NuGet packs the repeated MIT with no warning and keeps the expression as written.
  • Unicode-3.0 is OSI-approved per SPDX, and the SDK's NuGet.Packaging knows it.
  • SharpyLang.Compiler depends on the Core package rather than bundling it, so it keeps the default expression.
  • test_package_licenses.py pins each expression whole, and README.md's notices line names each package's added ids.

Mutation record

Each mutation was restored with cp and checked with cmp.

Mutation Result
IsPackable false → true red
heapq.spy dropped from the docstring entry red
bisect.insort's docstring copied into bisect_module.spy red
Core drops AND Unicode-3.0 red
Stdlib drops AND MIT red
README drops Core's Unicode-3.0 red
README drops Stdlib's MIT red
len.__doc__ put into an unlisted <summary> red
index without runtime docstrings red
os.makedirs' second-paragraph sentence copied red
markup-stripped json.dumps text copied red
doc_keys without per-sentence keys red
doc_keys without markup stripping red
resolve_oracle skips on CI red
.python-version set to 3.16 with CI=true red
YamlScalarStyle.cs dropped from the PyYAML list red
YamlScalarStyle.cs header dropped red
listed_files searches from the top red
PyYAML section takes the CPython label red
"See THIRD-PARTY-NOTICES.txt." header on an unlisted file red
test-module exclusion reverted to prefixes red
the notices name a second CPython minor red
CI=false treated as CI red

Gate

Local @ 9d31a5ddd (lane worker, measured):

  • pytest build_tools/tests under 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 onto dev is clean (tree 6e475c6e5), and the notices and licence tests pass on that merge tree (99 passed).

Issues

Refs #2602 (closed; this is its follow-up).

sharpy-issues:
  closes: []
  files: []

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 archive extracts under CPython 3.15.2.

The first pass (@ 813d1412d) returned merge after fixes:

  • C-implemented docstrings were not indexed;
  • the matcher was too narrow;
  • the guard skipped silently after an oracle bump;
  • YamlScalarStyle.cs was an uncredited PyYAML port;
  • the labels were fragile.

All five were applied in 978124ccb, which with 0288f70ae went to the second pass.

The second pass checked:

  • that the index is the same on CI's hostedtoolcache build and on the session's uv build (36/36 with _decimal dropped);
  • the sentence splitter, against four alternatives;
  • the licence expressions, by reading the csproj files and the SDK's NuGet.Packaging;
  • the README pins.

Applied from the second pass:

  1. The header guard matches THIRD-PARTY-NOTICES in any wording.
  2. Test modules are excluded by name (_ctypes_test ships on CI).
  3. The section may name no CPython minor other than the oracle's.
  4. CI counts only as true/1.

Declined:

  • 108 summary sentences sit one word from a CPython docstring, so a wording edit can turn the guard red. It fails loudly, naming the file, and the notices already say paraphrases are not matched.

https://claude.ai/code/session_01LGMKZYKjCq2pTmNWtKf2hy


Generated by Claude Code

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
@antonsynd
antonsynd merged commit f09bffc into dev Nov 20, 2026
37 of 38 checks passed
@antonsynd
antonsynd deleted the claude/notices-followups branch November 20, 2026 22:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants