Skip to content

Releases

pants-pyrefly 1.2.1

Choose a tag to compare

@github-actions github-actions released this 23 Nov 21:19
22e5b35

Pins Pyrefly 1.5.0 and makes it the default. No plugin code changes: the goals, [pyrefly] options, and skip_pyrefly field behave as before. Every version pinned in 1.2.0 is still pinned; to stay on the old default, set [pyrefly].version = "1.4.1".

  • The default pinned Pyrefly is now 1.5.0 (was 1.4.1); 1.4.1 stays pinned. The newer Pyrefly changes what some builds report (see the Pyrefly 1.5.0 release notes):
    • Warnings are printed by default, e.g. uses of deprecated APIs, redundant-cast, and unnecessary-type-conversion. They do not change the exit code, so pants check passes or fails as before, and pants pyrefly-update-baseline and pants pyrefly-suppress ignore them. To hide them, set [pyrefly].min_severity = "error".
    • Annotations look up names in the enclosing class body first, and uninitialized names and illegal circular references in annotations are now reported, which can surface errors 1.4.1 did not report.
    • unreachable now defaults to the new IDE-only hint severity (was warn), so it no longer appears in pants check output unless configured as "warn" or "error".

pants-pyrefly 1.2.0

Choose a tag to compare

@tague tague released this 09 Nov 20:21
09325e2

Adds support for Python 3.15 projects and makes Pyrefly 1.4.1 the default. No breaking changes: the goals, [pyrefly] options, and skip_pyrefly field behave as before, and every version pinned in 1.1.1 is still pinned. To stay on the old default, set [pyrefly].version = "1.4.0".

  • Python 3.15 projects are supported on Pants 2.31 and newer, once "3.15" is added to [python].interpreter_versions_universe (no Pants release includes it yet). The compatibility suite now checks a CPython==3.15.* project. On Pants 2.27–2.30, the pex that Pants bundles cannot run on Python 3.15, so Pants fails before Pyrefly runs.
  • The [pyrefly].interpreter_constraints fallback, used only for a target with no interpreter constraints of its own, is now CPython>=3.9,<3.16 (was <3.15).
  • The default pinned Pyrefly is now 1.4.1 (was 1.4.0); 1.4.0 stays pinned. The release notes list changes only to pyrefly coverage (see the Pyrefly 1.4.1 release notes), so pants check should report the same errors, but pants pyrefly-coverage can report a different percentage: results are now the same on every run, functions and classes excluded with @type_check_only or @no_type_check are no longer counted as untyped variables, and a variable assigned an explicitly parameterized constructor call (x = set[int]()) counts as typed.

pants-pyrefly 1.1.1

Choose a tag to compare

@tague tague released this 09 Nov 20:21
47f0eab

Pins Pyrefly 1.4.0 and makes it the default. No plugin code changes: the goals, [pyrefly] options, and skip_pyrefly field behave as before. Every version pinned in 1.1.0 is still pinned; to stay on the old default, set [pyrefly].version = "1.3.2".

  • The default pinned Pyrefly is now 1.4.0 (was 1.3.2). The newer Pyrefly changes what some builds report (see the Pyrefly 1.4.0 release notes):
    • Stricter checks on by default can surface errors 1.3.2 did not report, e.g. TypeVar bounds and constraints are now enforced when the expected type contains Any, and @property getters with extra required parameters are flagged. Many false positives are also fixed, so some # pyrefly: ignore comments and baseline entries may become unused.
    • Renamed error kind. incompatible-overload-residual is now incompatible-overload-argument. Pyrefly keeps the old name as a deprecated alias.
    • --typeshed-path replaces the bundled typeshed instead of overlaying it. This matters only if you pass it through [pyrefly].args.
    • New opt-in error kinds (unknown-attribute-access, unknown-return-type, untyped-function-decorator, uninitialized-instance-variable, and others) are off unless you enable them in [errors].

pants-pyrefly 1.1.0

Choose a tag to compare

@tague tague released this 09 Nov 20:21
1aed58a

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 = "..."; no known_versions override is needed. Existing version = "1.1.1" or "1.2.0" pins keep working after upgrading the plugin. (The 1.0.0 entry's advice to pin 1.1.1 did 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-definition is bad-dataclass-descriptor in 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 ones pants pyrefly-suppress wrote), [pyrefly].only, and [errors] settings in your Pyrefly config. Under the no-config basic preset, 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: regex is reported when a Pyrefly config file is in effect, but not under the basic preset. Invalid mock.patch targets are reported as warnings (missing-attribute-patch-target), which the default error severity 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-baseline now writes entries with path, column, name, concise_description, and severity, and drops line, stop_line, stop_column, code, and description, 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.
  • Removed Pyrefly versions now fail with a reason. A version is removed from the pins only deliberately, with the reason recorded in DENYLISTED_VERSIONS (in subsystems.py) and a CHANGELOG note. Selecting one with [pyrefly].version fails with DenylistedPyreflyVersion: Pyrefly X is not supported by pants-pyrefly: <reason>. Set [pyrefly].version to a supported release (<default>). instead of Pants's generic UnknownVersion. Supplying your own [pyrefly].known_versions entry for it still works. The denylist is empty in this release.

  • Fixed: Pyrefly 1.3's baseline flags in [pyrefly].args.

    • --error-stale-baseline now 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. check then failed every partition even when nothing was stale, and also failed when checking a subset such as pants 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. parametrize over 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-baseline ignores --error-stale-baseline. Before, it failed with exit code 2, because Pyrefly rejects the flag alongside --update-baseline.
    • --prune-baseline now fails fast. check and pyrefly-update-baseline exit with a PyreflyArgsError that names pants pyrefly-update-baseline ::. Before, check passed and the baseline file was silently left unchanged, because Pyrefly pruned a temporary copy in the sandbox; pyrefly-update-baseline failed with exit code 2. When check fails on stale entries, Pyrefly's "rerun with --prune-baseline" hint now says to run pants 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 locations hint 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 the description field of baselines written by pants pyrefly-update-baseline under 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 on description. 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_root named cache. The plugin did not mount that cache into Pyrefly's sandbox, so each Pyrefly process (check and the pyrefly-* 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 time pants check spent. 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, or pyproject.toml with [tool.pyrefly]; pyrefly.toml wins 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, as pyrefly check does 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 = true is now honored: files Pants passes in under venv/, node_modules/ or __pycache__/ directories are checked, instead of skipped with a Skipping include pattern warning.
    • 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.toml or [tool.pyrefly] is analyzed with your config instead of its own.

    A --config or -c in [pyrefly].args still replaces the plugin's, since Pyrefly rejects a repeated --config.

    If the plugin finds no config to pass (no root pyrefly.toml or [tool.pyrefly], or config_discovery = false without [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.ini or pyrightconfig.json are analyzed with the basic preset 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.toml found — using preset basic" notice no longer appears. Run pants pyrefly-init to create a config.
    • pants pyrefly-dump-config shows the generated config (preset = "basic", at __pyrefly_config.toml in 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.yml for every supported version). It drives real Pants runs of check, pyrefly-update-baseline, and pyrefly-suppress with only --pyrefly-version set, 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,...

Read more

pants-pyrefly 1.0.0

Choose a tag to compare

@tague tague released this 09 Nov 20:21
0f6f9c6

First stable release. No breaking changes from 0.5.0 — the goals, [pyrefly] options, and skip_pyrefly field all behave as they did; the bump declares the surface stable rather than changing it. See Stability for what the compatibility promise now covers and what stays an implementation detail.

  • Pants 2.33 is supported. The consumption smoke-test matrix now covers 2.27, 2.31, 2.32, and 2.33, so the version-conditional rules-API shim is verified on the current Pants line.
  • The default pinned Pyrefly is now 1.2.0 (was 1.1.1). Pin the old one with [pyrefly].version = "1.1.1" if a new Pyrefly release changes what your build reports.
  • Documented how import resolution actually works as of 0.5.0: the README described only the 0.4.0 nearest-root dedup, which check and pyrefly-suppress no longer use — they re-stage each source root into an isolated sibling directory instead. The diagnostic goals (pyrefly-coverage, pyrefly-dump-config, pyrefly-lsp-config) still pass nearest-root-deduped real source roots.

pants-pyrefly 0.5.0

Choose a tag to compare

@tague tague released this 09 Nov 20:21
9026c06
  • Nested source roots no longer produce spurious duplicate-module errors, even when the ancestor root is one that a file genuinely roots at (e.g. the build root . when a top-level scripts/ or tools/ package lives there). check now re-stages each source root's files into an isolated, non-nesting synthetic directory before invoking Pyrefly and passes --disable-search-path-heuristics, so every file is reachable under exactly one module identity regardless of how [source] root_patterns nest or how the dependency graph is shaped. This generalizes the 0.4.0 nearest-root dedup, which could only drop an ancestor root that no file needed — it could not fix a repo where first-party code roots at both an ancestor and a descendant (the common .-plus-src/python layout), leaving those errors to a baseline. Pyrefly's synthetic output paths are mapped back to real repo paths in diagnostics, the pants pyrefly-update-baseline file, and pants pyrefly-suppress edits.
  • pants pyrefly-update-baseline and pants pyrefly-suppress re-stage the same way, so a regenerated baseline no longer records the spurious errors and suppress no longer inserts # pyrefly: ignore comments for them.

pants-pyrefly 0.4.0

Choose a tag to compare

@tague tague released this 09 Nov 20:21
  • Nested/overlapping Pants source roots are now deduplicated before being passed to Pyrefly as --search-path (applies to check, the goals, and pants pyrefly-lsp-config). Previously, a repo with both src and src/python in [source] root_patterns made every module under the nested root reachable under two names (pkg.mod and python.pkg.mod), which Pyrefly reported as spurious duplicate-module / "not assignable to itself" errors. The plugin now emits only each file's nearest source root; a redundant ancestor root is dropped, and a genuine layout collision (first-party code living directly under both an ancestor and a nested root) is surfaced as a warning.
  • New advanced option [pyrefly].exclude_source_roots to force-drop specific source roots from the search path, for the rare case the automatic dedup should keep one but you don't want it.

pants-pyrefly 0.3.0

Choose a tag to compare

@tague tague released this 09 Nov 20:21
  • pants pyrefly-init bootstraps a Pyrefly config for the repo (wraps pyrefly init), migrating an existing MyPy or Pyright configuration when one is found. --pyrefly-init-migrate-from=<auto|mypy|pyright> selects the source. It refuses to overwrite an existing config.
  • pants pyrefly-dump-config prints the effective Pyrefly configuration Pants assembles for the targeted sources (first-party search-paths, the resolved interpreter, and the config file in effect) by running Pyrefly's dump-config subcommand. Diagnostic only — it does not type-check.
  • Pyrefly version pins (default_known_versions) are now generated by build-support/bin/generate_known_versions.py instead of being hand-edited: it fetches each asset's published .sha256 and size from the GitHub release. Bump with --version <new> --write; CI runs --check to fail if the committed pins drift from the release.

pants-pyrefly 0.2.0

Choose a tag to compare

@tague tague released this 09 Nov 20:21
  • pants pyrefly-suppress inserts inline # pyrefly: ignore comments for the current errors in the targeted sources (wraps Pyrefly's suppress); --pyrefly-suppress-remove-unused strips stale ones. The inline-comment alternative to the baseline for incremental adoption.
  • Lowered the published wheel's floor to Requires-Python: >=3.11 (was >=3.12), so one wheel installs into every supported Pants — 2.27 (CPython 3.11) through 2.32 (CPython 3.14) — and added per-version Python trove classifiers (3.11–3.14).
  • Added a MyPy→Pyrefly migration guide (docs/migrating-from-mypy.md).
  • CI now runs a consumption smoke-test matrix across Pants 2.27/2.31/2.32 (proving the version shim on every line), plus tests for lsp-config pyproject protection, [pyrefly].only, and the tool-failure exit path.

pants-pyrefly 0.1.0

Choose a tag to compare

@tague tague released this 09 Nov 20:21

Initial release.

  • Run Pyrefly (default 1.1.1) as a Python type checker in the Pants check goal.
  • Download the official prebuilt Pyrefly binary per platform (macOS arm64/x86_64, Linux arm64/x86_64 musl), pinned by SHA256.
  • First-party import resolution via --search-path, third-party resolution via a materialized requirements venv (--python-interpreter-path).
  • [pyrefly] subsystem options (skip, args, output_format, extra_type_stubs, config, config_discovery, version, …) and a per-target skip_pyrefly field. extra_type_stubs injects stub-only packages into the environment Pyrefly inspects; an explicit [pyrefly].config path is passed through to Pyrefly via --config.
  • The list of files to check is passed to Pyrefly via an argfile, so large targets never hit OS command-line length limits.
  • Incremental adoption: [pyrefly].baseline makes check report only errors new since the baseline, and the pants pyrefly-update-baseline goal records/refreshes that baseline file.
  • pants pyrefly-lsp-config writes Pants's source roots into pyrefly.toml as search-path, so the Pyrefly editor/LSP resolves first-party imports the way Pants does.
  • Triage controls [pyrefly].min_severity and [pyrefly].only; and check now flags a Pyrefly tool failure (an exit code other than 0/1) distinctly from ordinary type errors.
  • pants pyrefly-coverage reports overall type coverage (% of typable symbols typed), with an optional --pyrefly-coverage-fail-under threshold to ratchet/gate it.
  • Supports Pants 2.27–2.32 from a single codebase, via version-conditional imports for the rules-API change at 2.29 (coarsened_targets → resolve_coarsened_targets) and the CheckSubsystem.default_process_cache_scope addition at 2.32. Verified on 2.27 and 2.32.
  • The published wheel is pure-Python (Requires-Python: >=3.12) and carries no pantsbuild.pants dependency (Pants provides itself at runtime, and is no longer on PyPI). It installs into any Pants on CPython 3.12+ (Pants 2.27, on CPython 3.11, uses the from-source install). Verified end-to-end via a plugins=["… @ file://…whl"] install.