Skip to content

Commit 7fddf59

Browse files
committed
style: replace dict with Mapping
1 parent 83ffd9e commit 7fddf59

File tree

8 files changed

+16
-12
lines changed

8 files changed

+16
-12
lines changed

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 # type: ignore
16+
self.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 # type: ignore
17+
self.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 # type: ignore
17+
self.path = path
1818
self._parse_setting(data)
1919

2020
def init_empty_config_content(self):

commitizen/cz/base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from __future__ import annotations
22

33
from abc import ABCMeta, abstractmethod
4-
from collections.abc import Iterable
4+
from collections.abc import Iterable, Mapping
55
from typing import Any, Callable, Protocol
66

77
from jinja2 import BaseLoader, PackageLoader
@@ -72,7 +72,7 @@ def questions(self) -> Questions:
7272
"""Questions regarding the commit message."""
7373

7474
@abstractmethod
75-
def message(self, answers: dict) -> str:
75+
def message(self, answers: Mapping[str, Any]) -> str:
7676
"""Format your git message."""
7777

7878
@property

commitizen/cz/customize/customize.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from __future__ import annotations
22

3-
from typing import TYPE_CHECKING
3+
from collections.abc import Mapping
4+
from typing import TYPE_CHECKING, Any
45

56
if TYPE_CHECKING:
67
from jinja2 import Template
@@ -48,7 +49,7 @@ def __init__(self, config: BaseConfig):
4849
def questions(self) -> Questions:
4950
return self.custom_settings.get("questions", [{}])
5051

51-
def message(self, answers: dict) -> str:
52+
def message(self, answers: Mapping[str, Any]) -> str:
5253
message_template = Template(self.custom_settings.get("message_template", ""))
5354
if getattr(Template, "substitute", None):
5455
return message_template.substitute(**answers) # type: ignore

commitizen/cz/jira/jira.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import os
2+
from collections.abc import Mapping
23

34
from commitizen.cz.base import BaseCommitizen
45
from commitizen.defaults import Questions
@@ -43,7 +44,7 @@ def questions(self) -> Questions:
4344
},
4445
]
4546

46-
def message(self, answers: dict[str, str]) -> str:
47+
def message(self, answers: Mapping[str, str]) -> str:
4748
return " ".join(
4849
x
4950
for k in ("message", "issues", "workflow", "time", "comment")

tests/conftest.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import os
44
import re
55
import tempfile
6-
from collections.abc import Iterator
6+
from collections.abc import Iterator, Mapping
77
from pathlib import Path
88

99
import pytest
@@ -209,7 +209,7 @@ def questions(self) -> list:
209209
},
210210
]
211211

212-
def message(self, answers: dict) -> str:
212+
def message(self, answers: Mapping) -> str:
213213
prefix = answers["prefix"]
214214
subject = answers.get("subject", "default message").trim()
215215
return f"{prefix}: {subject}"
@@ -225,7 +225,7 @@ class MockPlugin(BaseCommitizen):
225225
def questions(self) -> defaults.Questions:
226226
return []
227227

228-
def message(self, answers: dict) -> str:
228+
def message(self, answers: Mapping) -> str:
229229
return ""
230230

231231

tests/test_cz_base.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from collections.abc import Mapping
2+
13
import pytest
24

35
from commitizen.cz.base import BaseCommitizen
@@ -7,7 +9,7 @@ class DummyCz(BaseCommitizen):
79
def questions(self):
810
return [{"type": "input", "name": "commit", "message": "Initial commit:\n"}]
911

10-
def message(self, answers: dict):
12+
def message(self, answers: Mapping):
1113
return answers["commit"]
1214

1315

0 commit comments

Comments
 (0)