fix: Preserve existing config.toml entries that are not managed by this tool#39
fix: Preserve existing config.toml entries that are not managed by this tool#39lyinch wants to merge 3 commits intocolcon:mainfrom
Conversation
| with cargo_config_toml_out.open('r') as toml_file: | ||
| content = toml.load(toml_file) |
There was a problem hiding this comment.
Should we wrap this in a try except so the tool doesn't crash if the file being loaded is malformed?
|
The CI failure points out the formatting issues, mainly in the test file |
There was a problem hiding this comment.
Format this file with flake8. CI is failing on this test specifically
colcon-ros-cargo/test/test_flake8.py
Line 12 in dc26ba5
I think this answers your question in the description as well
I didn't use a code formatter for build.py as I couldn't find any guidelines or config for common tooling.
| def temp_workspace(tmp_path): | ||
| """Create a temporary workspace directory.""" | ||
| original_cwd = os.getcwd() | ||
| os.chdir(tmp_path) |
There was a problem hiding this comment.
This fixture expects a tmp_path variable, but the usage of it doesn't ever fill this value. I don't think this will run as os.chdir does expect a value
>>> import os
>>> os.chdir(None)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: chdir: path should be string, bytes, os.PathLike or integer, not NoneType
>>> os.chdir("")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
FileNotFoundError: [Errno 2] No such file or directory: ''
I am working in a cargo workspace and want to use rclrs in some of the packages. The current implementation however takes strong ownership of this, and in particular replaces existing
.cargo/config.tomlfiles. I have:after running this tool, it is replaced with:
This PR changes the behaviour of
write_cargo_config_toml()to keep existing entries that are not part of a[patch.crates-io]section, while replacing all of the existing[patch.crates-io]. Replacing (instead of appending) keeps the functionality identical with the current implementation.The PR additionally introduces unit tests for the specific function.
This PR can be reviewed commit-by-commit. The first commit adds a unit test to test the existing behaviour, the second commit introduces the change and modifies the unit test to verify the new behaviour.
Note: AI was used for this PR
I didn't use a code formatter for
build.pyas I couldn't find any guidelines or config for common tooling. Usingruffheavily modifies it so I raw-dogged it.