pyrefly: cluster A cleanup (imports + attrs)#4810
Open
rjpower wants to merge 1 commit intopyrefly/pr2-cluster-dfrom
Open
pyrefly: cluster A cleanup (imports + attrs)#4810rjpower wants to merge 1 commit intopyrefly/pr2-cluster-dfrom
rjpower wants to merge 1 commit intopyrefly/pr2-cluster-dfrom
Conversation
- Add site-packages to pyrefly search path so numpy/pandas/requests/
click/pydantic/transformers/… resolve from shipped py.typed metadata.
Drops missing-import surface from 1,279 to 56.
- Ship project-local jaxtyping stub at stubs/jaxtyping/__init__.pyi
covering Array/ArrayLike/DTypeLike/PRNGKeyArray/PyTree/Scalar plus
shape-generic classes (Float/Int/Bool/Shaped/…) and the concrete
dtype aliases re-exported by haliax.haxtyping (Float16/32/64,
BFloat16, Int/UInt{4..64}, Complex64/128).
- Fix real bug: lib/marin/src/marin/markdown/markdown.py imported
`regex` from itself instead of importing the module; all callsites
use `regex.compile(...)` so `import regex` matches usage.
- Re-enable three pyrefly categories that were globally disabled:
missing-attribute, unknown-name, missing-module-attribute. Residuals
(primarily NoneType narrowing + Equinox Module field access + jaxtyping
shape-string false positives) land in the baseline so new code can't
regress.
- Keep missing-import disabled globally as a documented boundary choice:
jax / equinox / optax / ray / flax / chex / jmp / vllm / lm_eval /
connectrpc / draccus / cloudpickle / tensorstore / humanfriendly /
tqdm_loggable / dupekit / harbor / trackio / mergedeep / fsspec /
transformers / google.* ship without sufficient type info. Per-site
ignores would be ~1.2k comments with zero additional signal.
Baseline: 15 → 9327 lines (1 → 776 diagnostics). The bulk comes from
un-suppressing missing-attribute (380) and unknown-name (144), both of
which were silently hidden before.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Contributor
|
Claude finished @rjpower's task in 2m 22s —— View job Code Review
FindingsNo issues found. Checked for bugs and CLAUDE.md / AGENTS.md compliance. Notes (not review findings, just observations for the author):
|
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.
Summary
Cluster A of the pyrefly tightening plan (see
.agents/projects/2026-04-15_pyrefly_tightening.md). Stacked on PR-2 (#4809).search-path change
Added
site-package-path = [".venv/lib/python3.11/site-packages"]to[tool.pyrefly]. Since the project already setsskip-interpreter-query = true, pyrefly previously had no way to see installed packages — everyimport numpy/requests/click/… wasmissing-import. This single change drops the unsuppressedmissing-importcount from 1,279 → 56.jaxtyping stub
stubs/jaxtyping/__init__.pyi(plus"stubs"onsearch-path). Surface:Array,ArrayLike,DTypeLike,PRNGKeyArray,PyTree,Scalar__class_getitem__ -> Any):Float,Int,Bool,Shaped,Key,Complex,UInt,Num,Real,Inexacthaliax.haxtyping:Float16/32/64,BFloat16,Int4/8/16/32/64,UInt4/8/16/32/64,Complex64/128Boundary suppression policy
missing-importstays globally disabled.pyproject.tomlnow carries a named list of vetted untyped libraries (jax, equinox, optax, ray, flax, chex, jmp, tensorstore, vllm, lm_eval, connectrpc, draccus, cloudpickle, humanfriendly, tqdm_loggable, dupekit, harbor, trackio, mergedeep, plus partial-stub libs fsspec/transformers/google.*) with a rationale comment explicitly marking this as a boundary choice, not a "we gave up" disable.Real bugs fixed
lib/marin/src/marin/markdown/markdown.py:12—from regex import regex(doesn't exist as an attribute on theregexpackage) →import regex. All callsites useregex.compile(...)which matches the fix.Verified already-fixed by earlier PRs:
marin.infra.tpu_monitordead imports (PR-0)haliax.core.ensure_tupletypo (PR-0)# noqa: F821onControllerDB/EndpointRegistry(PR-0)levanter/eval.pybarevocab/tag— these are jaxtyping shape strings (Int[Array, "vocab"]), not real bugs. They remain in the baseline.Optional-narrowing sweep
Deferred to per-package follow-ups. The ~120
NoneType-has-no-attribute sites acrossmarin/rl,iris/providers,fray/clusterseach require reading the call site and adding anassert x is not None/cast(T, x)/ signature refactor. That is 4-6 engineer-days of work per the cluster-A memo (logs/pyrefly-tightening/stage3-cluster-a.md§9). They land in the baseline now so new code cannot regress, and a follow-up PR can pick them up per-package with real review bandwidth.Categories re-enabled in
[tool.pyrefly.errors]missing-attribute(was false) — residual 380 in baselineunknown-name(was false) — residual 144 in baseline (mostly jaxtyping shape-string false positives)missing-module-attribute— cleared to 0, category removedmissing-importstays disabled (documented boundary).Baseline delta
The baseline grew because three previously silently-suppressed categories are now visible and file:line:col-scoped.
Test plan
./infra/pre-commit.py --all-filespassesuvx pyrefly@0.61.0 checkreports0 errors (381 suppressed, 115 warnings not shown)🤖 Generated with Claude Code