Skip to content

Commit 3ae7ec4

Browse files
committed
ruff format (after adding flake8-commas)
1 parent abd3bc8 commit 3ae7ec4

File tree

15 files changed

+95
-36
lines changed

15 files changed

+95
-36
lines changed

src/libvcs/_internal/run.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,9 @@ def __init__(self, bin_name: str, keyword: str, *args: Any, **kwargs: Any) -> No
6565
logging.LoggerAdapter.__init__(self, *args, **kwargs)
6666

6767
def process(
68-
self, msg: str, kwargs: MutableMapping[str, Any],
68+
self,
69+
msg: str,
70+
kwargs: MutableMapping[str, Any],
6971
) -> tuple[Any, MutableMapping[str, Any]]:
7072
"""Add additional context information for loggers."""
7173
prefixed_dict = {}
@@ -89,7 +91,8 @@ def __call__(self, output: AnyStr, timestamp: datetime.datetime) -> None:
8991
_ENV: "TypeAlias" = Mapping[str, str]
9092
else:
9193
_ENV: "TypeAlias" = Union[
92-
Mapping[bytes, StrOrBytesPath], Mapping[str, StrOrBytesPath],
94+
Mapping[bytes, StrOrBytesPath],
95+
Mapping[str, StrOrBytesPath],
9396
]
9497

9598
_CMD = Union[StrOrBytesPath, Sequence[StrOrBytesPath]]

src/libvcs/_internal/subprocess.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ def __init__(self, output: str, *args: object):
7373
_ENV: "TypeAlias" = Mapping[str, str]
7474
else:
7575
_ENV: "TypeAlias" = Union[
76-
Mapping[bytes, StrOrBytesPath], Mapping[str, StrOrBytesPath],
76+
Mapping[bytes, StrOrBytesPath],
77+
Mapping[str, StrOrBytesPath],
7778
]
7879
_FILE: "TypeAlias" = Union[None, int, IO[Any]]
7980
_TXT: "TypeAlias" = Union[bytes, str]

src/libvcs/_internal/types.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@
1616
""":class:`os.PathLike` or :class:`str`"""
1717

1818
StrOrBytesPath: "TypeAlias" = Union[
19-
str, bytes, PathLike[str], PathLike[bytes], # stable
19+
str,
20+
bytes,
21+
PathLike[str],
22+
PathLike[bytes], # stable
2023
]
2124
""":class:`os.PathLike`, :class:`str` or :term:`bytes-like object`"""
2225

src/libvcs/cmd/git.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -733,7 +733,8 @@ def rebase(
733733
local_flags.append("--quit")
734734

735735
return self.run(
736-
["rebase", *local_flags, *required_flags], check_returncode=check_returncode,
736+
["rebase", *local_flags, *required_flags],
737+
check_returncode=check_returncode,
737738
)
738739

739740
def pull(

src/libvcs/pytest_plugin.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,21 +30,25 @@ def __init__(self, attempts: int, *args: object):
3030

3131

3232
skip_if_git_missing = pytest.mark.skipif(
33-
not shutil.which("git"), reason="git is not available",
33+
not shutil.which("git"),
34+
reason="git is not available",
3435
)
3536
skip_if_svn_missing = pytest.mark.skipif(
36-
not shutil.which("svn"), reason="svn is not available",
37+
not shutil.which("svn"),
38+
reason="svn is not available",
3739
)
3840
skip_if_hg_missing = pytest.mark.skipif(
39-
not shutil.which("hg"), reason="hg is not available",
41+
not shutil.which("hg"),
42+
reason="hg is not available",
4043
)
4144

4245

4346
class RandomStrSequence:
4447
"""Create a random string sequence."""
4548

4649
def __init__(
47-
self, characters: str = "abcdefghijklmnopqrstuvwxyz0123456789_",
50+
self,
51+
characters: str = "abcdefghijklmnopqrstuvwxyz0123456789_",
4852
) -> None:
4953
self.characters: str = characters
5054

@@ -163,7 +167,8 @@ def hgconfig(user_path: pathlib.Path, set_home: pathlib.Path) -> pathlib.Path:
163167

164168
@pytest.fixture(scope="function")
165169
def projects_path(
166-
user_path: pathlib.Path, request: pytest.FixtureRequest,
170+
user_path: pathlib.Path,
171+
request: pytest.FixtureRequest,
167172
) -> pathlib.Path:
168173
"""User's local checkouts and clones. Emphemeral directory."""
169174
dir = user_path / "projects"
@@ -178,7 +183,8 @@ def clean() -> None:
178183

179184
@pytest.fixture(scope="function")
180185
def remote_repos_path(
181-
user_path: pathlib.Path, request: pytest.FixtureRequest,
186+
user_path: pathlib.Path,
187+
request: pytest.FixtureRequest,
182188
) -> pathlib.Path:
183189
"""System's remote (file-based) repos to clone andpush to. Emphemeral directory."""
184190
dir = user_path / "remote_repos"
@@ -431,7 +437,8 @@ def fn(
431437
@pytest.fixture
432438
@skip_if_hg_missing
433439
def hg_remote_repo(
434-
remote_repos_path: pathlib.Path, hgconfig: pathlib.Path,
440+
remote_repos_path: pathlib.Path,
441+
hgconfig: pathlib.Path,
435442
) -> pathlib.Path:
436443
"""Pre-made, file-based repo for push and pull."""
437444
return _create_hg_remote_repo(

src/libvcs/sync/base.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,10 @@ def __init__(
118118

119119
#: Logging attribute
120120
self.log: CmdLoggingAdapter = CmdLoggingAdapter(
121-
bin_name=self.bin_name, keyword=self.repo_name, logger=logger, extra={},
121+
bin_name=self.bin_name,
122+
keyword=self.repo_name,
123+
logger=logger,
124+
extra={},
122125
)
123126

124127
@property

src/libvcs/sync/git.py

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,8 @@ def convert_pip_url(pip_url: str) -> VCSLocation:
174174
raise exc.LibVCSException(
175175
"Repo {} is malformatted, please use the convention {} for "
176176
"ssh / private GitHub repositories.".format(
177-
pip_url, "git+https://github.com/username/repo.git",
177+
pip_url,
178+
"git+https://github.com/username/repo.git",
178179
),
179180
)
180181
else:
@@ -192,7 +193,12 @@ class GitSync(BaseSync):
192193
_remotes: GitSyncRemoteDict
193194

194195
def __init__(
195-
self, *, url: str, dir: StrPath, remotes: GitRemotesArgs = None, **kwargs: Any,
196+
self,
197+
*,
198+
url: str,
199+
dir: StrPath,
200+
remotes: GitRemotesArgs = None,
201+
**kwargs: Any,
196202
) -> None:
197203
"""Local git repository.
198204
@@ -396,7 +402,9 @@ def update_repo(self, set_remotes: bool = False, *args: Any, **kwargs: Any) -> N
396402
# Get head sha
397403
try:
398404
head_sha = self.cmd.rev_list(
399-
commit="HEAD", max_count=1, check_returncode=True,
405+
commit="HEAD",
406+
max_count=1,
407+
check_returncode=True,
400408
)
401409
except exc.CommandError:
402410
self.log.exception("Failed to get the hash for HEAD")
@@ -565,22 +573,30 @@ def remote(self, name: str, **kwargs: Any) -> Optional[GitRemote]:
565573
"""
566574
try:
567575
ret = self.cmd.remote.show(
568-
name=name, no_query_remotes=True, log_in_real_time=True,
576+
name=name,
577+
no_query_remotes=True,
578+
log_in_real_time=True,
569579
)
570580
lines = ret.split("\n")
571581
remote_fetch_url = lines[1].replace("Fetch URL: ", "").strip()
572582
remote_push_url = lines[2].replace("Push URL: ", "").strip()
573583
if remote_fetch_url != name and remote_push_url != name:
574584
return GitRemote(
575-
name=name, fetch_url=remote_fetch_url, push_url=remote_push_url,
585+
name=name,
586+
fetch_url=remote_fetch_url,
587+
push_url=remote_push_url,
576588
)
577589
else:
578590
return None
579591
except exc.LibVCSException:
580592
return None
581593

582594
def set_remote(
583-
self, name: str, url: str, push: bool = False, overwrite: bool = False,
595+
self,
596+
name: str,
597+
url: str,
598+
push: bool = False,
599+
overwrite: bool = False,
584600
) -> GitRemote:
585601
"""Set remote with name and URL like git remote add.
586602

src/libvcs/sync/svn.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,10 @@ def get_revision(self, location: Optional[str] = None) -> int:
141141
return revision
142142

143143
def update_repo(
144-
self, dest: Optional[str] = None, *args: Any, **kwargs: Any,
144+
self,
145+
dest: Optional[str] = None,
146+
*args: Any,
147+
**kwargs: Any,
145148
) -> None:
146149
"""Fetch changes from SVN repository to local working copy."""
147150
self.ensure_dir()
@@ -193,7 +196,8 @@ def _get_svn_url_rev(cls, location: str) -> tuple[Optional[str], int]:
193196
# is being used to prompt for passwords, because passwords
194197
# are only potentially needed for remote server requests.
195198
xml = Svn(dir=pathlib.Path(location).parent).info(
196-
target=pathlib.Path(location), xml=True,
199+
target=pathlib.Path(location),
200+
xml=True,
197201
)
198202
match = _svn_info_xml_url_re.search(xml)
199203
assert match is not None

src/libvcs/url/registry.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ def __init__(self, parsers: "ParserLazyMap"):
4040
self.parser_map[k] = v
4141

4242
def match(
43-
self, url: str, is_explicit: t.Optional[bool] = None,
43+
self,
44+
url: str,
45+
is_explicit: t.Optional[bool] = None,
4446
) -> list["ParserMatch"]:
4547
"""Return a list of potential VCS' identified for a given URL."""
4648
matches: list[ParserMatch] = []

tests/_internal/subprocess/test_SubprocessCommand.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,9 @@ def test_init(args: list[Any], kwargs: dict[str, Any], expected_result: Any) ->
6060
ids=idfn,
6161
)
6262
def test_init_and_Popen(
63-
args: list[Any], kwargs: dict[str, Any], expected_result: Any,
63+
args: list[Any],
64+
kwargs: dict[str, Any],
65+
expected_result: Any,
6466
) -> None:
6567
"""Test SubprocessCommand with Popen."""
6668
cmd = SubprocessCommand(*args, **kwargs)
@@ -81,7 +83,9 @@ def test_init_and_Popen(
8183
ids=idfn,
8284
)
8385
def test_init_and_Popen_run(
84-
args: list[Any], kwargs: dict[str, Any], expected_result: Any,
86+
args: list[Any],
87+
kwargs: dict[str, Any],
88+
expected_result: Any,
8589
) -> None:
8690
"""Test SubprocessCommand with run."""
8791
cmd = SubprocessCommand(*args, **kwargs)
@@ -101,7 +105,9 @@ def test_init_and_Popen_run(
101105
ids=idfn,
102106
)
103107
def test_init_and_check_call(
104-
args: list[Any], kwargs: dict[str, Any], expected_result: Any,
108+
args: list[Any],
109+
kwargs: dict[str, Any],
110+
expected_result: Any,
105111
) -> None:
106112
"""Test SubprocessCommand with Popen.check_call."""
107113
cmd = SubprocessCommand(*args, **kwargs)
@@ -119,7 +125,9 @@ def test_init_and_check_call(
119125
FIXTURES,
120126
)
121127
def test_init_and_check_output(
122-
args: list[Any], kwargs: dict[str, Any], expected_result: Any,
128+
args: list[Any],
129+
kwargs: dict[str, Any],
130+
expected_result: Any,
123131
) -> None:
124132
"""Test SubprocessCommand with Popen.check_output."""
125133
cmd = SubprocessCommand(*args, **kwargs)

0 commit comments

Comments
 (0)