Skip to content

chore: faster and stricter mypy - #2968

Open
henryiii wants to merge 4 commits into
pypa:mainfrom
henryiii:henryiii/chore/mypyspeed
Open

chore: faster and stricter mypy#2968
henryiii wants to merge 4 commits into
pypa:mainfrom
henryiii:henryiii/chore/mypyspeed

Conversation

@henryiii

@henryiii henryiii commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

I'm not sure it's possible to reuse a wheel in pyodide, but it was a logical bug anyway.

🤖 AI text below 🤖

Two mypy changes:

  • native_parser = true, which makes mypy about 26% faster from a cold cache.
  • More error codes, including possibly-undefined and exhaustive-match, plus fixes for everything they report.

Two of the fixes are real bugs:

  • Pyodide set built_wheel instead of repaired_wheel when it reused a compatible wheel, so the test step failed with a NameError.
  • The OCI container read loop had no EOF guard, so it looped forever if the container shell exited.

bashlex has no stubs, so no-any-unimported is disabled for cibuildwheel.bashlex_eval only.

@freakboy3742 freakboy3742 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree there's a potential endless loop on EOF; but as the test suite bears out, theres either a testing gap or different handling required.

Other than that, the changes all makes sense to me.

@henryiii

henryiii commented Aug 17, 2026

Copy link
Copy Markdown
Contributor Author

The other PRs are stuck in the 3-hour timeout.

🤖 AI text below 🤖

The test failure is an environment regression on the new GitHub runner images, not a behavior change from the EOF fix — the fix is what made it visible.

Before this change, that scenario busy-looped forever on EOF; now it errors immediately.

Pushed a fix to the test: it queries podman info --format '{{.Host.OCIRuntime.Path}}' and carries that runtime into the generated containers.conf, so the test uses the same runtime binary as podman's default configuration.

This makes mypy around 26% faster from a cold cache.

Signed-off-by: Henry Schreiner <henryfs@princeton.edu>
Turn on possibly-undefined, exhaustive-match, and other strict flags, and
fix what they report. Two real bugs: pyodide never set `repaired_wheel`
when it reused a compatible wheel, so the test step failed with a
NameError; the OCI shell read loop spun forever if the shell exited.

Assisted-by: ClaudeCode:claude-opus-5
Podman ignores its usual config files when CONTAINERS_CONF is set, so it
falls back to the first runtime found on PATH. On current GitHub Ubuntu
runner images that is crun 1.14.1, which cannot parse the OCI spec v1.2.x
config that podman 5.8.4 generates ("crun: unknown version specified").
Query the default runtime path and set it in the generated config.

Assisted-by: ClaudeCode:claude-fable-5
@henryiii
henryiii force-pushed the henryiii/chore/mypyspeed branch from 62459fe to 39324d0 Compare August 17, 2026 05:02
mypy on macOS marks the rest of the function unreachable after the
darwin pytest.skip, so the strict index error only appears on Linux.

Assisted-by: ClaudeCode:claude-fable-5
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