Skip to content

Commit 3051965

Browse files
committed
refactor(BaseConfig): rename function
1 parent 22835e3 commit 3051965

File tree

4 files changed

+21
-4
lines changed

4 files changed

+21
-4
lines changed

commitizen/config/base_config.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,29 @@ class BaseConfig:
99
def __init__(self):
1010
self._settings: Settings = DEFAULT_SETTINGS.copy()
1111
self.encoding = self.settings["encoding"]
12-
self.path: Path | None = None
12+
self._path: Path | None = None
1313

1414
@property
1515
def settings(self) -> Settings:
1616
return self._settings
1717

18+
@property
19+
def path(self) -> Path | None:
20+
return self._path
21+
22+
"""
23+
mypy does not like the following until 1.16
24+
See https://github.com/python/mypy/pull/18510
25+
TODO: update this when 1.16 is available
26+
27+
@path.setter
28+
def path(self, path: str | Path) -> None:
29+
self._path = Path(path)
30+
"""
31+
32+
def update_path(self, path: str | Path) -> None:
33+
self._path = Path(path)
34+
1835
def set_key(self, key, value):
1936
"""Set or update a key in the conf.
2037

commitizen/config/json_config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class JsonConfig(BaseConfig):
1313
def __init__(self, *, data: bytes | str, path: Path | str):
1414
super().__init__()
1515
self.is_empty_config = False
16-
self.path = Path(path)
16+
self.update_path(path)
1717
self._parse_setting(data)
1818

1919
def init_empty_config_content(self):

commitizen/config/toml_config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class TomlConfig(BaseConfig):
1414
def __init__(self, *, data: bytes | str, path: Path | str):
1515
super().__init__()
1616
self.is_empty_config = False
17-
self.path = Path(path)
17+
self.update_path(path)
1818
self._parse_setting(data)
1919

2020
def init_empty_config_content(self):

commitizen/config/yaml_config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class YAMLConfig(BaseConfig):
1414
def __init__(self, *, data: bytes | str, path: Path | str):
1515
super().__init__()
1616
self.is_empty_config = False
17-
self.path = Path(path)
17+
self.update_path(path)
1818
self._parse_setting(data)
1919

2020
def init_empty_config_content(self):

0 commit comments

Comments
 (0)