pyrefly icon indicating copy to clipboard operation
pyrefly copied to clipboard

Update write_pyproject to use toml_edit

Open pt2302 opened this issue 7 months ago • 4 comments

Description

This PR updates the write_pyproject to handle existing [tool.pyrefly] sections by allowing the project to be re-initialized. It also fixes a bug where newlines were not properly inserted, depending on the formatting of the existing pyproject.toml file.

Testing Instructions

Run pyrefly init in the following cases and confirm that the initialization looks correct:

  1. No pyproject.toml in the project.
  2. Existing pyproject.toml with no [tool.pyrefly] section.
  3. Existing pyproject.toml with an existing [tool.pyrefly] section.

pt2302 avatar May 22 '25 19:05 pt2302

@pt2302 Thanks so much for the diff! Tagging @MaggieMoss @connernilsen who have more experience with the init and config flows.

lolpack avatar May 22 '25 20:05 lolpack

@yangdanny97 has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

facebook-github-bot avatar May 27 '25 13:05 facebook-github-bot

@yangdanny97 I can't see the Facebook Internal linter warning (https://github.com/facebook/pyrefly/pull/336/checks?check_run_id=42963354645) but if you let me know what it is, I would be glad to address it.

pt2302 avatar May 27 '25 13:05 pt2302

@pt2302 Oh, your cargo changes didn't sync to our internal build tool. I'm not sure if there's a way to get it to work automatically, so we probably just have to go in and make that change when importing it.

Sorry for not checking this sooner, I was out for most of last week 😅

connernilsen avatar May 27 '25 23:05 connernilsen

@yangdanny97 has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

facebook-github-bot avatar Jun 05 '25 02:06 facebook-github-bot

Hey @pt2302, are your changes still in progress, or are you ready for review? Just want to check in to make sure I'm not delaying a review if you're ready. Feel free to also hit "Re-request review" on my name under Reviewers on this page when you're ready.

connernilsen avatar Jun 05 '25 21:06 connernilsen

@connernilsen Thanks! I believe that I've addressed your feedback and the PR is now ready for re-review. I've also updated the tests to reflect some of the other changes in functionality since I originally put up the PR, such as making the configs use kebab-case by default (3c7cd487cbdead4466d43f5816eba63eb8ccd546).

pt2302 avatar Jun 06 '25 14:06 pt2302

@yangdanny97 has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

facebook-github-bot avatar Jun 09 '25 15:06 facebook-github-bot

@connernilsen Thank you for the detailed review and comments! Do you handle merging?

pt2302 avatar Jun 09 '25 16:06 pt2302

Yep, we'll get this merged.

yangdanny97 avatar Jun 09 '25 20:06 yangdanny97

@yangdanny97 merged this pull request in facebook/pyrefly@0c304693e6a8cc0cb02dee7613544819d49305a8.

facebook-github-bot avatar Jun 10 '25 02:06 facebook-github-bot