Skip to content

Commit e05658d

Browse files
committed
refactor!: dir -> path to not shadow builtin
1 parent 2cc79d1 commit e05658d

21 files changed

+311
-305
lines changed

CHANGES

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,7 @@ Temporarily add `Faker` as a dependency (due to pytest), track longterm fix on (
604604

605605
Before: `project.parent_dir`
606606

607-
After: `project.parent.dir`.
607+
After: `project.parent.path`.
608608

609609
- `repo_name` switched from attribute to property
610610

@@ -722,13 +722,13 @@ Temporarily add `Faker` as a dependency (due to pytest), track longterm fix on (
722722
`libvcs.sync.{module}.{Module}Project`
723723
- `repo_dir` param is renamed to `dir`:
724724

725-
Before: `GitSync(url='...', repo_dir='...')`
725+
Before: `GitSync(url='...', repo_path='...')`
726726

727-
After: `GitSync(url='...', dir='...')`
727+
After: `GitSync(url='...', path='...')`
728728

729729
#324
730730

731-
- `dir` to `pathlib`, `BaseSync.path` -> `BaseSync.dir`
731+
- `dir` to `pathlib`, `BaseSync.path` -> `BaseSync.path`
732732
- Logging functions moved to {attr}`libvcs.sync.base.BaseSync.log` (#322)
733733
- Rename `ProjectLoggingAdapter` to `CmdLoggingAdapter`
734734
- `CmdLoggingAdapter`: Rename `repo_name` param to `keyword`
@@ -768,7 +768,7 @@ Temporarily add `Faker` as a dependency (due to pytest), track longterm fix on (
768768
```python
769769
repo = GitSync(
770770
url="https://github.com/vcs-python/libvcs",
771-
repo_dir=checkout,
771+
repo_path=checkout,
772772
remotes={
773773
'gitlab': 'https://gitlab.com/vcs-python/libvcs',
774774
}
@@ -778,7 +778,7 @@ Temporarily add `Faker` as a dependency (due to pytest), track longterm fix on (
778778
```python
779779
repo = GitSync(
780780
url="https://github.com/vcs-python/libvcs",
781-
repo_dir=checkout,
781+
repo_path=checkout,
782782
remotes={
783783
'gitlab': {
784784
'fetch_url': 'https://gitlab.com/vcs-python/libvcs',

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ Simple [`subprocess`](https://docs.python.org/3/library/subprocess.html) wrapper
8383
import pathlib
8484
from libvcs.cmd.git import Git
8585

86-
git = Git(dir=pathlib.Path.cwd() / 'my_git_repo')
86+
git = Git(path=pathlib.Path.cwd() / 'my_git_repo')
8787
git.clone(url='https://github.com/vcs-python/libvcs.git')
8888
```
8989

@@ -98,7 +98,7 @@ from libvcs.sync.git import GitSync
9898

9999
repo = GitSync(
100100
url="https://github.com/vcs-python/libvcs",
101-
dir=pathlib.Path().cwd() / "my_repo",
101+
path=pathlib.Path().cwd() / "my_repo",
102102
remotes={
103103
'gitlab': 'https://gitlab.com/vcs-python/libvcs'
104104
}
@@ -136,7 +136,7 @@ def test_repo_git_remote_checkout(
136136
) -> None:
137137
git_server = create_git_remote_repo()
138138
git_repo_checkout_dir = projects_path / "my_git_checkout"
139-
git_repo = GitSync(dir=str(git_repo_checkout_dir), url=f"file://{git_server!s}")
139+
git_repo = GitSync(path=str(git_repo_checkout_dir), url=f"file://{git_server!s}")
140140

141141
git_repo.obtain()
142142
git_repo.update_repo()

src/libvcs/_internal/shortcuts.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def __init__(self, url: str, vcs: str, *args: object):
3636
def create_project(
3737
*,
3838
url: str,
39-
dir: StrPath,
39+
path: StrPath,
4040
vcs: t.Literal["git"],
4141
progress_callback: t.Optional[ProgressCallbackProtocol] = None,
4242
**kwargs: dict[t.Any, t.Any],
@@ -48,7 +48,7 @@ def create_project(
4848
def create_project(
4949
*,
5050
url: str,
51-
dir: StrPath,
51+
path: StrPath,
5252
vcs: t.Literal["svn"],
5353
progress_callback: t.Optional[ProgressCallbackProtocol] = None,
5454
**kwargs: dict[t.Any, t.Any],
@@ -60,7 +60,7 @@ def create_project(
6060
def create_project(
6161
*,
6262
url: str,
63-
dir: StrPath,
63+
path: StrPath,
6464
vcs: t.Literal["hg"],
6565
progress_callback: t.Optional[ProgressCallbackProtocol] = ...,
6666
**kwargs: dict[t.Any, t.Any],
@@ -71,7 +71,7 @@ def create_project(
7171
def create_project(
7272
*,
7373
url: str,
74-
dir: StrPath,
74+
path: StrPath,
7575
vcs: t.Optional[VCSLiteral] = None,
7676
progress_callback: t.Optional[ProgressCallbackProtocol] = None,
7777
**kwargs: dict[t.Any, t.Any],
@@ -84,7 +84,7 @@ def create_project(
8484
>>> r = create_project(
8585
... url=f'file://{create_git_remote_repo()}',
8686
... vcs='git',
87-
... dir=tmp_path
87+
... path=tmp_path
8888
... )
8989
9090
>>> isinstance(r, GitSync)
@@ -95,7 +95,7 @@ def create_project(
9595
>>> r = create_project(
9696
... # Note the git+ before the URL
9797
... url=f'git+file://{create_git_remote_repo()}',
98-
... dir=tmp_path
98+
... path=tmp_path
9999
... )
100100
101101
>>> isinstance(r, GitSync)
@@ -120,10 +120,14 @@ def is_vcs(val: t.Any) -> "TypeGuard[VCSLiteral]":
120120
raise VCSNotSupported(url=url, vcs=vcs_matches[0].vcs)
121121

122122
if vcs == "git":
123-
return GitSync(url=url, dir=dir, progress_callback=progress_callback, **kwargs)
123+
return GitSync(
124+
url=url, path=path, progress_callback=progress_callback, **kwargs
125+
)
124126
elif vcs == "hg":
125-
return HgSync(url=url, dir=dir, progress_callback=progress_callback, **kwargs)
127+
return HgSync(url=url, path=path, progress_callback=progress_callback, **kwargs)
126128
elif vcs == "svn":
127-
return SvnSync(url=url, dir=dir, progress_callback=progress_callback, **kwargs)
129+
return SvnSync(
130+
url=url, path=path, progress_callback=progress_callback, **kwargs
131+
)
128132
else:
129133
raise InvalidVCS("VCS %s is not a valid VCS" % vcs)

0 commit comments

Comments
 (0)