Skip to content

Commit 2c0acc6

Browse files
committed
core/refactor[typing]: Clarify generic object types
why: Reduce Any usage in fixtures/helpers and align log formatter signature with stdlib. what: - Use object for doctest namespace and raw test loader return - Narrow is_valid_config input type for type guard usage - Replace LogFormatter kwargs with explicit stdlib-compatible params
1 parent 13c5020 commit 2c0acc6

4 files changed

Lines changed: 20 additions & 5 deletions

File tree

conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
@pytest.fixture(autouse=True)
2323
def add_doctest_fixtures(
2424
request: pytest.FixtureRequest,
25-
doctest_namespace: dict[str, t.Any],
25+
doctest_namespace: dict[str, object],
2626
) -> None:
2727
"""Harness pytest fixtures to doctests namespace."""
2828
from _pytest.doctest import DoctestItem

src/vcspull/log.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,23 @@ def template(self, record: logging.LogRecord) -> str:
175175

176176
return "".join(reset + levelname + asctime + name + reset)
177177

178-
def __init__(self, color: bool = True, **kwargs: t.Any) -> None:
179-
logging.Formatter.__init__(self, **kwargs)
178+
def __init__(
179+
self,
180+
color: bool = True,
181+
fmt: str | None = None,
182+
datefmt: str | None = None,
183+
style: t.Literal["%", "{", "$"] = "%",
184+
validate: bool = True,
185+
defaults: t.Mapping[str, object] | None = None,
186+
) -> None:
187+
logging.Formatter.__init__(
188+
self,
189+
fmt=fmt,
190+
datefmt=datefmt,
191+
style=style,
192+
validate=validate,
193+
defaults=defaults,
194+
)
180195

181196
def format(self, record: logging.LogRecord) -> str:
182197
"""Format log record."""

src/vcspull/validator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from vcspull.types import RawConfigDict
99

1010

11-
def is_valid_config(config: dict[str, t.Any]) -> t.TypeGuard[RawConfigDict]:
11+
def is_valid_config(config: dict[str, object]) -> t.TypeGuard[RawConfigDict]:
1212
"""Return true and upcast if vcspull configuration file is valid."""
1313
if not isinstance(config, dict):
1414
return False

tests/helpers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,6 @@ def write_config(config_path: pathlib.Path, content: str) -> pathlib.Path:
5858
return config_path
5959

6060

61-
def load_raw(data: str, fmt: t.Literal["yaml", "json"]) -> dict[str, t.Any]:
61+
def load_raw(data: str, fmt: t.Literal["yaml", "json"]) -> dict[str, object]:
6262
"""Load configuration data via string value. Accepts yaml or json."""
6363
return ConfigReader._load(fmt=fmt, content=data)

0 commit comments

Comments
 (0)