Skip to content

Commit 133e369

Browse files
committed
types(pytest plugin): Rename create repo Protocol functions
1 parent 147704c commit 133e369

4 files changed

Lines changed: 27 additions & 27 deletions

File tree

src/libvcs/pytest_plugin.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -194,17 +194,17 @@ def unique_repo_name(remote_repos_path: pathlib.Path, max_retries: int = 15) ->
194194
InitCmdArgs: "TypeAlias" = Optional[list[str]]
195195

196196

197-
class CreateProjectCallbackProtocol(Protocol):
197+
class CreateRepoPostInitFn(Protocol):
198198
def __call__(self, remote_repo_path: pathlib.Path) -> None:
199199
...
200200

201201

202-
class CreateProjectCallbackFixtureProtocol(Protocol):
202+
class CreateRepoPytestFixtureFn(Protocol):
203203
def __call__(
204204
self,
205205
remote_repos_path: pathlib.Path = ...,
206206
remote_repo_name: Optional[str] = ...,
207-
remote_repo_post_init: Optional[CreateProjectCallbackProtocol] = ...,
207+
remote_repo_post_init: Optional[CreateRepoPostInitFn] = ...,
208208
init_cmd_args: InitCmdArgs = ...,
209209
) -> pathlib.Path:
210210
...
@@ -216,7 +216,7 @@ def __call__(
216216
def _create_git_remote_repo(
217217
remote_repos_path: pathlib.Path,
218218
remote_repo_name: str,
219-
remote_repo_post_init: Optional[CreateProjectCallbackProtocol] = None,
219+
remote_repo_post_init: Optional[CreateRepoPostInitFn] = None,
220220
init_cmd_args: InitCmdArgs = DEFAULT_GIT_REMOTE_REPO_CMD_ARGS,
221221
) -> pathlib.Path:
222222
if init_cmd_args is None:
@@ -234,13 +234,13 @@ def _create_git_remote_repo(
234234
@skip_if_git_missing
235235
def create_git_remote_repo(
236236
remote_repos_path: pathlib.Path,
237-
) -> CreateProjectCallbackFixtureProtocol:
238-
"""Factory. Create git remote repo to for clone / push purposes"""
237+
) -> CreateRepoPytestFixtureFn:
238+
"""Factory. Create git remote repo to for clone / push purposes."""
239239

240240
def fn(
241241
remote_repos_path: pathlib.Path = remote_repos_path,
242242
remote_repo_name: Optional[str] = None,
243-
remote_repo_post_init: Optional[CreateProjectCallbackProtocol] = None,
243+
remote_repo_post_init: Optional[CreateRepoPostInitFn] = None,
244244
init_cmd_args: InitCmdArgs = DEFAULT_GIT_REMOTE_REPO_CMD_ARGS,
245245
) -> pathlib.Path:
246246
return _create_git_remote_repo(
@@ -278,7 +278,7 @@ def git_remote_repo(remote_repos_path: pathlib.Path) -> pathlib.Path:
278278
def _create_svn_remote_repo(
279279
remote_repos_path: pathlib.Path,
280280
remote_repo_name: str,
281-
remote_repo_post_init: Optional[CreateProjectCallbackProtocol] = None,
281+
remote_repo_post_init: Optional[CreateRepoPostInitFn] = None,
282282
init_cmd_args: InitCmdArgs = None,
283283
) -> pathlib.Path:
284284
"""Create a test SVN repo to for checkout / commit purposes"""
@@ -318,13 +318,13 @@ def svn_remote_repo_single_commit_post_init(remote_repo_path: pathlib.Path) -> N
318318
@skip_if_svn_missing
319319
def create_svn_remote_repo(
320320
remote_repos_path: pathlib.Path,
321-
) -> CreateProjectCallbackFixtureProtocol:
321+
) -> CreateRepoPytestFixtureFn:
322322
"""Pre-made svn repo, bare, used as a file:// remote to checkout and commit to."""
323323

324324
def fn(
325325
remote_repos_path: pathlib.Path = remote_repos_path,
326326
remote_repo_name: Optional[str] = None,
327-
remote_repo_post_init: Optional[CreateProjectCallbackProtocol] = None,
327+
remote_repo_post_init: Optional[CreateRepoPostInitFn] = None,
328328
init_cmd_args: InitCmdArgs = None,
329329
) -> pathlib.Path:
330330
return _create_svn_remote_repo(
@@ -355,7 +355,7 @@ def svn_remote_repo(remote_repos_path: pathlib.Path) -> pathlib.Path:
355355
def _create_hg_remote_repo(
356356
remote_repos_path: pathlib.Path,
357357
remote_repo_name: str,
358-
remote_repo_post_init: Optional[CreateProjectCallbackProtocol] = None,
358+
remote_repo_post_init: Optional[CreateRepoPostInitFn] = None,
359359
init_cmd_args: InitCmdArgs = None,
360360
) -> pathlib.Path:
361361
"""Create a test hg repo to for checkout / commit purposes"""
@@ -384,13 +384,13 @@ def create_hg_remote_repo(
384384
remote_repos_path: pathlib.Path,
385385
hgconfig: pathlib.Path,
386386
set_home: pathlib.Path,
387-
) -> CreateProjectCallbackFixtureProtocol:
387+
) -> CreateRepoPytestFixtureFn:
388388
"""Pre-made hg repo, bare, used as a file:// remote to checkout and commit to."""
389389

390390
def fn(
391391
remote_repos_path: pathlib.Path = remote_repos_path,
392392
remote_repo_name: Optional[str] = None,
393-
remote_repo_post_init: Optional[CreateProjectCallbackProtocol] = None,
393+
remote_repo_post_init: Optional[CreateRepoPostInitFn] = None,
394394
init_cmd_args: InitCmdArgs = None,
395395
) -> pathlib.Path:
396396
return _create_hg_remote_repo(
@@ -465,9 +465,9 @@ def add_doctest_fixtures(
465465
tmp_path: pathlib.Path,
466466
set_home: pathlib.Path,
467467
gitconfig: pathlib.Path,
468-
create_git_remote_repo: CreateProjectCallbackFixtureProtocol,
469-
create_svn_remote_repo: CreateProjectCallbackFixtureProtocol,
470-
create_hg_remote_repo: CreateProjectCallbackFixtureProtocol,
468+
create_git_remote_repo: CreateRepoPytestFixtureFn,
469+
create_svn_remote_repo: CreateRepoPytestFixtureFn,
470+
create_hg_remote_repo: CreateRepoPytestFixtureFn,
471471
git_repo: pathlib.Path,
472472
) -> None:
473473
from _pytest.doctest import DoctestItem

tests/sync/test_git.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from libvcs import exc
1313
from libvcs._internal.run import run
1414
from libvcs._internal.shortcuts import create_project
15-
from libvcs.pytest_plugin import CreateProjectCallbackFixtureProtocol
15+
from libvcs.pytest_plugin import CreateRepoPytestFixtureFn
1616
from libvcs.sync.git import (
1717
GitRemote,
1818
GitStatus,
@@ -169,7 +169,7 @@ def test_repo_update_handle_cases(
169169
)
170170
def test_repo_update_stash_cases(
171171
tmp_path: pathlib.Path,
172-
create_git_remote_repo: CreateProjectCallbackFixtureProtocol,
172+
create_git_remote_repo: CreateRepoPytestFixtureFn,
173173
mocker: MockerFixture,
174174
has_untracked_files: bool,
175175
needs_stash: bool,
@@ -531,7 +531,7 @@ def test_remotes_update_repo(
531531
lazy_constructor_options: ProjectTestFactoryLazyKwargs,
532532
lazy_remote_dict: ProjectTestFactoryRemoteLazyExpected,
533533
lazy_remote_expected: ProjectTestFactoryRemoteLazyExpected,
534-
create_git_remote_repo: CreateProjectCallbackFixtureProtocol,
534+
create_git_remote_repo: CreateRepoPytestFixtureFn,
535535
) -> None:
536536
repo_name = "myrepo"
537537
remote_name = "myremote"
@@ -887,7 +887,7 @@ def test_GitRemote__from_stdout_c(fixture: str, expected_result: GitStatus) -> N
887887

888888

889889
def test_repo_git_remote_checkout(
890-
create_git_remote_repo: CreateProjectCallbackFixtureProtocol,
890+
create_git_remote_repo: CreateRepoPytestFixtureFn,
891891
tmp_path: pathlib.Path,
892892
projects_path: pathlib.Path,
893893
) -> None:

tests/sync/test_svn.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import pytest
66

7-
from libvcs.pytest_plugin import CreateProjectCallbackFixtureProtocol
7+
from libvcs.pytest_plugin import CreateRepoPytestFixtureFn
88
from libvcs.sync.svn import SvnSync
99

1010
if not shutil.which("svn"):
@@ -29,7 +29,7 @@ def test_repo_svn(tmp_path: pathlib.Path, svn_remote_repo: pathlib.Path) -> None
2929

3030

3131
def test_repo_svn_remote_checkout(
32-
create_svn_remote_repo: CreateProjectCallbackFixtureProtocol,
32+
create_svn_remote_repo: CreateRepoPytestFixtureFn,
3333
tmp_path: pathlib.Path,
3434
projects_path: pathlib.Path,
3535
) -> None:

tests/test_pytest_plugin.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44

55
import pytest
66

7-
from libvcs.pytest_plugin import CreateProjectCallbackFixtureProtocol
7+
from libvcs.pytest_plugin import CreateRepoPytestFixtureFn
88

99

1010
@pytest.mark.skipif(not shutil.which("git"), reason="git is not available")
1111
def test_create_git_remote_repo(
12-
create_git_remote_repo: CreateProjectCallbackFixtureProtocol,
12+
create_git_remote_repo: CreateRepoPytestFixtureFn,
1313
tmp_path: pathlib.Path,
1414
projects_path: pathlib.Path,
1515
) -> None:
@@ -21,7 +21,7 @@ def test_create_git_remote_repo(
2121

2222
@pytest.mark.skipif(not shutil.which("svn"), reason="svn is not available")
2323
def test_create_svn_remote_repo(
24-
create_svn_remote_repo: CreateProjectCallbackFixtureProtocol,
24+
create_svn_remote_repo: CreateRepoPytestFixtureFn,
2525
tmp_path: pathlib.Path,
2626
projects_path: pathlib.Path,
2727
) -> None:
@@ -69,10 +69,10 @@ def setup(
6969
import pathlib
7070
7171
from libvcs.sync.git import GitSync
72-
from libvcs.pytest_plugin import CreateProjectCallbackFixtureProtocol
72+
from libvcs.pytest_plugin import CreateRepoPytestFixtureFn
7373
7474
def test_repo_git_remote_checkout(
75-
create_git_remote_repo: CreateProjectCallbackFixtureProtocol,
75+
create_git_remote_repo: CreateRepoPytestFixtureFn,
7676
tmp_path: pathlib.Path,
7777
projects_path: pathlib.Path,
7878
) -> None:

0 commit comments

Comments
 (0)