Skip to content

Add pyrefly tool config section - #2431

Open
shengliangxu wants to merge 1 commit into
mainfrom
shengliangx/pyrefly-tool
Open

shengliangxu wants to merge 1 commit into
mainfrom
shengliangx/pyrefly-tool

Conversation

@shengliangxu

@shengliangxu shengliangxu commented Sep 14, 2026

Copy link
Copy Markdown
Collaborator

What does this PR do?

Type of change: Misc (developer tooling / editor config)

Adds the first [tool.pyrefly] configuration section to pyproject.toml. Specifically, the change enables pyrefly's fallback search path (enable-fallback-search-path = true) so that example scripts' sibling imports are resolved.

Example scripts import sibling helper modules as top-level modules — e.g. from example_utils import ... in examples/hf_ptq/hf_ptq.py, and cast_mxfp4_to_nvfp4. At runtime these resolve because Python puts the script's own directory on sys.path, but pyrefly infers the import root as the repo root and flags them as missing-import. Enabling the fallback search path makes pyrefly walk up from each importing file's directory to resolve imports the same way — fixing every example dir's sibling imports without enumerating each one in search-path (and with no cross-directory name collisions).

Config-only and inert for anyone without pyrefly: [tool.*] tables are namespaced, so other tools ignore it; the repo already disables even-better-toml schema validation, and the check-toml pre-commit hook validates syntax only.

Usage

Not an API change. With the pyrefly VS Code extension (or CLI), open examples/hf_ptq/hf_ptq.pyexample_utils now resolves instead of raising Cannot find module 'example_utils'.

Testing

  • pyrefly check examples/hf_ptq/hf_ptq.py with the auto-discovered config: missing-import errors for example_utils and cast_mxfp4_to_nvfp40.
  • pyrefly dump-config confirms the config is picked up and the fallback search path is active ([…/examples/hf_ptq, …/examples, …/main]).
  • Confirmed inert for non-pyrefly setups (namespaced [tool.*], even-better-toml schema disabled, check-toml = syntax-only).

Before your PR is "Ready for review"

  • Is this change backward compatible?: ✅
  • If you copied code from any other sources or added a new PIP dependency, did you follow guidance in CONTRIBUTING.md: N/A
  • Did you write any new necessary tests?: N/A (config-only, no runtime code)
  • Did you update Changelog?: N/A (developer tooling; not a user-facing feature/fix)
  • Did you get Claude approval on this PR?: N/A

Add a [tool.pyrefly] section enabling enable-fallback-search-path so
pyrefly (the VS Code extension / CLI) resolves example scripts' sibling
imports the way Python does at runtime (script dir on sys.path), e.g.
examples/hf_ptq/example_utils. Config-only, ignored by anyone without
pyrefly; no dependency or CI change.

Signed-off-by: Shengliang Xu <shengliangx@nvidia.com>
@shengliangxu
shengliangxu requested a review from a team as a code owner September 14, 2026 16:33
@coderabbitai

coderabbitai Bot commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: b25fbd7d-c03d-4514-bc59-51c02850c00e

📥 Commits

Reviewing files that changed from the base of the PR and between f70991f and 28429d7.

📒 Files selected for processing (1)
  • pyproject.toml

Included review availability: Your plan provides up to 12 included reviews per hour; 11 remain after this review.


📝 Walkthrough

Walkthrough

Changes

Pyrefly Import Resolution

Layer / File(s) Summary
Configure fallback search paths
pyproject.toml
Adds [tool.pyrefly] fallback search-path configuration for sibling-module imports in example directories.

Priority: ⬇️ Low

Estimated code review effort: 1 (Trivial) | ~5 minutes

Change: Other

Merge Risk: ⚪ Minimal · up to 28429

This configuration-only change has no identified merge-blocking risk.

🚥 Pre-merge checks | ✅ 6
✅ Passed checks (6 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Security Anti-Patterns ✅ Passed PASS. The reviewed range changes only pyproject.toml and adds a [tool.pyrefly] setting with comments. It adds no Python code, security-sensitive calls, # nosec comments, or dependency declaratio…
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: adding a pyrefly configuration section.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch shengliangx/pyrefly-tool

Comment @coderabbitai help to get the list of available commands.

@shengliangxu shengliangxu changed the title Add pyrefly config with fallback search path for example imports Add pyrefly tool config section Sep 14, 2026
@codecov

codecov Bot commented Sep 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.95%. Comparing base (700e188) to head (28429d7).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2431      +/-   ##
==========================================
+ Coverage   71.41%   78.95%   +7.54%     
==========================================
  Files         590      590              
  Lines       64692    64691       -1     
==========================================
+ Hits        46197    51075    +4878     
+ Misses      18495    13616    -4879     
Flag Coverage Δ
examples-diffusers 20.88% <ø> (ø)
examples-gpt-oss 13.40% <ø> (ø)
examples-hf_ptq 22.48% <ø> (-0.04%) ⬇️
examples-llm_distill 13.47% <ø> (-0.01%) ⬇️
examples-llm_eval 17.37% <ø> (ø)
examples-llm_qat 17.70% <ø> (-0.01%) ⬇️
examples-llm_sparsity 15.93% <ø> (ø)
examples-megatron_bridge 26.27% <ø> (-0.12%) ⬇️
examples-specdec_bench 13.15% <ø> (ø)
examples-speculative_decoding 17.78% <ø> (-0.07%) ⬇️
examples-torch_onnx 21.89% <ø> (ø)
examples-torch_trt 15.21% <ø> (ø)
gpu 58.33% <ø> (+25.92%) ⬆️
regression 15.16% <ø> (+0.28%) ⬆️
unit 57.80% <ø> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread pyproject.toml
"@(abc\\.)?abstractmethod",
]

[tool.pyrefly]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

do we need to also install the dependency in dev deps?

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