Repository navigation
pants-pyrefly 1.1.0
pants check no longer rebuilds the third-party venv on every Pyrefly run, which on a large lockfile was most of its time. Pyrefly now gets one config for every file it loads. Every stable Pyrefly from 1.1.1 is pinned, and the default is now 1.3.2. No breaking changes: the goals, [pyrefly] options, and skip_pyrefly field behave as before. Some diagnostics can change, from the newer default Pyrefly and from the config handling; the entries below say when.
-
Every stable Pyrefly from 1.1.1 up to the default is now pinned: 1.1.1, 1.2.0, 1.2.1, 1.3.0, 1.3.1, and 1.3.2. Select any of them with just
[pyrefly].version = "..."; noknown_versionsoverride is needed. Existingversion = "1.1.1"or"1.2.0"pins keep working after upgrading the plugin. (The 1.0.0 entry's advice to pin1.1.1did not actually work on 1.0.0, which pinned only 1.2.0; it works as of this release.) See Supported Pyrefly versions for the policy. -
The default pinned Pyrefly is now 1.3.2 (was 1.2.0). No plugin behavior changes, but the newer Pyrefly changes what some builds report:
- Renamed error kind. The dataclass-field-assigned-an-inconsistent-data-descriptor error that 1.2.0 reported as
bad-class-definitionisbad-dataclass-descriptorin 1.3. Anything that names the old kind stops matching it under 1.3.x: 1.2.0-era baseline entries,# pyrefly: ignore[bad-class-definition]comments (including onespants pyrefly-suppresswrote),[pyrefly].only, and[errors]settings in your Pyrefly config. Under the no-configbasicpreset, 1.3.2 does not report this error at all. - New diagnostics can surface errors 1.2.0 did not report, e.g. invalid literal regular expressions (
regex). Which ones fire depends on your config:regexis reported when a Pyrefly config file is in effect, but not under thebasicpreset. Invalidmock.patchtargets are reported as warnings (missing-attribute-patch-target), which the defaulterrorseverity hides. Open-type match exhaustiveness (non-exhaustive-match-open-type) is off unless you enable it in[errors]. The summary line now also counts hidden warnings (INFO 2 errors (… 1 warning not shown)). - Compact baseline format.
pants pyrefly-update-baselinenow writes entries withpath,column,name,concise_description, andseverity, and dropsline,stop_line,stop_column,code, anddescription, so regenerating a committed baseline rewrites the whole file once. 1.3.x still honors existing full-format baselines, except entries for the renamed kind above. The change is one-way: a baseline written by 1.3.x does not suppress anything under older Pyrefly, so regenerate it after pinning back. # type: ignore[<code>]comments carrying another tool's codes (e.g. a MyPy code) still suppress everything on the line, as before. 1.3 adds# type: ignore[pyrefly:<code>]for targeted suppression.
- Renamed error kind. The dataclass-field-assigned-an-inconsistent-data-descriptor error that 1.2.0 reported as
-
Removed Pyrefly versions now fail with a reason. A version is removed from the pins only deliberately, with the reason recorded in
DENYLISTED_VERSIONS(insubsystems.py) and a CHANGELOG note. Selecting one with[pyrefly].versionfails withDenylistedPyreflyVersion: Pyrefly X is not supported by pants-pyrefly: <reason>. Set [pyrefly].version to a supported release (<default>).instead of Pants's genericUnknownVersion. Supplying your own[pyrefly].known_versionsentry for it still works. The denylist is empty in this release. -
Fixed: Pyrefly 1.3's baseline flags in
[pyrefly].args.--error-stale-baselinenow works. Before, every partition received the whole merged baseline. Inside a partition's sandbox, entries for files checked by other partitions point at paths that do not exist, so Pyrefly reported them as stale.checkthen failed every partition even when nothing was stale, and also failed when checking a subset such aspants check src/a::. Each partition now gets only the entries for its own files. A truly stale entry fails only the partition that checks its file. Entries for deleted files are still reported as stale, once per run, by the first partition, so a subset run can fail on them too. Without the flag, the same errors are gated as before; an entry only ever matched errors in its own file.- Known limitation: baseline entries are keyed by path only. A file checked by several partitions (e.g.
parametrizeover interpreter constraints) with an error in only some of them keeps failing--error-stale-baseline. Use an inline# pyrefly: ignore[<error-kind>]for such errors. See the README. pants pyrefly-update-baselineignores--error-stale-baseline. Before, it failed with exit code 2, because Pyrefly rejects the flag alongside--update-baseline.--prune-baselinenow fails fast.checkandpyrefly-update-baselineexit with aPyreflyArgsErrorthat namespants pyrefly-update-baseline ::. Before,checkpassed and the baseline file was silently left unchanged, because Pyrefly pruned a temporary copy in the sandbox;pyrefly-update-baselinefailed with exit code 2. Whencheckfails on stale entries, Pyrefly's "rerun with--prune-baseline" hint now says to runpants pyrefly-update-baseline ::instead. The README now warns that update-baseline rewrites the whole file from only the targets given, so a subset run drops all other entries.
-
Missing-import hints now name your real source roots. Pyrefly's
Looked in these locationshint listed the plugin's internal sandbox directories, e.g.Search path override (from command line): ["__pyrefly_root_0", "__pyrefly_root_1"]. It now lists the source roots they stand for, e.g.[".", "src/python"](.is the build root), in every[pyrefly].output_format, with or without--color=always. The same applies to thedescriptionfield of baselines written bypants pyrefly-update-baselineunder Pyrefly older than 1.3, which also recorded the absolute sandbox path and so changed on every regeneration; regenerate such a baseline once to clean it up. Gating is unaffected, since Pyrefly does not match baseline entries ondescription. Only the internal names the plugin generated for that run are rewritten, and only as whole path segments, so user code or messages that merely contain such a name are left alone. -
Fixed: every Pyrefly run rebuilt the third-party venv. Pyrefly finds your third-party packages through a venv that Pants keeps in its shared
pex_rootnamed cache. The plugin did not mount that cache into Pyrefly's sandbox, so each Pyrefly process (checkand thepyrefly-*goals that read your third-party packages) rebuilt the whole venv before Pyrefly started, even when nothing had changed. The rebuild time grows with the size of the resolve; with a large lockfile it was most of the timepants checkspent. The venv is now built once and reused, as it is for Pants' own Python tools. A CI runner that starts with an empty named-caches directory still builds it once per run.Because the venv now lives outside the sandbox, the plugin also passes your discovered config (
pyrefly.toml, orpyproject.tomlwith[tool.pyrefly];pyrefly.tomlwins if both exist, as in Pyrefly) to Pyrefly as--config, as it already did for[pyrefly].config. Pyrefly then uses that one config for your code and your third-party packages, aspyrefly checkdoes in project mode and as Pyrefly's Bazel and Buck integrations do, so third-party packages are still analyzed with your config. A discovered config now behaves exactly like one set with[pyrefly].config, which changes three edge cases:disable-project-excludes-heuristics = trueis now honored: files Pants passes in undervenv/,node_modules/or__pycache__/directories are checked, instead of skipped with aSkipping include patternwarning.- A config that fails to parse is a fatal error, instead of Pyrefly printing the parse error and checking with defaults.
- A third-party package that ships its own
pyrefly.tomlor[tool.pyrefly]is analyzed with your config instead of its own.
A
--configor-cin[pyrefly].argsstill replaces the plugin's, since Pyrefly rejects a repeated--config.If the plugin finds no config to pass (no root
pyrefly.tomlor[tool.pyrefly], orconfig_discovery = falsewithout[pyrefly].config), it passes a generated one holding what Pyrefly uses when it finds none,preset = "basic". Pyrefly no longer searches for a config per file, so no config outside your repo applies: before, a Pyrefly, mypy or pyright config in a directory above Pants' sandbox could apply to your files, and one above Pants' cache (such as your home directory) to third-party packages. Visible changes for projects without a config:- Third-party packages that ship a
mypy.iniorpyrightconfig.jsonare analyzed with thebasicpreset instead of a config Pyrefly converted from theirs, so code that uses them can report errors it did not before. Pyrefly's warnings about converting those files (e.g.Invalid search-path: .../site-packages/<package>/...) are gone. - Pyrefly's "No
pyrefly.tomlfound — using presetbasic" notice no longer appears. Runpants pyrefly-initto create a config. pants pyrefly-dump-configshows the generated config (preset = "basic", at__pyrefly_config.tomlin the sandbox) instead of Pyrefly's default configuration.
-
Releases are now gated on a Pyrefly compatibility suite (
build-support/ci/compat_test.sh, run by.github/workflows/compat.ymlfor every supported version). It drives real Pants runs ofcheck,pyrefly-update-baseline, andpyrefly-suppresswith only--pyrefly-versionset, and asserts that the requested Pyrefly binary is the one that ran. It also runs the default Pyrefly on the latest patch of every supported Pants minor: 2.27.1, 2.28.1, 2.29.1, 2.30.2, 2.31.0, 2.32.1, and 2.33.1, and against aCPython==3.9.*project, asserting that Pyrefly checks it as Python 3.9. The release workflow publishes nothing if any of these jobs fails. -
Maintenance:
build-support/bin/generate_known_versions.pynow manages the pins.--writeonly adds pins (stable releases up to the default, skipping pre-releases and denylisted versions) and never rewrites existing ones.--checkverifies only the shipped pins (checksums, default pinned, order, nothing denylisted), so new upstream releases or backports never fail it.--check-upstreamlists stable releases that are neither pinned nor denylisted.--removeis the only way to drop a version,--list-versionsprints the supported set, and--default-versionprints the default.--writeand--removeeditsubsystems.pyline by line, leaving comments and formatting untouched, and denylist reasons are written as single-line UTF-8 literals inruff format's quote style. Failures print a singleerror: ...line (with file and line where relevant), never a traceback. The script sends the GitHub token only toapi.github.com, rejects malformed.sha256sidecars, and retries transient network failures, including downloads cut off mid-body. -
Maintenance: a weekly workflow (
.github/workflows/upstream.yml) runsgenerate_known_versions.py --check-upstreamand fails when a stable Pyrefly release is neither pinned nor denylisted, showing the script's output in the job summary. It only reports: it never writes pins or opens a PR. On failure,--check-upstreamprints the exact commands to pin the new releases (or skip one). -
Maintenance: Dependabot (
.github/dependabot.yml) now opens one grouped weekly PR for GitHub Actions updates. Python dependencies stay out of it, since Dependabot cannot regenerate Pants lockfiles. -
Maintenance: the repo now develops, tests, and builds releases on Pants 2.33.1 (was 2.32.0). PR CI smoke-tests the latest patch of a subset of the supported minors: 2.27.1, 2.31.0, 2.32.1, and 2.33.1. The supported Pants range (2.27–2.33) and the published wheel's requirements are unchanged.