Skip to content

Commit 7f1d0c6

Browse files
committed
fix(BaseConfig): raise error if Path is not set
1 parent 28ac03b commit 7f1d0c6

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

commitizen/config/base_config.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,13 @@ def settings(self) -> Settings:
2626
return self._settings
2727

2828
@property
29-
def path(self) -> Path | None:
29+
def path(self) -> Path:
30+
if self._path is None:
31+
raise ValueError("Path is not set")
3032
return self._path
3133

3234
@path.setter
3335
def path(self, path: str | Path) -> None:
34-
"""
35-
mypy does not like this until 1.16
36-
See https://github.com/python/mypy/pull/18510
37-
TODO: remove "type: ignore" from the call sites when 1.16 is available
38-
"""
3936
self._path = Path(path)
4037

4138
def set_key(self, key: str, value: Any) -> Self:

tests/config/test_base_config.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import pytest
2+
3+
from commitizen.config.base_config import BaseConfig
4+
5+
6+
def test_base_config_init():
7+
config = BaseConfig()
8+
with pytest.raises(ValueError):
9+
config.path

0 commit comments

Comments
 (0)