-
-
Notifications
You must be signed in to change notification settings - Fork 32
Closed
Description
Describe the bug
Setting top-namespace in [tool.polylith.build] of pyproject.toml discards single-line comments or whitespaces while rewriting the source files
To Reproduce
Steps to reproduce the behavior:
- Open
python-polylith-example-uv:
https://github.com/DavidVujic/python-polylith-example-uv/blob/main/projects/consumer_project/pyproject.toml#L25 - Run
uv build --sdist projects/consumer_project/ && tar -xzvf dist/consumer_project-0.1.0.tar.gz -C stripped - Comment on
top-namespace = "my_custom_ns"in theprojects/consumer_project/pyproject.toml - (Optional) Add single-line comments starting with
#or trivial whitespaces tocomponents/example/kafka/consumer.py - Run
uv build --sdist projects/consumer_project/ && tar -xzvf dist/consumer_project-0.1.0.tar.gz -C preserved - See the difference between
stripped/consumer_project-0.1.0/my_custom_ns/example/kafka/consumer.pyandpreserved/consumer_project-0.1.0/example/kafka/consumer.py
Expected behavior
It should make no difference in source files other than prepending the new top-namespace to the previous single top-namespace in the import lines.
Desktop (please complete the following information):
- OS: Ubuntu 24.04.2 LTS
- Python version: cpython-3.12.11-linux-x86_64-gnu
- uv version: 0.7.12
Additional context
- https://github.com/DavidVujic/python-polylith-docs/blob/c05923d459a46698c534484259787f363a436bdc/docs/deployment.md?plain=1#L140-L142
def rewrite_modules(path: Path, ns: str, top_ns: str) -> List[str]: - Replacing ast with Instagram/LibCST could be helpful.
Metadata
Metadata
Assignees
Labels
No labels