Skip to content

Commit dd45294

Browse files
committed
chore(ruff) Automated fixes for typing annotations
Fixed 11 errors: - src/vcspull/_internal/config_reader.py: 2 × TC006 (runtime-cast-value) - src/vcspull/cli/sync.py: 1 × TC006 (runtime-cast-value) - src/vcspull/config.py: 3 × UP006 (non-pep585-annotation) 2 × RUF052 (used-dummy-variable) 1 × I001 (unsorted-imports) - tests/test_config.py: 2 × RUF052 (used-dummy-variable) Found 362 errors (11 fixed, 351 remaining). 25 files left unchanged uv run ruff check --select ALL . --fix --unsafe-fixes --preview --show-fixes; uv run ruff format .
1 parent 7efcd8a commit dd45294

File tree

4 files changed

+21
-20
lines changed

4 files changed

+21
-20
lines changed

src/vcspull/_internal/config_reader.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,14 @@ def _load(fmt: "FormatLiteral", content: str) -> dict[str, t.Any]:
3737
"""
3838
if fmt == "yaml":
3939
return t.cast(
40-
dict[str, t.Any],
40+
"dict[str, t.Any]",
4141
yaml.load(
4242
content,
4343
Loader=yaml.SafeLoader,
4444
),
4545
)
4646
if fmt == "json":
47-
return t.cast(dict[str, t.Any], json.loads(content))
47+
return t.cast("dict[str, t.Any]", json.loads(content))
4848
msg = f"{fmt} not supported in configuration"
4949
raise NotImplementedError(msg)
5050

src/vcspull/cli/sync.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ def guess_vcs(url: str) -> t.Optional[VCSLiteral]:
128128
log.warning(f"No exact matches for {url}")
129129
return None
130130

131-
return t.cast(VCSLiteral, vcs_matches[0].vcs)
131+
return t.cast("VCSLiteral", vcs_matches[0].vcs)
132132

133133

134134
class CouldNotGuessVCSFromURL(exc.VCSPullException):

src/vcspull/config.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import os
66
import pathlib
77
import typing as t
8+
from collections.abc import Callable
89

910
from libvcs.sync.git import GitRemote
1011

@@ -23,8 +24,8 @@
2324

2425

2526
def expand_dir(
26-
_dir: pathlib.Path,
27-
cwd: t.Union[pathlib.Path, t.Callable[[], pathlib.Path]] = pathlib.Path.cwd,
27+
dir_: pathlib.Path,
28+
cwd: t.Union[pathlib.Path, Callable[[], pathlib.Path]] = pathlib.Path.cwd,
2829
) -> pathlib.Path:
2930
"""Return path with environmental variables and tilde ~ expanded.
3031
@@ -40,19 +41,19 @@ def expand_dir(
4041
pathlib.Path :
4142
Absolute directory path
4243
"""
43-
_dir = pathlib.Path(os.path.expandvars(str(_dir))).expanduser()
44+
dir_ = pathlib.Path(os.path.expandvars(str(dir_))).expanduser()
4445
if callable(cwd):
4546
cwd = cwd()
4647

47-
if not _dir.is_absolute():
48-
_dir = pathlib.Path(os.path.normpath(cwd / _dir))
49-
assert _dir == pathlib.Path(cwd, _dir).resolve(strict=False)
50-
return _dir
48+
if not dir_.is_absolute():
49+
dir_ = pathlib.Path(os.path.normpath(cwd / dir_))
50+
assert dir_ == pathlib.Path(cwd, dir_).resolve(strict=False)
51+
return dir_
5152

5253

5354
def extract_repos(
5455
config: "RawConfigDict",
55-
cwd: t.Union[pathlib.Path, t.Callable[[], pathlib.Path]] = pathlib.Path.cwd,
56+
cwd: t.Union[pathlib.Path, Callable[[], pathlib.Path]] = pathlib.Path.cwd,
5657
) -> list["ConfigDict"]:
5758
"""Return expanded configuration.
5859
@@ -233,7 +234,7 @@ def find_config_files(
233234

234235
def load_configs(
235236
files: list[pathlib.Path],
236-
cwd: t.Union[pathlib.Path, t.Callable[[], pathlib.Path]] = pathlib.Path.cwd,
237+
cwd: t.Union[pathlib.Path, Callable[[], pathlib.Path]] = pathlib.Path.cwd,
237238
) -> list["ConfigDict"]:
238239
"""Return repos from a list of files.
239240

tests/test_config.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,14 @@ def fn(
3434
filename: str = "randomfilename.yaml",
3535
) -> tuple[pathlib.Path, list[pathlib.Path], list["ConfigDict"]]:
3636
"""Return vcspull configurations and write out config to temp directory."""
37-
_dir = tmp_path / path
38-
_dir.mkdir()
39-
_config = _dir / filename
40-
_config.write_text(content, encoding="utf-8")
41-
42-
configs = config.find_config_files(path=_dir)
43-
repos = config.load_configs(configs, cwd=_dir)
44-
return _dir, configs, repos
37+
dir_ = tmp_path / path
38+
dir_.mkdir()
39+
config_ = dir_ / filename
40+
config_.write_text(content, encoding="utf-8")
41+
42+
configs = config.find_config_files(path=dir_)
43+
repos = config.load_configs(configs, cwd=dir_)
44+
return dir_, configs, repos
4545

4646
return fn
4747

0 commit comments

Comments
 (0)