Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

refactor(BaseConfig): update function name, upgrade mypy version #1444

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 23, 2025
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
12 changes: 9 additions & 3 deletions 12 commitizen/config/base_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@ def settings(self) -> Settings:
def path(self) -> Path | None:
return self._path

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

def set_key(self, key, value):
"""Set or update a key in the conf.

Expand All @@ -30,8 +39,5 @@ def set_key(self, key, value):
def update(self, data: Settings) -> None:
self._settings.update(data)

def add_path(self, path: str | Path) -> None:
self._path = Path(path)

Lee-W marked this conversation as resolved.
Show resolved Hide resolved
def _parse_setting(self, data: bytes | str) -> None:
raise NotImplementedError()
2 changes: 1 addition & 1 deletion 2 commitizen/config/json_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class JsonConfig(BaseConfig):
def __init__(self, *, data: bytes | str, path: Path | str):
super().__init__()
self.is_empty_config = False
self.add_path(path)
self.path = path # type: ignore
self._parse_setting(data)

def init_empty_config_content(self):
Expand Down
2 changes: 1 addition & 1 deletion 2 commitizen/config/toml_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class TomlConfig(BaseConfig):
def __init__(self, *, data: bytes | str, path: Path | str):
super().__init__()
self.is_empty_config = False
self.add_path(path)
self.path = path # type: ignore
self._parse_setting(data)

def init_empty_config_content(self):
Expand Down
2 changes: 1 addition & 1 deletion 2 commitizen/config/yaml_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class YAMLConfig(BaseConfig):
def __init__(self, *, data: bytes | str, path: Path | str):
super().__init__()
self.is_empty_config = False
self.add_path(path)
self.path = path # type: ignore
self._parse_setting(data)

def init_empty_config_content(self):
Expand Down
108 changes: 51 additions & 57 deletions 108 poetry.lock

Large diffs are not rendered by default.

14 changes: 3 additions & 11 deletions 14 pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ deprecated = "^1.2.13"
[tool.poetry.group.linters.dependencies]
ruff = ">=0.5.0,<0.10.0"
pre-commit = ">=2.18,<5.0"
mypy = "^1.4"
mypy = "^1.15.0"
types-deprecated = "^1.2.9.2"
types-python-dateutil = "^2.8.19.13"
types-PyYAML = ">=5.4.3,<7.0.0"
Expand Down Expand Up @@ -250,12 +250,7 @@ cover.help = "Run the test suite with coverage"
cover.ref = "test --cov-report term-missing --cov-report=xml:coverage.xml --cov=commitizen"

all.help = "Run all tasks"
all.sequence = [
"format",
"lint",
"cover",
"check-commit",
]
all.sequence = ["format", "lint", "cover", "check-commit"]

"doc:screenshots".help = "Render documentation screeenshots"
"doc:screenshots".script = "scripts.gen_cli_help_screenshots:gen_cli_help_screenshots"
Expand All @@ -267,10 +262,7 @@ doc.help = "Live documentation server"
doc.cmd = "mkdocs serve"

ci.help = "Run all tasks in CI"
ci.sequence = [
{ cmd = "pre-commit run --all-files" },
"cover",
]
ci.sequence = [{ cmd = "pre-commit run --all-files" }, "cover"]
ci.env = { SKIP = "no-commit-to-branch" }

setup-pre-commit.help = "Install pre-commit hooks"
Expand Down
2 changes: 1 addition & 1 deletion 2 tests/commands/test_init_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def test_init_without_setup_pre_commit_hook(tmpdir, mocker: MockFixture, config)
def test_init_when_config_already_exists(config, capsys):
# Set config path
path = os.sep.join(["tests", "pyproject.toml"])
config.add_path(path)
config.path = path

commands.Init(config)()
captured = capsys.readouterr()
Expand Down
4 changes: 3 additions & 1 deletion 4 tests/test_changelog.py
Original file line number Diff line number Diff line change
Expand Up @@ -1641,7 +1641,9 @@ def test_tags_rules_get_version_tags(capsys: pytest.CaptureFixture):

def test_changelog_file_name_from_args_and_config():
mock_config = Mock(spec=BaseConfig)
mock_config.path.parent = "/my/project"
mock_path = Mock(spec=Path)
mock_path.parent = Path("/my/project")
mock_config.path = mock_path
mock_config.settings = {
"name": "cz_conventional_commits",
"changelog_file": "CHANGELOG.md",
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.