Skip to content

Commit

Permalink
Fix: tomli-w require binary mode
Browse files Browse the repository at this point in the history
  • Loading branch information
WangGithubUser committed Jan 12, 2025
1 parent 341a555 commit 97a946a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
9 changes: 5 additions & 4 deletions client/commands/initialize.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,12 +266,13 @@ def get_configuration_and_path(
def write_configuration(
configuration: Dict[str, Any], configuration_path: Path
) -> None:
with open(configuration_path, "wb+") as configuration_file:
if configuration_path.suffix.lower() == ".toml":
if configuration_path.suffix.lower() == ".toml":
with open(configuration_path, "wb+") as configuration_file:
configuration = {"tool": {"pyre": configuration}} # [tool.pyre] section
tomli_w.dump(configuration, configuration_file)
else:
# assume to JSON
else:
# assume to JSON
with open(configuration_path, "w+") as configuration_file:
json.dump(configuration, configuration_file, sort_keys=True, indent=2)
configuration_file.write("\n")

Expand Down
5 changes: 4 additions & 1 deletion client/configuration/tests/configuration_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1216,7 +1216,10 @@ def test_write_to_pyproject_dot_toml(self) -> None:
self.assertEqual(
configuration_file.read(),
"""[tool.pyre]
exclude = ["sample/exclude1", "sample/exclude2"]
excludes = [
"sample/exclude1",
"sample/exclude2",
]
strict = true
""",
)

0 comments on commit 97a946a

Please sign in to comment.