Skip to content

Commit 614aae3

Browse files
committed
refactor(BaseConfig): remove path property
1 parent e3b4465 commit 614aae3

File tree

5 files changed

+6
-12
lines changed

5 files changed

+6
-12
lines changed

commitizen/config/base_config.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,12 @@ 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-
2218
def set_key(self, key, value):
2319
"""Set or update a key in the conf.
2420
@@ -30,8 +26,5 @@ def set_key(self, key, value):
3026
def update(self, data: Settings) -> None:
3127
self._settings.update(data)
3228

33-
def add_path(self, path: str | Path) -> None:
34-
self._path = Path(path)
35-
3629
def _parse_setting(self, data: bytes | str) -> None:
3730
raise NotImplementedError()

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.add_path(path)
16+
self.path = 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.add_path(path)
17+
self.path = 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.add_path(path)
17+
self.path = Path(path)
1818
self._parse_setting(data)
1919

2020
def init_empty_config_content(self):

tests/commands/test_init_command.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import json
44
import os
55
import sys
6+
from pathlib import Path
67
from typing import Any
78

89
import pytest
@@ -86,7 +87,7 @@ def test_init_without_setup_pre_commit_hook(tmpdir, mocker: MockFixture, config)
8687
def test_init_when_config_already_exists(config, capsys):
8788
# Set config path
8889
path = os.sep.join(["tests", "pyproject.toml"])
89-
config.add_path(path)
90+
config.path = Path(path)
9091

9192
commands.Init(config)()
9293
captured = capsys.readouterr()

0 commit comments

Comments
 (0)