Fix config migration to check section presence not parse success (#4234)#4234
Closed
anushamukka-dev wants to merge 1 commit into
Closed
Fix config migration to check section presence not parse success (#4234)#4234anushamukka-dev wants to merge 1 commit into
anushamukka-dev wants to merge 1 commit into
Conversation
Contributor
|
@anushamukka-dev has exported this pull request. If you are a Meta employee, you can view the originating Diff in D111620497. |
kinto0
approved these changes
Jul 21, 2026
kinto0
left a comment
Contributor
There was a problem hiding this comment.
Review automatically exported from Phabricator review in Meta.
anushamukka-dev
added a commit
to anushamukka-dev/pyrefly
that referenced
this pull request
Jul 22, 2026
…ebook#4234) Summary: When migrating a `pyproject.toml` with `MigrationSource::Auto`, the code ran `try_mypy().or_else(|_| try_pyright())`. That falls back to pyright on *any* mypy parse failure, not just "section missing" — so a present-but-malformed `[tool.mypy]` (bad value types, etc.) silently became a pyright migration whenever both sections were present, hiding the mypy error the user actually needs to fix. This decides which tool to migrate based on section *presence* rather than parse *success*. A new `has_toml_section` helper does lightweight TOML table-header detection (independent of section validity). Both `Args::load_from_pyproject` (used by `pyrefly init`) and the in-memory `find_and_migrate_in_memory` loader now use it: when `[tool.mypy]` is present we attempt mypy and surface its error; only when mypy is absent and `[tool.pyright]` is present do we migrate pyright; the both-absent case preserves prior behavior. This also removes the now-resolved TODO and the ad-hoc post-hoc error-precedence logic in the in-memory loader, which is subsumed by presence-based selection. Reviewed By: kinto0 Differential Revision: D111620497
anushamukka-dev
force-pushed
the
export-D111620497
branch
from
July 22, 2026 16:50
c4ecb96 to
458207f
Compare
anushamukka-dev
added a commit
to anushamukka-dev/pyrefly
that referenced
this pull request
Jul 23, 2026
…ebook#4234) Summary: When migrating a `pyproject.toml` with `MigrationSource::Auto`, the code ran `try_mypy().or_else(|_| try_pyright())`. That falls back to pyright on *any* mypy parse failure, not just "section missing" — so a present-but-malformed `[tool.mypy]` (bad value types, etc.) silently became a pyright migration whenever both sections were present, hiding the mypy error the user actually needs to fix. This decides which tool to migrate based on section *presence* rather than parse *success*. A new `has_toml_section` helper does lightweight TOML table-header detection (independent of section validity). Both `Args::load_from_pyproject` (used by `pyrefly init`) and the in-memory `find_and_migrate_in_memory` loader now use it: when `[tool.mypy]` is present we attempt mypy and surface its error; only when mypy is absent and `[tool.pyright]` is present do we migrate pyright; the both-absent case preserves prior behavior. This also removes the now-resolved TODO and the ad-hoc post-hoc error-precedence logic in the in-memory loader, which is subsumed by presence-based selection. Reviewed By: kinto0 Differential Revision: D111620497
anushamukka-dev
force-pushed
the
export-D111620497
branch
from
July 23, 2026 14:45
458207f to
09b3768
Compare
…ebook#4234) Summary: When migrating a `pyproject.toml` with `MigrationSource::Auto`, the code ran `try_mypy().or_else(|_| try_pyright())`. That falls back to pyright on *any* mypy parse failure, not just "section missing" — so a present-but-malformed `[tool.mypy]` (bad value types, etc.) silently became a pyright migration whenever both sections were present, hiding the mypy error the user actually needs to fix. This decides which tool to migrate based on section *presence* rather than parse *success*. A new `has_toml_section` helper does lightweight TOML table-header detection (independent of section validity). Both `Args::load_from_pyproject` (used by `pyrefly init`) and the in-memory `find_and_migrate_in_memory` loader now use it: when `[tool.mypy]` is present we attempt mypy and surface its error; only when mypy is absent and `[tool.pyright]` is present do we migrate pyright; the both-absent case preserves prior behavior. This also removes the now-resolved TODO and the ad-hoc post-hoc error-precedence logic in the in-memory loader, which is subsumed by presence-based selection. Reviewed By: kinto0 Differential Revision: D111620497
anushamukka-dev
force-pushed
the
export-D111620497
branch
from
July 23, 2026 14:46
09b3768 to
3874f96
Compare
Contributor
|
This pull request has been merged in fd3e282. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary:
When migrating a
pyproject.tomlwithMigrationSource::Auto, the code rantry_mypy().or_else(|_| try_pyright()). That falls back to pyright on any mypy parse failure, not just "section missing" — so a present-but-malformed[tool.mypy](bad value types, etc.) silently became a pyright migration whenever both sections were present, hiding the mypy error the user actually needs to fix.This decides which tool to migrate based on section presence rather than parse success. A new
has_toml_sectionhelper does lightweight TOML table-header detection (independent of section validity). BothArgs::load_from_pyproject(used bypyrefly init) and the in-memoryfind_and_migrate_in_memoryloader now use it: when[tool.mypy]is present we attempt mypy and surface its error; only when mypy is absent and[tool.pyright]is present do we migrate pyright; the both-absent case preserves prior behavior.This also removes the now-resolved TODO and the ad-hoc post-hoc error-precedence logic in the in-memory loader, which is subsumed by presence-based selection.
Reviewed By: kinto0
Differential Revision: D111620497