Skip to content

Commit f5ff8b7

Browse files
authored
libvcs v0.27.0 (linting updates, #435)
Includes breaking rename (`dir` -> `path`)
2 parents a1813a1 + 355ce6f commit f5ff8b7

File tree

14 files changed

+88
-75
lines changed

14 files changed

+88
-75
lines changed

CHANGES

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,16 @@ $ pipx install --suffix=@next 'vcspull' --pip-args '\--pre' --force
2121

2222
<!-- Maintainers, insert changes / features for the next release here -->
2323

24+
### Breaking changes
25+
26+
- libvcs: v0.25.0 -> v0.26.0 (#435)
27+
28+
Renamings of `dir` to `path`.
29+
30+
- Fix shadowing of python builtins
31+
32+
- `dir` -> `path` (#435)
33+
2434
### Documentation
2535

2636
- Refactor API docs to split across multiple pages (#431)

conftest.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,15 @@ def cwd_default(monkeypatch: pytest.MonkeyPatch, tmp_path: pathlib.Path) -> None
4444
monkeypatch.chdir(tmp_path)
4545

4646

47-
@pytest.fixture(autouse=True, scope="session")
48-
@pytest.mark.usefixtures("set_home")
49-
def xdg_config_path(user_path: pathlib.Path) -> pathlib.Path:
47+
@pytest.fixture(autouse=True)
48+
def xdg_config_path(
49+
user_path: pathlib.Path,
50+
set_home: pathlib.Path,
51+
) -> pathlib.Path:
5052
"""Create and return path to use for XDG Config Path."""
5153
p = user_path / ".config"
52-
p.mkdir()
54+
if not p.exists():
55+
p.mkdir()
5356
return p
5457

5558

poetry.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ vcspull = 'vcspull:cli.cli'
6161

6262
[tool.poetry.dependencies]
6363
python = "^3.9"
64-
libvcs = "~0.26.0"
64+
libvcs = "~0.27.0"
6565
colorama = ">=0.3.9"
6666
PyYAML = "^6.0"
6767

scripts/generate_gitlab.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@
9696

9797
config[path][reponame] = {
9898
"name": reponame,
99-
"dir": path / reponame,
99+
"path": path / reponame,
100100
"url": f"git+ssh://{url_to_repo}",
101101
"remotes": {
102102
"origin": GitRemote(

src/vcspull/cli/sync.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,19 +79,19 @@ def sync(
7979
found_repos = []
8080

8181
for repo_pattern in repo_patterns:
82-
dir, vcs_url, name = None, None, None
82+
path, vcs_url, name = None, None, None
8383
if any(repo_pattern.startswith(n) for n in ["./", "/", "~", "$HOME"]):
84-
dir = repo_pattern
84+
path = repo_pattern
8585
elif any(repo_pattern.startswith(n) for n in ["http", "git", "svn", "hg"]):
8686
vcs_url = repo_pattern
8787
else:
8888
name = repo_pattern
8989

9090
# collect the repos from the config files
91-
found = filter_repos(configs, dir=dir, vcs_url=vcs_url, name=name)
91+
found = filter_repos(configs, path=path, vcs_url=vcs_url, name=name)
9292
if len(found) == 0:
9393
print(NO_REPOS_FOR_TERM_MSG.format(name=name))
94-
found_repos.extend(filter_repos(configs, dir=dir, vcs_url=vcs_url, name=name))
94+
found_repos.extend(filter_repos(configs, path=path, vcs_url=vcs_url, name=name))
9595

9696
for repo in found_repos:
9797
try:

src/vcspull/config.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,8 @@ def extract_repos(
102102
if "name" not in conf:
103103
conf["name"] = repo
104104

105-
if "dir" not in conf:
106-
conf["dir"] = expand_dir(
105+
if "path" not in conf:
106+
conf["path"] = expand_dir(
107107
pathlib.Path(expand_dir(pathlib.Path(directory), cwd=cwd))
108108
/ conf["name"],
109109
cwd,
@@ -301,10 +301,10 @@ def detect_duplicate_repos(
301301
dupes: list[ConfigDictTuple] = []
302302

303303
repo_dirs = {
304-
pathlib.Path(repo["dir"]).parent / repo["name"]: repo for repo in config1
304+
pathlib.Path(repo["path"]).parent / repo["name"]: repo for repo in config1
305305
}
306306
repo_dirs_2 = {
307-
pathlib.Path(repo["dir"]).parent / repo["name"]: repo for repo in config2
307+
pathlib.Path(repo["path"]).parent / repo["name"]: repo for repo in config2
308308
}
309309

310310
for repo_dir, repo in repo_dirs.items():
@@ -347,19 +347,19 @@ def in_dir(
347347

348348
def filter_repos(
349349
config: list["ConfigDict"],
350-
dir: t.Union[pathlib.Path, t.Literal["*"], str, None] = None,
350+
path: t.Union[pathlib.Path, t.Literal["*"], str, None] = None,
351351
vcs_url: t.Union[str, None] = None,
352352
name: t.Union[str, None] = None,
353353
) -> list["ConfigDict"]:
354354
"""Return a :py:obj:`list` list of repos from (expanded) config file.
355355
356-
dir, vcs_url and name all support fnmatch.
356+
path, vcs_url and name all support fnmatch.
357357
358358
Parameters
359359
----------
360360
config : dict
361361
the expanded repo config in :py:class:`dict` format.
362-
dir : str, Optional
362+
path : str, Optional
363363
directory of checkout location, fnmatch pattern supported
364364
vcs_url : str, Optional
365365
url of vcs remote, fn match pattern supported
@@ -373,12 +373,12 @@ def filter_repos(
373373
"""
374374
repo_list: list["ConfigDict"] = []
375375

376-
if dir:
376+
if path:
377377
repo_list.extend(
378378
[
379379
r
380380
for r in config
381-
if fnmatch.fnmatch(str(pathlib.Path(r["dir"]).parent), str(dir))
381+
if fnmatch.fnmatch(str(pathlib.Path(r["path"]).parent), str(path))
382382
]
383383
)
384384

src/vcspull/types.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class RawConfigDict(t.TypedDict):
1212

1313
vcs: VCSLiteral
1414
name: str
15-
dir: StrPath
15+
path: StrPath
1616
url: str
1717
remotes: GitSyncRemoteDict
1818

@@ -26,7 +26,7 @@ class ConfigDict(TypedDict):
2626

2727
vcs: t.Optional[VCSLiteral]
2828
name: str
29-
dir: pathlib.Path
29+
path: pathlib.Path
3030
url: str
3131
remotes: NotRequired[t.Optional[GitSyncRemoteDict]]
3232
shell_command_after: NotRequired[t.Optional[list[str]]]

tests/fixtures/example.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,32 +41,32 @@
4141
{
4242
"vcs": "git",
4343
"name": "linux",
44-
"dir": pathlib.Path("/home/me/myproject/study/linux"),
44+
"path": pathlib.Path("/home/me/myproject/study/linux"),
4545
"url": "git+git://git.kernel.org/linux/torvalds/linux.git",
4646
},
4747
{
4848
"vcs": "git",
4949
"name": "freebsd",
50-
"dir": pathlib.Path("/home/me/myproject/study/freebsd"),
50+
"path": pathlib.Path("/home/me/myproject/study/freebsd"),
5151
"url": "git+https://github.com/freebsd/freebsd.git",
5252
},
5353
{
5454
"vcs": "git",
5555
"name": "sphinx",
56-
"dir": pathlib.Path("/home/me/myproject/study/sphinx"),
56+
"path": pathlib.Path("/home/me/myproject/study/sphinx"),
5757
"url": "hg+https://bitbucket.org/birkenfeld/sphinx",
5858
},
5959
{
6060
"vcs": "git",
6161
"name": "docutils",
62-
"dir": pathlib.Path("/home/me/myproject/study/docutils"),
62+
"path": pathlib.Path("/home/me/myproject/study/docutils"),
6363
"url": "svn+http://svn.code.sf.net/p/docutils/code/trunk",
6464
},
6565
{
6666
"vcs": "git",
6767
"name": "kaptan",
6868
"url": "git+git@github.com:tony/kaptan.git",
69-
"dir": pathlib.Path("/home/me/myproject/github_projects/kaptan"),
69+
"path": pathlib.Path("/home/me/myproject/github_projects/kaptan"),
7070
"remotes": {
7171
"upstream": GitRemote(
7272
**{
@@ -87,14 +87,14 @@
8787
{
8888
"vcs": "git",
8989
"name": ".vim",
90-
"dir": pathlib.Path("/home/me/myproject/.vim"),
90+
"path": pathlib.Path("/home/me/myproject/.vim"),
9191
"url": "git+git@github.com:tony/vim-config.git",
9292
"shell_command_after": ["ln -sf /home/me/.vim/.vimrc /home/me/.vimrc"],
9393
},
9494
{
9595
"vcs": "git",
9696
"name": ".tmux",
97-
"dir": pathlib.Path("/home/me/myproject/.tmux"),
97+
"path": pathlib.Path("/home/me/myproject/.tmux"),
9898
"url": "git+git@github.com:tony/tmux-config.git",
9999
"shell_command_after": ["ln -sf /home/me/.tmux/.tmux.conf /home/me/.tmux.conf"],
100100
},

tests/test_cli.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ def test_sync_cli_filter_non_existent(
8484
config = {
8585
"~/github_projects/": {
8686
"my_git_project": {
87-
"url": f"git+file://{git_repo.dir}",
88-
"remotes": {"test_remote": f"git+file://{git_repo.dir}"},
87+
"url": f"git+file://{git_repo.path}",
88+
"remotes": {"test_remote": f"git+file://{git_repo.path}"},
8989
},
9090
}
9191
}
@@ -219,11 +219,11 @@ def test_sync(
219219
config = {
220220
"~/github_projects/": {
221221
"my_git_repo": {
222-
"url": f"git+file://{git_repo.dir}",
223-
"remotes": {"test_remote": f"git+file://{git_repo.dir}"},
222+
"url": f"git+file://{git_repo.path}",
223+
"remotes": {"test_remote": f"git+file://{git_repo.path}"},
224224
},
225225
"broken_repo": {
226-
"url": f"git+file://{git_repo.dir}",
226+
"url": f"git+file://{git_repo.path}",
227227
"remotes": {"test_remote": "git+file://non-existent-remote"},
228228
},
229229
}
@@ -360,8 +360,8 @@ def test_sync_broken(
360360
config = {
361361
"~/github_projects/": {
362362
"my_git_repo": {
363-
"url": f"git+file://{git_repo.dir}",
364-
"remotes": {"test_remote": f"git+file://{git_repo.dir}"},
363+
"url": f"git+file://{git_repo.path}",
364+
"remotes": {"test_remote": f"git+file://{git_repo.path}"},
365365
},
366366
"my_git_repo_not_found": {
367367
"url": "git+file:///dev/null",

0 commit comments

Comments
 (0)