Thanks to visit codestin.com
Credit goes to github.com

Skip to content
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
6 changes: 3 additions & 3 deletions semantic_release/history/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def __init__(self, path, key):
self.key = key

def _read(self) -> Dotty:
toml_doc = tomlkit.loads(self.path.read_text())
toml_doc = tomlkit.loads(self.path.read_text(encoding="utf-8"))
return Dotty(toml_doc)

def parse(self) -> Set[str]:
Expand Down Expand Up @@ -157,7 +157,7 @@ def parse(self) -> Set[str]:
should be the same version in each place), but it falls on the caller
to check for this condition.
"""
content = self.path.read_text()
content = self.path.read_text(encoding="utf-8")

versions = {
m.group(1) for m in re.finditer(self.pattern, content, re.MULTILINE)
Expand All @@ -178,7 +178,7 @@ def replace(self, new_version: str):
:param new_version: The new version number as a string
"""
n = 0
old_content = self.path.read_text()
old_content = self.path.read_text(encoding="utf-8")

def swap_version(m):
nonlocal n
Expand Down
4 changes: 2 additions & 2 deletions semantic_release/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def _config():

def _config_from_ini(paths):
parser = configparser.ConfigParser()
parser.read(paths)
parser.read(paths, encoding="utf-8")

flags = {
"changelog_capitalize",
Expand Down Expand Up @@ -69,7 +69,7 @@ def _config_from_ini(paths):
def _config_from_pyproject(path):
if os.path.isfile(path):
try:
with open(path, "r") as f:
with open(path, "r", encoding="utf-8") as f:
pyproject = tomlkit.loads(f.read())
if pyproject:
return pyproject.get("tool", {}).get("semantic_release", {})
Expand Down
4 changes: 2 additions & 2 deletions semantic_release/vcs_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,11 +182,11 @@ def update_changelog_file(version: str, content_to_add: str):
changelog_file = config.get("changelog_file")
changelog_placeholder = config.get("changelog_placeholder")
git_path = Path(os.getcwd(), changelog_file)
if not git_path.exists() or git_path.read_text().strip() == "":
if not git_path.exists() or git_path.read_text(encoding="utf-8").strip() == "":
original_content = f"# Changelog\n\n{changelog_placeholder}\n"
logger.warning(f"Changelog file not found: {git_path} - creating it.")
else:
original_content = git_path.read_text()
original_content = git_path.read_text(encoding="utf-8")
if (
changelog_placeholder not in original_content
and "# Changelog" in original_content
Expand Down
2 changes: 1 addition & 1 deletion tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -1230,7 +1230,7 @@ def test_overload_by_cli(mocker, runner):
],
)

mock_read_text.assert_called_once_with()
mock_read_text.assert_called_once_with(encoding="utf-8")
mock_read_text.reset_mock()


Expand Down