Fix TOML comment stripping in extend_list and remove_from_list#1591
Conversation
Use in-place append/remove on tomlkit Array objects instead of creating plain Python lists, which strips comments and formatting. Fixes #884 Agent-Logs-Url: https://github.com/usethis-python/usethis-python/sessions/032e12ce-4fc2-4e64-87e1-f3914b7fcf59 Co-authored-by: nathanjmcdougall <18602289+nathanjmcdougall@users.noreply.github.com>
Agent-Logs-Url: https://github.com/usethis-python/usethis-python/sessions/032e12ce-4fc2-4e64-87e1-f3914b7fcf59 Co-authored-by: nathanjmcdougall <18602289+nathanjmcdougall@users.noreply.github.com>
|
@copilot the |
… add_author The in-place Array modification in extend_list now preserves the tomlkit Array type. The add_author delete/re-set dance needs plain Python dicts to trigger tomlkit's format conversion to [[project.authors]]. Agent-Logs-Url: https://github.com/usethis-python/usethis-python/sessions/6a19efab-dd8b-4ba2-ae5e-1f9670293228 Co-authored-by: nathanjmcdougall <18602289+nathanjmcdougall@users.noreply.github.com>
Fixed in f00ffcb. The |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
@copilot the static checks are failing - you need to fix these |
…able alignment Agent-Logs-Url: https://github.com/usethis-python/usethis-python/sessions/109d7daa-f84f-425a-b82b-ebb5e8491acf Co-authored-by: nathanjmcdougall <18602289+nathanjmcdougall@users.noreply.github.com>
Fixed in 282b11a. Two issues:
|
extend_listandremove_from_listin_file/toml/io_.pyreplace tomlkitArrayobjects with plain Pythonlists, stripping comments and formattingextend_list: use in-placeinsert()instead ofd + list(values)to preserve tomlkit Array metadataremove_from_list: use in-placeremove()instead of list comprehension to preserve tomlkit Array metadataextend_listandremove_from_listusethis rule --ignore ERA001scenario with ruff.toml commentsadd_authorto unwrap tomlkit Array items to plain dicts for the delete/re-set dancetest_appendexpectation for cosmetic whitespace change (one fewer leading newline)Mappingisinstance check to narrow item type beforedict()conversion⚡ Quickly spin up Copilot coding agent tasks from anywhere on your macOS or Windows machine with Raycast.