Skip to content

Commit 4601bfa

Browse files
authored
Remove 0.14.x deprecations (#377)
2 parents 4f174a7 + 361ef02 commit 4601bfa

8 files changed

Lines changed: 51 additions & 130 deletions

File tree

CHANGES

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@ $ pip install --user --upgrade --pre libvcs
1616
### Breaking changes
1717

1818
- {issue}`372` Typings moved from `libvcs.types` -> {mod}`libvcs._internal.types`
19+
- {issue}`377` Remove deprecated functions and exceptions
20+
21+
- Removed `libvcs.shortcuts`
22+
- Removed `libvcs.shortcuts.create_project_from_pip_url()`: This will be replaced in future
23+
versions by {issue}`376` / parsing utilities
24+
- Moved `libvcs.shortcuts.create_project()` to {func}`libvcs._internal.shortcuts.create_project`
25+
- Removed {exc}`libvcs.exc.InvalidPipURL`
1926

2027
### Fixes
2128

@@ -59,7 +66,7 @@ $ pip install --user --upgrade --pre libvcs
5966

6067
### Typings
6168

62-
- {func}`~libvcs.shortcuts.create_project`: Add overloads that return the typed project (e.g.
69+
- `create_project()`: Add overloads that return the typed project (e.g.
6370
{class}`~libvcs.projects.git.GitProject`)
6471

6572
## libvcs 0.13.2 (2022-06-12)

libvcs/_internal/shortcuts.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def create_project(
5757
5858
Examples
5959
--------
60-
>>> from libvcs.shortcuts import create_project
60+
>>> from libvcs._internal.shortcuts import create_project
6161
>>> r = create_project(
6262
... url=f'file://{create_git_remote_repo()}',
6363
... vcs='git',

libvcs/exc.py

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -33,21 +33,5 @@ class CommandTimeoutError(CommandError):
3333
"""CommandError which gets raised when a subprocess exceeds its timeout."""
3434

3535

36-
class InvalidPipURL(LibVCSException):
37-
"""Invalid pip-style URL."""
38-
39-
def __init__(self, url):
40-
self.url = url
41-
super().__init__()
42-
43-
def __str__(self):
44-
return self.message
45-
46-
message = (
47-
"Repo URL %s requires a vcs scheme. Prepend the vcs (hg+, git+, svn+)"
48-
"to the repo URL. e.g: git+https://github.com/freebsd/freebsd.git"
49-
)
50-
51-
5236
class InvalidVCS(LibVCSException):
5337
"""Invalid VCS."""

libvcs/shortcuts.py

Lines changed: 0 additions & 41 deletions
This file was deleted.

tests/projects/test_git.py

Lines changed: 37 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
from libvcs import exc
1313
from libvcs._internal.run import run, which
14+
from libvcs._internal.shortcuts import create_project
1415
from libvcs.conftest import CreateProjectCallbackFixtureProtocol
1516
from libvcs.projects.git import (
1617
GitFullRemoteDict,
@@ -19,7 +20,6 @@
1920
GitStatus,
2021
convert_pip_url as git_convert_pip_url,
2122
)
22-
from libvcs.shortcuts import create_project_from_pip_url
2323

2424
if not which("git"):
2525
pytestmark = pytest.mark.skip(reason="git is not available")
@@ -39,13 +39,15 @@
3939
lambda bare_dir, tmp_path, **kwargs: {
4040
"url": f"file://{bare_dir}",
4141
"dir": tmp_path / "obtaining a bare repo",
42+
"vcs": "git",
4243
},
4344
],
4445
[
45-
create_project_from_pip_url,
46+
create_project,
4647
lambda bare_dir, tmp_path, **kwargs: {
47-
"pip_url": f"git+file://{bare_dir}",
48+
"url": f"git+file://{bare_dir}",
4849
"dir": tmp_path / "obtaining a bare repo",
50+
"vcs": "git",
4951
},
5052
],
5153
],
@@ -80,13 +82,15 @@ def test_repo_git_obtain_initial_commit_repo(
8082
lambda git_remote_repo, tmp_path, **kwargs: {
8183
"url": f"file://{git_remote_repo}",
8284
"dir": tmp_path / "myrepo",
85+
"vcs": "git",
8386
},
8487
],
8588
[
86-
create_project_from_pip_url,
89+
create_project,
8790
lambda git_remote_repo, tmp_path, **kwargs: {
88-
"pip_url": f"git+file://{git_remote_repo}",
91+
"url": f"git+file://{git_remote_repo}",
8992
"dir": tmp_path / "myrepo",
93+
"vcs": "git",
9094
},
9195
],
9296
],
@@ -115,13 +119,15 @@ def test_repo_git_obtain_full(
115119
lambda git_remote_repo, tmp_path, **kwargs: {
116120
"url": f"file://{git_remote_repo}",
117121
"dir": tmp_path / "myrepo",
122+
"vcs": "git",
118123
},
119124
],
120125
[
121-
create_project_from_pip_url,
126+
create_project,
122127
lambda git_remote_repo, tmp_path, **kwargs: {
123-
"pip_url": f"git+file://{git_remote_repo}",
128+
"url": f"git+file://{git_remote_repo}",
124129
"dir": tmp_path / "myrepo",
130+
"vcs": "git",
125131
},
126132
],
127133
],
@@ -158,14 +164,16 @@ def test_repo_update_handle_cases(
158164
"url": f"file://{git_remote_repo}",
159165
"dir": tmp_path / "myrepo",
160166
"progress_callback": progress_callback,
167+
"vcs": "git",
161168
},
162169
],
163170
[
164-
create_project_from_pip_url,
171+
create_project,
165172
lambda git_remote_repo, tmp_path, progress_callback, **kwargs: {
166-
"pip_url": f"git+file://{git_remote_repo}",
173+
"url": f"git+file://{git_remote_repo}",
167174
"dir": tmp_path / "myrepo",
168175
"progress_callback": progress_callback,
176+
"vcs": "git",
169177
},
170178
],
171179
],
@@ -272,6 +280,7 @@ def progress_callback_spy(output, timestamp):
272280
lambda git_remote_repo, projects_path, repo_name, **kwargs: {
273281
"url": f"file://{git_remote_repo}",
274282
"dir": projects_path / repo_name,
283+
"vcs": "git",
275284
"remotes": {
276285
"second_remote": GitRemote(
277286
name="second_remote",
@@ -285,10 +294,11 @@ def progress_callback_spy(output, timestamp):
285294
},
286295
],
287296
[
288-
create_project_from_pip_url,
297+
create_project,
289298
lambda git_remote_repo, projects_path, repo_name, **kwargs: {
290-
"pip_url": f"git+file://{git_remote_repo}",
299+
"url": f"git+file://{git_remote_repo}",
291300
"dir": projects_path / repo_name,
301+
"vcs": "git",
292302
},
293303
lambda git_remote_repo, **kwargs: {"origin": f"file://{git_remote_repo}"},
294304
],
@@ -472,13 +482,15 @@ def test_git_get_url_and_rev_from_pip_url():
472482
lambda git_remote_repo, dir, **kwargs: {
473483
"url": f"file://{git_remote_repo}",
474484
"dir": str(dir),
485+
"vcs": "git",
475486
},
476487
],
477488
[
478-
create_project_from_pip_url,
489+
create_project,
479490
lambda git_remote_repo, dir, **kwargs: {
480-
"pip_url": f"git+file://{git_remote_repo}",
491+
"url": f"git+file://{git_remote_repo}",
481492
"dir": dir,
493+
"vcs": "git",
482494
},
483495
],
484496
],
@@ -514,13 +526,15 @@ def test_remotes_preserves_git_ssh(
514526
lambda bare_dir, tmp_path, **kwargs: {
515527
"url": f"file://{bare_dir}",
516528
"dir": tmp_path / "obtaining a bare repo",
529+
"vcs": "git",
517530
},
518531
],
519532
[
520-
create_project_from_pip_url,
533+
create_project,
521534
lambda bare_dir, tmp_path, **kwargs: {
522-
"pip_url": f"git+file://{bare_dir}",
535+
"url": f"git+file://{bare_dir}",
523536
"dir": tmp_path / "obtaining a bare repo",
537+
"vcs": "git",
524538
},
525539
],
526540
],
@@ -530,14 +544,15 @@ def test_private_ssh_format(
530544
constructor: ProjectTestFactory,
531545
lazy_constructor_options: ProjectTestFactoryLazyKwargs,
532546
):
533-
pip_url_kwargs = {
534-
"pip_url": "git+ssh://github.com:/tmp/omg/private_ssh_repo",
535-
"dir": tmpdir,
536-
}
537-
538547
with pytest.raises(exc.LibVCSException) as excinfo:
539-
create_project_from_pip_url(**pip_url_kwargs)
540-
excinfo.match(r"is malformatted")
548+
create_project(
549+
url=git_convert_pip_url(
550+
"git+ssh://github.com:/tmp/omg/private_ssh_repo"
551+
).url,
552+
dir=tmpdir,
553+
vcs="git",
554+
)
555+
excinfo.match(r".*is a malformed.*")
541556

542557

543558
def test_ls_remotes(git_repo: GitProject):

tests/projects/test_hg.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
from libvcs._internal.run import run, which
77
from libvcs._internal.shortcuts import create_project
8-
from libvcs.shortcuts import create_project_from_pip_url
98

109
if not which("hg"):
1110
pytestmark = pytest.mark.skip(reason="hg is not available")
@@ -14,11 +13,10 @@
1413
def test_repo_mercurial(tmp_path: pathlib.Path, projects_path, hg_remote_repo):
1514
repo_name = "my_mercurial_project"
1615

17-
mercurial_repo = create_project_from_pip_url(
18-
**{
19-
"pip_url": f"hg+file://{hg_remote_repo}",
20-
"dir": projects_path / repo_name,
21-
}
16+
mercurial_repo = create_project(
17+
url=f"file://{hg_remote_repo}",
18+
dir=projects_path / repo_name,
19+
vcs="hg",
2220
)
2321

2422
run(["hg", "init", mercurial_repo.repo_name], cwd=tmp_path)

tests/test_exc.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,3 @@ def test_command_error():
3131
command = "command arg"
3232
raise exc.CommandError("this is output", 0, command)
3333
assert e.value.cmd == command
34-
35-
36-
def test_invalid_pip_url():
37-
with pytest.raises(exc.InvalidPipURL) as e:
38-
raise exc.InvalidPipURL("http://github.com/wrong/format")
39-
assert str(e.value) == e.value.message

tests/test_shortcuts.py

Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -4,43 +4,7 @@
44

55
from libvcs import GitProject, MercurialProject, SubversionProject
66
from libvcs._internal.shortcuts import create_project
7-
from libvcs.exc import InvalidPipURL, InvalidVCS
8-
from libvcs.shortcuts import create_project_from_pip_url
9-
10-
11-
@pytest.mark.parametrize(
12-
"repo_dict,repo_class,raises_exception",
13-
[
14-
({"pip_url": "git+https://github.com/freebsd/freebsd.git"}, GitProject, False),
15-
(
16-
{"pip_url": "hg+https://bitbucket.org/birkenfeld/sphinx"},
17-
MercurialProject,
18-
False,
19-
),
20-
(
21-
{"pip_url": "svn+http://svn.code.sf.net/p/docutils/code/trunk"},
22-
SubversionProject,
23-
False,
24-
),
25-
(
26-
{"pip_url": "sv+http://svn.code.sf.net/p/docutils/code/trunk"},
27-
None,
28-
InvalidPipURL,
29-
),
30-
],
31-
)
32-
def test_create_project_from_pip_url(
33-
tmp_path: pathlib.Path, repo_dict, repo_class, raises_exception
34-
):
35-
# add parent_dir via fixture
36-
repo_dict["dir"] = tmp_path / "repo_name"
37-
38-
if raises_exception:
39-
with pytest.raises(raises_exception):
40-
create_project_from_pip_url(**repo_dict)
41-
else:
42-
repo = create_project_from_pip_url(**repo_dict)
43-
assert isinstance(repo, repo_class)
7+
from libvcs.exc import InvalidVCS
448

459

4610
@pytest.mark.parametrize(

0 commit comments

Comments
 (0)