Skip to content

Decide the Python Directory Gate's Behavior-Changing Edge Cases #1936

Closed

Description

@ptr727

Problem

These items were split off #1917 because each one changes what the Python directory gate accepts or runs. The prose and small code fixes from that issue were handled separately. Item numbers are #1917's own.

  1. mypy on a declared pip directory (item 2). The command-line --python-version overrides a python_version the repo pins in its own mypy config. mypy running under uvx also cannot import a plugin that is installed only in .venv.
  2. Type-checker config only at the root (item 3). The checker lookup reads only the declared directory. So a monorepo that keeps [tool.mypy] or [tool.pyright] in the root pyproject.toml fails with "configures neither".
  3. unittest discovery (item 4). discover -s tests exits 5 on pytest-style plain test functions, and no message explains why. It also silently skips a nested test directory that has no __init__.py.
  4. Name-matched test modules (item 5). The lint-only exclusion is gone. A python-typed lint-only repo holding a script that is merely named test_*.py now owes a Codecov claim.
  5. The audit's caller check (item 9). It reads only a job keyed validate. A renamed job, or a flow-mapping with: { python-directories: X }, is skipped or misread.
  6. Caller-level selftest cases (item 14). The audit selftest now checks declared_types() directly. But its callers in spec/audit.py still have no case with a malformed types value. If one of them goes back to reading entry.get("types", []), every selftest still passes.

Each needs a decision on the intended behavior before it is fixed, so they can land separately.

A seventh gap turned up while reviewing the #1917 fixes:

  1. A tool-config-only pip directory has no profile. Take a directory whose pyproject.toml carries only [tool.*] config and sits beside a requirements*.txt. The validator installs it with pip, and python.uvlock.pinned calls it build. It matches neither shape python.profile.detect defines, and it carries neither a uv.lock nor the project metadata that "a build one must" requires.

Activity

  1. ptr727 commented on Sep 27, 2026

    @ptr727
    OwnerAuthor

    Maintainer decisions, 2026-09-27:

    1. mypy on a declared pip directory: respect the repo's config. Skip the injected --python-version when the config pins python_version. Run mypy from .venv when it is installed there, and use uvx otherwise.
    2. Checker config at the root: fall back to the repo-root config when the declared directory has none, and accept setup.cfg [mypy].
    3. unittest discovery: trap exit 5 and print a message naming both causes: pytest-style plain functions, and a nested test directory without __init__.py. Stay stdlib-only.
    4. Name-matched test modules: leave as is. The broad detector is deliberate. A script merely named test_*.py in a lint-only repo is fixed by renaming it.
    5. The audit's caller check: fail loud. A job that uses validate-task.yml under a key other than validate, or a flow-mapping with:, reports a finding that the audit cannot read it, rather than being skipped or misread.
    6. Caller-level selftest cases: add a malformed-types case to each caller's selftest table that lacks one. python_type_findings already has one, so this item was only partly true.
    7. A tool-config-only pip directory: document it as build. Extend python.profile.detect so a directory with requirements*.txt is build, installed with pip, matching what shape() already does.
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