Skip to content

Commit 3f67566

Browse files
committed
!squash more Remove unused tuples dicts
1 parent 7723e7b commit 3f67566

File tree

2 files changed

+6
-52
lines changed

2 files changed

+6
-52
lines changed

libvcs/projects/git.py

Lines changed: 2 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@
1818
import logging
1919
import pathlib
2020
import re
21-
import typing
22-
from typing import Any, Dict, NamedTuple, Optional, TypedDict, Union
21+
from typing import Any, Dict, Optional, Union
2322
from urllib import parse as urlparse
2423

2524
from libvcs._internal.types import StrOrBytesPath, StrPath
@@ -34,22 +33,6 @@
3433
logger = logging.getLogger(__name__)
3534

3635

37-
class GitRemoteDict(TypedDict):
38-
"""For use when hydrating GitProject via dict, and exporting as dict."""
39-
40-
name: Optional[str]
41-
fetch_url: str
42-
push_url: str
43-
44-
45-
class GitRemoteTuple(NamedTuple):
46-
"""For use when exporting GitRemote as tuple."""
47-
48-
name: Optional[str]
49-
fetch_url: str
50-
push_url: str
51-
52-
5336
@dataclasses.dataclass
5437
class GitRemote:
5538
"""Structure containing git working copy information."""
@@ -58,31 +41,9 @@ class GitRemote:
5841
fetch_url: str
5942
push_url: str
6043

61-
def to_tuple(self) -> GitRemoteTuple:
62-
return GitRemoteTuple(*dataclasses.astuple(self))
63-
6444

6545
GitProjectRemoteDict = Dict[str, GitRemote]
66-
GitFullRemoteDict = Dict[str, GitRemoteDict]
67-
GitRemotesArgs = Union[None, GitFullRemoteDict, GitProjectRemoteDict, Dict[str, str]]
68-
69-
70-
class GitStatusDict(TypedDict):
71-
branch_oid: Optional[str]
72-
branch_head: Optional[str]
73-
branch_upstream: Optional[str]
74-
branch_ab: Optional[str]
75-
branch_ahead: Optional[str]
76-
branch_behind: Optional[str]
77-
78-
79-
class GitStatusTuple(typing.NamedTuple):
80-
branch_oid: Optional[str]
81-
branch_head: Optional[str]
82-
branch_upstream: Optional[str]
83-
branch_ab: Optional[str]
84-
branch_ahead: Optional[str]
85-
branch_behind: Optional[str]
46+
GitRemotesArgs = Union[None, GitProjectRemoteDict, Dict[str, str]]
8647

8748

8849
@dataclasses.dataclass
@@ -94,9 +55,6 @@ class GitStatus:
9455
branch_ahead: Optional[str] = None
9556
branch_behind: Optional[str] = None
9657

97-
def to_tuple(self) -> GitStatusTuple:
98-
return GitStatusTuple(*dataclasses.astuple(self))
99-
10058
@classmethod
10159
def from_stdout(cls, value: str) -> "GitStatus":
10260
"""Returns ``git status -sb --porcelain=2`` extracted to a dict

tests/projects/test_git.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
from libvcs._internal.shortcuts import create_project
1515
from libvcs.conftest import CreateProjectCallbackFixtureProtocol
1616
from libvcs.projects.git import (
17-
GitFullRemoteDict,
1817
GitProject,
1918
GitRemote,
2019
GitStatus,
@@ -28,7 +27,6 @@
2827
ProjectTestFactory = Callable[..., GitProject]
2928
ProjectTestFactoryLazyKwargs = Callable[..., dict]
3029
ProjectTestFactoryRemoteLazyExpected = Callable[..., Dict[str, GitRemote]]
31-
ProjectTestFactoryRemoteDictLazyExpected = Callable[..., GitFullRemoteDict]
3230

3331

3432
@pytest.mark.parametrize(
@@ -372,11 +370,9 @@ def test_remotes(
372370
assert remote is not None
373371

374372
if remote is not None:
375-
assert (
376-
expected_remote_name,
377-
expected_remote_dict.fetch_url,
378-
expected_remote_dict.push_url,
379-
) == remote.to_tuple()
373+
assert expected_remote_name == remote.name
374+
assert expected_remote_dict.fetch_url == remote.fetch_url
375+
assert expected_remote_dict.push_url == remote.push_url
380376

381377

382378
@pytest.mark.parametrize(
@@ -472,7 +468,7 @@ def test_remotes_update_repo(
472468
git_remote_repo: pathlib.Path,
473469
constructor: ProjectTestFactory,
474470
lazy_constructor_options: ProjectTestFactoryLazyKwargs,
475-
lazy_remote_dict: ProjectTestFactoryRemoteDictLazyExpected,
471+
lazy_remote_dict: ProjectTestFactoryRemoteLazyExpected,
476472
lazy_remote_expected: ProjectTestFactoryRemoteLazyExpected,
477473
create_git_remote_repo: CreateProjectCallbackFixtureProtocol,
478474
) -> None:

0 commit comments

Comments
 (0)