Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add explicit file encoding argument to open statements #38

Merged
merged 1 commit into from
Jun 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion poetry_lock_package/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ def create_or_update(project: Dict[str, Any], should_create_tests: bool) -> str:

# Create project toml
with open(
os.path.join(lock_project_path, "pyproject.toml"), "w"
os.path.join(lock_project_path, "pyproject.toml"), "w", encoding="utf-8"
) as requirements_toml:
toml.dump(project, requirements_toml)
return lock_project_path
Expand Down
4 changes: 2 additions & 2 deletions poetry_lock_package/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ def del_keys(dictionary: Dict[Any, Any], keys: List[str]) -> None:


def read_toml(filename: str) -> MutableMapping[str, Any]:
with open(filename, "r") as project_file:
with open(filename, "r", encoding="utf-8") as project_file:
return toml.load(project_file)


def create_and_write(path: str, contents: str) -> None:
if not os.path.exists(path):
os.makedirs(os.path.dirname(path), exist_ok=True)
with open(path, "w") as output_file:
with open(path, "w", encoding="utf-8") as output_file:
output_file.write(contents)


Expand Down
6 changes: 3 additions & 3 deletions tests/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def test_lock_package_name():


def test_collect_dependencies():
with open("tests/resources/example1.lock", "r") as lock_file:
with open("tests/resources/example1.lock", "r", encoding="utf-8") as lock_file:
lock_toml = toml.load(lock_file)
assert clean_dependencies(
collect_dependencies(lock_toml, ["atomicwrites"], always(True))
Expand All @@ -62,7 +62,7 @@ def test_collect_dependencies():


def test_lock_file_v2() -> None:
with open("tests/resources/poetry_v2.lock", "r") as lock_file:
with open("tests/resources/poetry_v2.lock", "r", encoding="utf-8") as lock_file:
lock_toml = toml.load(lock_file)
assert clean_dependencies(
collect_dependencies(lock_toml, ["arrow"], always(True))
Expand Down Expand Up @@ -116,7 +116,7 @@ def test_clean_dependencies_should_ignore_extra_via_dependency():

def test_issue_36_lock() -> None:
"""If the dependency information contains more markers for different versions, we incorrectly merge the configuration"""
with open("tests/resources/issue_36.lock", "r") as lock_file:
with open("tests/resources/issue_36.lock", "r", encoding="utf-8") as lock_file:
lock_toml = toml.load(lock_file)
collected_deps = collect_dependencies(
lock_toml, ["aioboto3", "docker", "requests"], always(True)
Expand Down
Loading