Skip to content

ci: upgrade pyrefly to 1.4.0 and gate on a baseline file - #5298

Merged
terrykong merged 10 commits into
mainfrom
rnabel/pyrefly-baseline
Nov 21, 2026
Merged

terrykong merged 10 commits into
mainfrom
rnabel/pyrefly-baseline

Conversation

@RNabel

@RNabel RNabel commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do ?

Upgrades the pinned type checker from Pyrefly 0.24.2 to 1.4.0 and replaces the per-file allow-list with Pyrefly's baseline file, so every file is type-checked and only new errors fail.

Issues

Revives the approach of #3080 on current main, moved from 1.1.1 to 1.4.0. Follows #5296. Includes #5305 and #5306, which were merged into this branch.

Usage

# Fails only on errors that are not in pyrefly-baseline.json
uv run --group dev pyrefly check

# After fixing errors, drop their entries (never adds new ones)
uv run --group dev pyrefly check --prune-baseline

Before your PR is "Ready for review"

Pre checks:

  • Make sure you read and followed Contributor guidelines
  • Did you write any new necessary tests?
  • Did you run the unit tests and functional tests locally? Visit our Testing Guide for how to run tests
  • Did you add or update any necessary documentation? Visit our Document Development Guide for how to write, build and test the docs.

Additional Information

Why upgrade

  • 0.24.2 cannot narrow match class patterns, so match with assert_never is reported as an error. 1.4.0 handles it.
  • 0.24.2 reports false no-matching-overload errors on pydantic.Field(default=..., ge=...). 1.4.0 does not.
  • 1.4.0 is stricter: it reports 91 errors in files that are clean today (106 before refactor: fix type errors that pyrefly 1.4 reports in whitelisted files #5296). The baseline absorbs those, which is why the upgrade and the baseline land together.

Changes

  • pyproject.toml and uv.lock: pyrefly==1.4.0. The lock diff is the Pyrefly entry only.
  • pyrefly.toml: project-includes is five globs (nemo_rl, examples, docs, tools, and docker/*.py so that docker/prune_uv_cache.py, which is on today's allow-list, stays checked) and the explicit allow-list is gone. The globs also cover the 33 files directly under examples/, which the old CI step's git ls-files 'examples/**/*.py' never matched. baseline = "pyrefly-baseline.json" and baseline-matching-mode = "column-ordered" are set here.
  • pyrefly-baseline.json: the 1,460 existing errors across 132 files, written by pyrefly check --update-baseline as 1,306 rows, one per flagged source range. Entries match on path, error kind and column, not on line number or message. column-ordered also counts them, so a key that shows up more often than recorded is reported.
  • From ci: treat optional backend imports as Any in pyrefly #5305: eight optional packages that the lint environment does not install (modelopt, sglang, sglang_router, transformer_engine, nvidia_resiliency_ext, fla, sentence_transformers, myst_parser) are added to replace-imports-with-any, which removes their missing-import errors from the baseline.
  • From refactor(examples): build MasterConfig with model_validate #5306: the 13 example entry points build the top-level config with MasterConfig.model_validate(config) instead of MasterConfig(**config), which removes 114 errors from the baseline. Five test files are updated to match.
  • CI: the "Check if any files with zero errors not in whitelist" step is removed; nothing has to be registered any more.
  • Five suppression comments are renamed to the codes 1.4.0 uses (import-error to missing-import four times, typed-dict-key-error to bad-typed-dict-key once).
  • skills/: the contributor and reviewer notes that described the allow-list now describe the baseline. Reviewers are asked to flag new entries in pyrefly-baseline.json instead of files missing from project-includes.

The only runtime change is the MasterConfig.model_validate call in the example entry points.

Differences from #3080

  • 1.4.0 instead of 1.1.1.
  • The baseline is configured in pyrefly.toml, not passed as --baseline in the pre-commit hook, so a plain pyrefly check and editor integrations use it too. The hook entry is unchanged.

Please check

  • The baseline was generated on Linux aarch64; the Lint check runs on x86_64. The Lint check passed on x86_64 with the earlier baseline. The regenerated one counts entries, so a platform difference would now show up as a Lint failure; if it does, I will regenerate it from the job's output.
  • Matching ignores line numbers and messages. Fixing one baselined error and adding a new one of the same kind at the same column in the same file nets out and is not reported.
  • No ratchet. Fixing an error leaves a stale entry until someone prunes. --error-stale-baseline in the hook would enforce pruning; I left it out to avoid baseline conflicts between PRs.
  • 14 ignore[implicitly-defined-attribute] comments no longer suppress anything, because 1.4.0 does not report that kind. They are left in place to keep this diff small.

Testing

Run in a Linux container with the locked environment, CPU only:

  • pre-commit run --all-files: every hook passes, including pyrefly check at 1.4.0.
  • A deliberately added bad-argument-type error in nemo_rl/algorithms/grpo.py, at a column where the file already has a baselined error of that kind, is reported with column-ordered and hidden in the default mode. --error-stale-baseline on the fresh baseline reports nothing.
  • Loss, config, GRPO/PPO and single-controller setup suites: 1501 passed, 95 skipped.
  • No new tests: the change is tooling, comments and the model_validate call, which the existing entry-point tests cover. GPU and functional tests were not run locally.

🤖 Generated with Claude Code

@copy-pr-bot

copy-pr-bot Bot commented Nov 18, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@github-actions github-actions Bot added the CI Relating to CI label Nov 18, 2026
@RNabel
RNabel requested review from terrykong and yuki-97 November 18, 2026 23:07
@RNabel
RNabel force-pushed the rnabel/pyrefly-prep-fixes branch from 93db711 to 684dd48 Compare November 19, 2026 09:48
@RNabel
RNabel force-pushed the rnabel/pyrefly-baseline branch from eb7b20b to ca79589 Compare November 19, 2026 09:48
@RNabel

RNabel commented Nov 19, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test ca79589

@RNabel RNabel added CI:Lfast Runs a fast test suite and re-use nightly `main` container (but sync dependencies to PRs version) CI:L1 Run doctests, unit tests, and functional tests and removed CI:Lfast Runs a fast test suite and re-use nightly `main` container (but sync dependencies to PRs version) labels Nov 19, 2026
@RNabel

RNabel commented Nov 19, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test ca79589

@svcnvidia-nemo-ci svcnvidia-nemo-ci 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.

One validation regression needs fixing: (C1) the new Pyrefly root list drops the previously checked Docker cache-pruning script.

I inspected all 13 changed files and the affected hook and CI paths. One parallel report was unavailable, so I covered its suppression and documentation changes directly.

This was a static review. I did not run lint, Pyrefly or tests, and CI results were not supplied. Baseline compatibility between aarch64 and x86_64 is unverified.

Generated by Codex

Note: formal approval is not available for this request, so this review is posted as a comment only.

Review generated by codex. This was a full review. Request a full review with /review reset=true.

Comment thread pyrefly.toml Resolved
@RNabel

RNabel commented Nov 19, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test cb1ae0f

@nemo-automation-bot
nemo-automation-bot Bot requested a review from a team November 19, 2026 10:43
Base automatically changed from rnabel/pyrefly-prep-fixes to main November 19, 2026 15:25
@RNabel

RNabel commented Nov 19, 2026

Copy link
Copy Markdown
Contributor Author

/review reset=true

@svcnvidia-nemo-ci svcnvidia-nemo-ci 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.

LGTM. I found no qualifying findings after reviewing all 24 changed files and their directly affected paths with three parallel reviewers.

The previous Docker coverage finding is fixed. The current root list includes docker/*.py, covering the cache-pruning script.

This was a static review. I did not run lint, Pyrefly or tests, and CI results were not supplied. Diagnostic matching on x86_64 for the aarch64-generated baseline is still unverified.

Generated by Codex

Review generated by codex. This was a full review. Request a full review with /review reset=true.

@RNabel

RNabel commented Nov 19, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 741a817

@RNabel
RNabel force-pushed the rnabel/pyrefly-baseline branch from 741a817 to a48fc3a Compare November 19, 2026 19:30
@RNabel

RNabel commented Nov 19, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test a48fc3a

RNabel and others added 3 commits November 20, 2026 10:18
Pin pyrefly 1.4.0 and replace the per-file allow-list in pyrefly.toml, and
the CI step that kept it complete, with pyrefly's baseline file. Every file
under nemo_rl, examples, docs and tools is now checked, and the check fails
only on errors that are not recorded in pyrefly-baseline.json.

The baseline holds the 1,610 errors that exist today. Five suppression
comments are renamed to the error codes 1.4.0 uses. This revives the
approach of #3080 on current main.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Signed-off-by: Robin Nabel <[email protected]>
The allow-list on main includes docker/prune_uv_cache.py, which none of the
four globs match, so the file would have dropped out of type checking. Add
docker/*.py to project-includes. The file is clean under pyrefly 1.4.0, so
the baseline is unchanged.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Signed-off-by: Robin Nabel <[email protected]>
Signed-off-by: Robin Nabel <[email protected]>
Co-authored-by: Claude Fable 5.2 <[email protected]>
@RNabel
RNabel force-pushed the rnabel/pyrefly-baseline branch from 6e805bc to 13d40e8 Compare November 20, 2026 08:23
RNabel and others added 3 commits November 20, 2026 11:49
Pyrefly's default baseline mode matches on path, error kind and column
only, so one recorded entry hid every new error of that kind at that
column in the file. "column-ordered" also counts the entries, and a key
that shows up more often than recorded is reported.

Regenerate pyrefly-baseline.json in this mode. It now holds one row per
flagged source range: 1,303 rows for the same 1,457 errors.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Signed-off-by: Robin Nabel <[email protected]>
…utor notes

The review skill still asked reviewers to flag new files missing from
project-includes, which no longer exists as an allow-list. It now asks
them to flag new entries in pyrefly-baseline.json. The note about the
removed CI step is in the past tense, and the contributor note lists
docker/*.py among the checked paths.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Signed-off-by: Robin Nabel <[email protected]>
@RNabel

RNabel commented Nov 20, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 8aa1cdd

@nemo-automation-bot
nemo-automation-bot Bot requested a review from a team November 20, 2026 09:54
terrykong
terrykong previously approved these changes Nov 20, 2026
@terrykong
terrykong enabled auto-merge (squash) November 20, 2026 10:09
RNabel and others added 2 commits November 20, 2026 19:30
Three changes merged to main after the baseline was written add one error
each that Pyrefly 1.4.0 reports: an index on a possibly-None value in
grpo_sync.py, a possibly-unbound name in rollout_checkpointing/restore.py,
and an index on object in megatron_policy_worker.py. Record them so the
gate starts from main's current state.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Signed-off-by: Robin Nabel <[email protected]>
@RNabel

RNabel commented Nov 20, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test a061c0e

@nemo-automation-bot
nemo-automation-bot Bot requested a review from a team November 20, 2026 17:44
terrykong
terrykong previously approved these changes Nov 20, 2026
@terrykong
terrykong enabled auto-merge (squash) November 20, 2026 18:09
@terrykong

Copy link
Copy Markdown
Collaborator

/resolve-conflict

Conflict in pyrefly.toml: main added a file to the old whitelist; the
glob in project-includes already covers it.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Signed-off-by: Robin Nabel <[email protected]>
@terrykong

Copy link
Copy Markdown
Collaborator

/ok to test 8d17dd0

@nemo-automation-bot
nemo-automation-bot Bot requested a review from a team November 20, 2026 19:56
@RNabel RNabel added CI:Lfast Runs a fast test suite and re-use nightly `main` container (but sync dependencies to PRs version) and removed CI:L1 Run doctests, unit tests, and functional tests labels Nov 20, 2026
@terrykong
terrykong merged commit 5ce8092 into main Nov 21, 2026
130 of 156 checks passed
@terrykong
terrykong deleted the rnabel/pyrefly-baseline branch November 21, 2026 01:22
zyzhou5 added a commit to zyzhou5/RL that referenced this pull request Nov 23, 2026
…ting

Resolve one conflict with NVIDIA-NeMo#5298 in pyrefly.toml: take main's globbed
project-includes, which cover nemo_gym_multi_harness.py.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Zeyu Zhou <[email protected]>
sharonyu-115 added a commit to sharonyu-115/RL that referenced this pull request Nov 26, 2026
…ig for pyrefly

Main now gates lint on pyrefly 1.4.0 with a baseline (NVIDIA-NeMo#5298), and the
full-batch train path tripped two new errors: automodel_cfg is a union with
the disabled variant, so .get() returned object and could not be used in a
modulo against the typed microbatch index; and get_microbatch_iterator takes
dict[str, Any], which PolicyConfig is not. Cast to AutomodelConfig, which
the full-batch path already requires, and cast the policy config at the
call like the existing generation-config precedent in this file.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Signed-off-by: Shuang Yu <[email protected]>
sharonyu-115 added a commit to sharonyu-115/RL that referenced this pull request Nov 27, 2026
…ig for pyrefly

Main now gates lint on pyrefly 1.4.0 with a baseline (NVIDIA-NeMo#5298), and the
full-batch train path tripped two new errors: automodel_cfg is a union with
the disabled variant, so .get() returned object and could not be used in a
modulo against the typed microbatch index; and get_microbatch_iterator takes
dict[str, Any], which PolicyConfig is not. Cast to AutomodelConfig, which
the full-batch path already requires, and cast the policy config at the
call like the existing generation-config precedent in this file.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Signed-off-by: Shuang Yu <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CI:Lfast Runs a fast test suite and re-use nightly `main` container (but sync dependencies to PRs version) CI Relating to CI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants