Skip to content

Commit c1eea63

Browse files
bearomorphismLee-W
authored andcommitted
style: replace dict with Mapping
1 parent 18b9729 commit c1eea63

File tree

5 files changed

+13
-9
lines changed

5 files changed

+13
-9
lines changed

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) -> Iterable[CzQuestion]:
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
from commitizen.question import CzQuestion
67

@@ -49,7 +50,7 @@ def __init__(self, config: BaseConfig) -> None:
4950
def questions(self) -> list[CzQuestion]:
5051
return self.custom_settings.get("questions", [{}]) # type: ignore
5152

52-
def message(self, answers: dict) -> str:
53+
def message(self, answers: Mapping[str, Any]) -> str:
5354
message_template = Template(self.custom_settings.get("message_template", ""))
5455
if getattr(Template, "substitute", None):
5556
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.question import CzQuestion
@@ -43,7 +44,7 @@ def questions(self) -> list[CzQuestion]:
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
@@ -210,7 +210,7 @@ def questions(self) -> list:
210210
},
211211
]
212212

213-
def message(self, answers: dict) -> str:
213+
def message(self, answers: Mapping) -> str:
214214
prefix = answers["prefix"]
215215
subject = answers.get("subject", "default message").trim()
216216
return f"{prefix}: {subject}"
@@ -226,7 +226,7 @@ class MockPlugin(BaseCommitizen):
226226
def questions(self) -> list[CzQuestion]:
227227
return []
228228

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

232232

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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy