Skip to content

Commit 30f1ffe

Browse files
committed
chore: annotate types in some test helpers and fixtures
This didn't help with Pylint E1101, though; see pylint-dev/pylint#9252
1 parent 50237d5 commit 30f1ffe

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

src/darker/tests/helpers.py

+10-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
11
"""Helper functions for unit tests"""
22

3+
from __future__ import annotations
4+
35
import sys
46
from contextlib import contextmanager
57
from types import ModuleType
6-
from typing import Generator, Optional
8+
from typing import TYPE_CHECKING, Generator, Optional
79
from unittest.mock import patch
810

911
from darkgraylib.testtools.git_repo_plugin import GitRepoFixture
1012

13+
if TYPE_CHECKING:
14+
import pytest
15+
from _pytest.fixtures import SubRequest
16+
1117

1218
@contextmanager
1319
def _package_present(
@@ -56,7 +62,9 @@ def flynt_present(present: bool) -> Generator[None, None, None]:
5662

5763

5864
@contextmanager
59-
def unix_and_windows_newline_repos(request, tmp_path_factory):
65+
def unix_and_windows_newline_repos(
66+
request: SubRequest, tmp_path_factory: pytest.TempPathFactory
67+
) -> Generator[dict[str, GitRepoFixture], None, None]:
6068
"""Create temporary repositories for Unix and windows newlines separately."""
6169
with GitRepoFixture.context(
6270
request, tmp_path_factory

src/darker/tests/test_git.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@
88
from subprocess import DEVNULL, check_call # nosec
99
from textwrap import dedent # nosec
1010
from types import SimpleNamespace
11+
from typing import Generator
1112
from unittest.mock import ANY, patch
1213

1314
import pytest
15+
from _pytest.fixtures import SubRequest
1416

1517
from darker import git
1618
from darkgraylib.git import WORKTREE, RevisionRange
@@ -321,7 +323,9 @@ def test_git_get_modified_python_files(
321323

322324

323325
@pytest.fixture(scope="module")
324-
def git_get_modified_python_files_revision_range_repo(request, tmp_path_factory):
326+
def git_get_modified_python_files_revision_range_repo(
327+
request: SubRequest, tmp_path_factory: pytest.TempPathFactory
328+
) -> Generator[GitRepoFixture]:
325329
"""Fixture for a Git repository with multiple commits and branches."""
326330
yield from branched_repo(request, tmp_path_factory)
327331

0 commit comments

Comments
 (0)