Skip to content

Commit

Permalink
chore: annotate types in some test helpers and fixtures
Browse files Browse the repository at this point in the history
This didn't help with Pylint E1101, though; see
pylint-dev/pylint#9252
  • Loading branch information
akaihola committed Feb 3, 2025
1 parent 50237d5 commit 30f1ffe
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
12 changes: 10 additions & 2 deletions src/darker/tests/helpers.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
"""Helper functions for unit tests"""

from __future__ import annotations

import sys
from contextlib import contextmanager
from types import ModuleType
from typing import Generator, Optional
from typing import TYPE_CHECKING, Generator, Optional
from unittest.mock import patch

from darkgraylib.testtools.git_repo_plugin import GitRepoFixture

if TYPE_CHECKING:
import pytest
from _pytest.fixtures import SubRequest


@contextmanager
def _package_present(
Expand Down Expand Up @@ -56,7 +62,9 @@ def flynt_present(present: bool) -> Generator[None, None, None]:


@contextmanager
def unix_and_windows_newline_repos(request, tmp_path_factory):
def unix_and_windows_newline_repos(
request: SubRequest, tmp_path_factory: pytest.TempPathFactory
) -> Generator[dict[str, GitRepoFixture], None, None]:
"""Create temporary repositories for Unix and windows newlines separately."""
with GitRepoFixture.context(
request, tmp_path_factory
Expand Down
6 changes: 5 additions & 1 deletion src/darker/tests/test_git.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@
from subprocess import DEVNULL, check_call # nosec
from textwrap import dedent # nosec
from types import SimpleNamespace
from typing import Generator
from unittest.mock import ANY, patch

import pytest
from _pytest.fixtures import SubRequest

from darker import git
from darkgraylib.git import WORKTREE, RevisionRange
Expand Down Expand Up @@ -321,7 +323,9 @@ def test_git_get_modified_python_files(


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

Expand Down

0 comments on commit 30f1ffe

Please sign in to comment.