Add pyrefly tool config section - #2431
shengliangxu wants to merge 1 commit into
Conversation
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>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 12 included reviews per hour; 11 remain after this review. 📝 WalkthroughWalkthroughChangesPyrefly Import Resolution
Priority: ⬇️ Low Estimated code review effort: 1 (Trivial) | ~5 minutes Change: Other Merge Risk: ⚪ Minimal · up to This configuration-only change has no identified merge-blocking risk. 🚥 Pre-merge checks | ✅ 6✅ Passed checks (6 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. 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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
| "@(abc\\.)?abstractmethod", | ||
| ] | ||
|
|
||
| [tool.pyrefly] |
There was a problem hiding this comment.
do we need to also install the dependency in dev deps?
What does this PR do?
Type of change: Misc (developer tooling / editor config)
Adds the first
[tool.pyrefly]configuration section topyproject.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 ...inexamples/hf_ptq/hf_ptq.py, andcast_mxfp4_to_nvfp4. At runtime these resolve because Python puts the script's own directory onsys.path, but pyrefly infers the import root as the repo root and flags them asmissing-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 insearch-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 thecheck-tomlpre-commit hook validates syntax only.Usage
Not an API change. With the pyrefly VS Code extension (or CLI), open
examples/hf_ptq/hf_ptq.py—example_utilsnow resolves instead of raisingCannot find module 'example_utils'.Testing
pyrefly check examples/hf_ptq/hf_ptq.pywith the auto-discovered config:missing-importerrors forexample_utilsandcast_mxfp4_to_nvfp4→ 0.pyrefly dump-configconfirms the config is picked up and the fallback search path is active ([…/examples/hf_ptq, …/examples, …/main]).[tool.*], even-better-toml schema disabled,check-toml= syntax-only).Before your PR is "Ready for review"
CONTRIBUTING.md: N/A