Skip to content

Commit f864db3

Browse files
authored
Merge branch 'master' into fix/mypy-index-error
2 parents faf8a6d + dd972c9 commit f864db3

29 files changed

+447
-280
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ repos:
5656
- tomli
5757

5858
- repo: https://github.com/commitizen-tools/commitizen
59-
rev: v4.13.6 # automatically updated by Commitizen
59+
rev: v4.13.7 # automatically updated by Commitizen
6060
hooks:
6161
- id: commitizen
6262
- id: commitizen-branch

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## v4.13.7 (2026-02-09)
2+
3+
### Fix
4+
5+
- **provider**: use encoding settings in config (#1857)
6+
17
## v4.13.6 (2026-02-07)
28

39
### Fix

commitizen/__version__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "4.13.6"
1+
__version__ = "4.13.7"

commitizen/commands/check.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import re
44
import sys
5+
from pathlib import Path
56
from typing import TYPE_CHECKING, TypedDict
67

78
from commitizen import factory, git, out
@@ -116,11 +117,10 @@ def _get_commit_message(self) -> str | None:
116117
# Get commit message from command line (--message)
117118
return self.commit_msg
118119

119-
with open(
120-
self.commit_msg_file, encoding=self.config.settings["encoding"]
121-
) as commit_file:
122-
# Get commit message from file (--commit-msg-file)
123-
return commit_file.read()
120+
# Get commit message from file (--commit-msg-file)
121+
return Path(self.commit_msg_file).read_text(
122+
encoding=self.config.settings["encoding"]
123+
)
124124

125125
def _get_commits(self) -> list[git.GitCommit]:
126126
if (msg := self._get_commit_message()) is not None:

commitizen/commands/commit.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import shutil
66
import subprocess
77
import tempfile
8+
from pathlib import Path
89
from typing import TYPE_CHECKING, TypedDict
910

1011
import questionary
@@ -26,8 +27,6 @@
2627
from commitizen.git import smart_open
2728

2829
if TYPE_CHECKING:
29-
from pathlib import Path
30-
3130
from commitizen.config import BaseConfig
3231

3332

@@ -61,8 +60,9 @@ def _read_backup_message(self) -> str | None:
6160
return None
6261

6362
# Read commit message from backup
64-
with self.backup_file_path.open(encoding=self.config.settings["encoding"]) as f:
65-
return f.read().strip()
63+
return self.backup_file_path.read_text(
64+
encoding=self.config.settings["encoding"]
65+
).strip()
6666

6767
def _get_message_by_prompt_commit_questions(self) -> str:
6868
# Prompt user for the commit message
@@ -112,8 +112,7 @@ def manual_edit(self, message: str) -> str:
112112
file_path = file.name
113113
argv = [exec_path, file_path]
114114
subprocess.call(argv)
115-
with open(file_path) as temp_file:
116-
message = temp_file.read().strip()
115+
message = Path(file_path).read_text().strip()
117116
os.unlink(file.name)
118117
return message
119118

commitizen/config/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@ def _resolve_config_candidates() -> list[BaseConfig]:
2828

2929

3030
def _create_config_from_path(path: Path) -> BaseConfig:
31-
with path.open("rb") as f:
32-
return create_config(data=f.read(), path=path)
31+
return create_config(data=path.read_bytes(), path=path)
3332

3433

3534
def read_cfg(filepath: str | None = None) -> BaseConfig:

commitizen/config/toml_config.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,13 @@ def __init__(self, *, data: bytes | str, path: Path) -> None:
2626
self._parse_setting(data)
2727

2828
def contains_commitizen_section(self) -> bool:
29-
with self.path.open("rb") as f:
30-
config_doc = parse(f.read())
29+
config_doc = parse(self.path.read_bytes())
3130
return config_doc.get("tool", {}).get("commitizen") is not None
3231

3332
def init_empty_config_content(self) -> None:
3433
config_doc = TOMLDocument()
3534
if self.path.is_file():
36-
with self.path.open("rb") as input_toml_file:
37-
config_doc = parse(input_toml_file.read())
35+
config_doc = parse(self.path.read_bytes())
3836

3937
if config_doc.get("tool") is None:
4038
config_doc["tool"] = table()
@@ -46,12 +44,10 @@ def init_empty_config_content(self) -> None:
4644
)
4745

4846
def set_key(self, key: str, value: object) -> Self:
49-
with self.path.open("rb") as f:
50-
config_doc = parse(f.read())
47+
config_doc = parse(self.path.read_bytes())
5148

5249
config_doc["tool"]["commitizen"][key] = value # type: ignore[index]
53-
with self.path.open("wb") as f:
54-
f.write(config_doc.as_string().encode(self._settings["encoding"]))
50+
self.path.write_bytes(config_doc.as_string().encode(self._settings["encoding"]))
5551

5652
return self
5753

commitizen/cz/conventional_commits/conventional_commits.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,5 +215,4 @@ def schema_pattern(self) -> str:
215215

216216
def info(self) -> str:
217217
filepath = Path(__file__).parent / "conventional_commits_info.txt"
218-
with filepath.open(encoding=self.config.settings["encoding"]) as f:
219-
return f.read()
218+
return filepath.read_text(encoding=self.config.settings["encoding"])

commitizen/cz/customize/customize.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from __future__ import annotations
22

3+
from pathlib import Path
34
from typing import TYPE_CHECKING, Any
45

56
if TYPE_CHECKING:
@@ -68,6 +69,5 @@ def schema(self) -> str:
6869

6970
def info(self) -> str:
7071
if info_path := self.custom_settings.get("info_path"):
71-
with open(info_path, encoding=self.config.settings["encoding"]) as f:
72-
return f.read()
72+
return Path(info_path).read_text(encoding=self.config.settings["encoding"])
7373
return self.custom_settings.get("info") or ""

commitizen/cz/jira/jira.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,5 +74,4 @@ def schema_pattern(self) -> str:
7474

7575
def info(self) -> str:
7676
filepath = Path(__file__).parent / "jira_info.txt"
77-
with filepath.open(encoding=self.config.settings["encoding"]) as f:
78-
return f.read()
77+
return filepath.read_text(encoding=self.config.settings["encoding"])

0 commit comments

Comments
 (0)