Skip to content

Close the Python Directory Gate's Deferred Edge Cases #1917

Closed

Description

@ptr727

Problem

The final local strict review of #1914 found no real failure path for any repo shape the fleet holds today. It did list these edge cases, deferred rather than fixed on that PR by the maintainer's call, most likely first:

  1. BOM in pyproject.toml. python_directories.py reads it as utf-8, and tomllib rejects a leading BOM. So an undeclared root whose pyproject.toml carries one now fails, where ruff and mypy accepted it before. Reading with utf-8-sig closes this.
  2. mypy on a declared pip directory. The command-line --python-version overrides a python_version pinned in the repo's own mypy config. And mypy running under uvx cannot import a plugin installed only in .venv.
  3. A subdirectory with type-checker config only at the root. The checker lookup reads only the declared directory, so a monorepo whose [tool.mypy] or [tool.pyright] lives in the root pyproject.toml fails with "configures neither".
  4. unittest discovery. discover -s tests exits 5 on pytest-style plain functions, with no coverage-specific message, and it silently skips nested test directories that have no __init__.py.
  5. Name-matched test modules. With the lint-only exclusion gone, a python-typed lint-only repo holding a script merely named test_*.py now owes a Codecov claim.
  6. Prose: detection. AUDIT.md's classification line and spec/project-types.json's python detect give no carve-out for the carried hub-fetch-run.py, which the resolver and audit now skip.
  7. Prose: WORKFLOW.md D1.2. It no longer says the undeclared root's test leg also needs tests/ plus a uv.lock or requirements*.txt.
  8. Prose: the python-codestyle profiles. In references/profiles.md, "A script that carries a gate still earns tests" is conditional, while a declared directory owes tests unconditionally. python.profile.detect also does not list requirements*.txt among what a lint-only subtree must not carry.
  9. The audit's caller check. It reads only a job keyed validate, so a renamed job, or a flow-mapping with: { python-directories: X }, is skipped or misread.

Items 1 and 6 are the ones worth doing first. 1 is the only departure from "an undeclared root keeps the old gate exactly", and 6 contradicts behavior that has already shipped.

Activity

  1. ptr727 commented on Sep 27, 2026

    @ptr727
    OwnerAuthor

    Two more from the local strict review of the promotion fix, both edge cases:

    1. python_directories.py reads pyproject.toml a second time to decide whether to name a byte-order mark in its TOML error. A file deleted between the two reads raises an uncaught FileNotFoundError instead of ::error::. Detecting the mark from the text already read closes this.
    2. spec/secrets.json's mechanisms.codecov.note still says a csharp or python repo lists CODECOV_TOKEN unconditionally, while the top-level note now says only a repo with tests for that language owes it.
  2. ptr727 commented on Sep 27, 2026

    @ptr727
    OwnerAuthor

    Three more, from the local review of the registry types gate, all edge cases:

    1. spec/validate.py empties repo_types when the shape check fails. So a mixed list such as ["pythn", 3] hides the unknown-type error for pythn until a second run, and a declared profile then also draws a false "not one of the repo's types" error. Keeping the list's string elements, as declared_types() does in the audit, closes both.
    2. scripts/carry.py still reads entry.get("types", []) unguarded, in selector_set and two prints. resolve_repo accepts an entry of any status, while the new shape check runs only for cataloged entries, so a backlog entry with a string types still reaches it.
    3. The audit selftests reach declared_types() through two of its callers only. The other guarded readers have no case with a malformed value.
  3. ptr727 commented on Sep 27, 2026

    @ptr727
    OwnerAuthor
    1. declared_types() in spec/audit.py says it returns "none" for a non-list types, which can read as Python None, while it returns []. And spec/validate.py now answers an explicit "types": null on a cataloged entry with the shape error rather than "cataloged repo has no types (add types or mark it backlog)", dropping that remedy. Both are wording only.
  4. ptr727 commented on Sep 27, 2026

    @ptr727
    OwnerAuthor

    Item 1 (BOM) is settled in a5bdc15 (#1919), but not by stripping the mark. tomllib, mypy, and the workflow's editable-install probe all reject a byte-order mark, so the resolver now fails with an error naming it rather than letting the file past to be misread later. The undeclared root's old gate accepted a BOM file only because nothing parsed it, and mypy silently dropped its config there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions