Skip to content

Commit

Permalink
fix: Poetry 1.5 TOML parsing issues in windows (#31)
Browse files Browse the repository at this point in the history
* fix: open files with explicit utf-8

* fix: open file for write with newline set to '', for no translation.

* bump version to 1.2.2
  • Loading branch information
DavidVujic committed May 22, 2023
1 parent 23ba589 commit c779426
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions poetry_multiproject_plugin/components/parsing/rewrite.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@ def mutate_imports(node: ast.AST, namespaces: List[str], top_ns: str) -> bool:
def rewrite_module(path: pathlib.Path, namespaces: List[str], top_ns: str) -> bool:
file_path = path.as_posix()

with open(file_path, "r") as f:
with open(file_path, "r", encoding="utf-8") as f:
tree = ast.parse(f.read(), path.name)

res = {mutate_imports(node, namespaces, top_ns) for node in ast.walk(tree)}

if True in res:
rewritten_source_code = ast.unparse(tree) # type: ignore[attr-defined]

with open(file_path, "w") as f:
with open(file_path, "w", encoding="utf-8", newline="") as f:
f.write(rewritten_source_code)

return True
Expand Down
2 changes: 1 addition & 1 deletion poetry_multiproject_plugin/components/project/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def create_new_project_file(

destination = Path(destination / project_file.name)

with open(destination.as_posix(), "w") as f:
with open(destination.as_posix(), "w", encoding="utf-8", newline="") as f:
f.write(generated)

return destination
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "poetry-multiproject-plugin"
version = "1.2.1"
version = "1.2.2"
description = "A Poetry plugin that makes it possible to use relative package includes."
authors = ["David Vujic"]
homepage = "https://github.com/davidvujic/poetry-multiproject-plugin"
Expand Down

0 comments on commit c779426

Please sign in to comment.