Skip to content

Commit 850e2ca

Browse files
fix: address type checking review comments
- Add type annotations to smart_open in git.py - Add type: ignore[attr-defined] for Template.substitute call - Cast dict to ChangelogArgs in bump.py - Cast dynamic key dict to VersionArgs in test_version_command.py Co-authored-by: Copilot <[email protected]>
1 parent 0a22b49 commit 850e2ca

4 files changed

Lines changed: 10 additions & 6 deletions

File tree

commitizen/commands/bump.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,10 @@ def __call__(self) -> None:
323323
try:
324324
Changelog(
325325
self.config,
326-
{**changelog_args, "dry_run": True},
326+
cast(
327+
"ChangelogArgs",
328+
{**changelog_args, "dry_run": True},
329+
),
327330
)()
328331
except DryRunExit:
329332
pass

commitizen/cz/customize/customize.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def questions(self) -> list[CzQuestion]:
5555
def message(self, answers: Mapping[str, Any]) -> str:
5656
message_template = Template(self.custom_settings.get("message_template", ""))
5757
if getattr(Template, "substitute", None):
58-
return message_template.substitute(
58+
return message_template.substitute( # type: ignore[attr-defined]
5959
**answers
6060
) # pragma: no cover # TODO: check if we can fix this
6161
return message_template.render(**answers)

commitizen/git.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from functools import lru_cache
66
from pathlib import Path
77
from tempfile import NamedTemporaryFile
8+
from typing import IO, Any
89

910
from commitizen import cmd, out
1011
from commitizen.exceptions import GitCommandError
@@ -316,7 +317,7 @@ def get_core_editor() -> str | None:
316317
return None
317318

318319

319-
def smart_open(*args, **kwargs): # noqa: ANN201
320+
def smart_open(*args: Any, **kwargs: Any) -> IO[Any]: # noqa: ANN401
320321
"""Open a file with the EOL style determined from Git."""
321322
return open(*args, newline=EOLType.for_open(), **kwargs)
322323

tests/commands/test_version_command.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import platform
22
import sys
3+
from typing import cast
34

45
import pytest
56
from pytest_mock import MockerFixture
67

78
from commitizen import commands
89
from commitizen.__version__ import __version__
10+
from commitizen.commands.version import VersionArgs
911
from commitizen.config.base_config import BaseConfig
1012

1113

@@ -151,9 +153,7 @@ def test_version_just_minor(config, capsys, version: str, expected_version: str)
151153
def test_version_just_major_error_no_project(config, capsys, argument: str):
152154
commands.Version(
153155
config,
154-
{
155-
argument: True,
156-
},
156+
cast("VersionArgs", {argument: True}),
157157
)()
158158
captured = capsys.readouterr()
159159
assert not captured.out

0 commit comments

Comments
 (0)