Skip to content

Commit 5d6c06b

Browse files
authored
refactor!(cmd): Keyword-only params (#366)
See also: https://peps.python.org/pep-3102/
2 parents ae873e9 + 35adcb6 commit 5d6c06b

File tree

3 files changed

+23
-9
lines changed

3 files changed

+23
-9
lines changed

libvcs/cmd/git.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111

1212
class Git:
13-
def __init__(self, dir: StrPath):
13+
def __init__(self, *, dir: StrPath):
1414
"""Lite, typed, pythonic wrapper for git(1).
1515
1616
Parameters
@@ -36,7 +36,7 @@ def __repr__(self):
3636
def run(
3737
self,
3838
args: _CMD,
39-
/,
39+
*,
4040
# Print-and-exit flags
4141
version: Optional[bool] = None,
4242
help: Optional[bool] = None,
@@ -185,6 +185,7 @@ def run(
185185

186186
def clone(
187187
self,
188+
*,
188189
url: str,
189190
separate_git_dir: Optional[StrOrBytesPath] = None,
190191
template: Optional[str] = None,
@@ -312,6 +313,7 @@ def clone(
312313

313314
def fetch(
314315
self,
316+
*,
315317
reftag: Optional[Any] = None,
316318
deepen: Optional[str] = None,
317319
depth: Optional[str] = None,
@@ -469,6 +471,7 @@ def fetch(
469471

470472
def rebase(
471473
self,
474+
*,
472475
upstream: Optional[str] = None,
473476
onto: Optional[str] = None,
474477
branch: Optional[str] = None,
@@ -665,6 +668,7 @@ def rebase(
665668

666669
def pull(
667670
self,
671+
*,
668672
reftag: Optional[Any] = None,
669673
repository: Optional[str] = None,
670674
deepen: Optional[str] = None,
@@ -943,6 +947,7 @@ def pull(
943947

944948
def init(
945949
self,
950+
*,
946951
template: Optional[str] = None,
947952
separate_git_dir: Optional[StrOrBytesPath] = None,
948953
object_format: Optional[Literal["sha1", "sha256"]] = None,
@@ -1022,6 +1027,7 @@ def init(
10221027

10231028
def help(
10241029
self,
1030+
*,
10251031
all: Optional[bool] = None,
10261032
verbose: Optional[bool] = None,
10271033
no_external_commands: Optional[bool] = None,
@@ -1105,6 +1111,7 @@ def help(
11051111

11061112
def reset(
11071113
self,
1114+
*,
11081115
quiet: Optional[bool] = None,
11091116
refresh: Optional[bool] = None,
11101117
no_refresh: Optional[bool] = None,
@@ -1196,6 +1203,7 @@ def reset(
11961203

11971204
def checkout(
11981205
self,
1206+
*,
11991207
quiet: Optional[bool] = None,
12001208
progress: Optional[bool] = None,
12011209
no_progress: Optional[bool] = None,
@@ -1329,6 +1337,7 @@ def checkout(
13291337

13301338
def status(
13311339
self,
1340+
*,
13321341
verbose: Optional[bool] = None,
13331342
long: Optional[bool] = None,
13341343
short: Optional[bool] = None,
@@ -1456,6 +1465,7 @@ def status(
14561465

14571466
def config(
14581467
self,
1468+
*,
14591469
replace_all: Optional[bool] = None,
14601470
get: Optional[str] = None,
14611471
get_all: Optional[bool] = None,

libvcs/cmd/hg.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class HgPagerType(enum.Enum):
2525

2626

2727
class Hg:
28-
def __init__(self, dir: StrPath):
28+
def __init__(self, *, dir: StrPath):
2929
"""Lite, typed, pythonic wrapper for hg(1).
3030
3131
Parameters
@@ -51,6 +51,7 @@ def __repr__(self):
5151
def run(
5252
self,
5353
args: _CMD,
54+
*,
5455
config: Optional[str] = None,
5556
repository: Optional[str] = None,
5657
quiet: Optional[bool] = None,
@@ -161,6 +162,7 @@ def run(
161162

162163
def clone(
163164
self,
165+
*,
164166
url: str,
165167
no_update: Optional[str] = None,
166168
update_rev: Optional[str] = None,

libvcs/cmd/svn.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313

1414
class Svn:
15-
def __init__(self, dir: StrPath):
15+
def __init__(self, *, dir: StrPath):
1616
"""Lite, typed, pythonic wrapper for svn(1).
1717
1818
Parameters
@@ -38,6 +38,7 @@ def __repr__(self):
3838
def run(
3939
self,
4040
args: _CMD,
41+
*,
4142
quiet: Optional[bool] = None,
4243
username: Optional[str] = None,
4344
password: Optional[str] = None,
@@ -112,6 +113,7 @@ def run(
112113

113114
def checkout(
114115
self,
116+
*,
115117
url: str,
116118
revision: Union[RevisionLiteral, str] = None,
117119
force: Optional[bool] = None,
@@ -159,6 +161,7 @@ def checkout(
159161

160162
def add(
161163
self,
164+
*,
162165
path: Union[list[pathlib.Path], pathlib.Path],
163166
targets: Optional[pathlib.Path] = None,
164167
depth: DepthLiteral = None,
@@ -225,7 +228,6 @@ def auth(
225228
self,
226229
remove: Optional[str] = None,
227230
show_passwords: Optional[bool] = None,
228-
*args,
229231
**kwargs,
230232
):
231233
"""
@@ -244,7 +246,7 @@ def auth(
244246
>>> Svn(dir=tmp_path).auth()
245247
"Credentials cache in '...' is empty"
246248
"""
247-
local_flags: list[str] = [*args]
249+
local_flags: list[str] = []
248250

249251
if remove is not None:
250252
local_flags.extend(["--remove", remove])
@@ -256,14 +258,14 @@ def auth(
256258
def blame(
257259
self,
258260
target: pathlib.Path,
261+
*,
259262
revision: Union[RevisionLiteral, str] = None,
260263
verbose: Optional[bool] = None,
261264
force: Optional[bool] = None,
262265
use_merge_history: Optional[bool] = None,
263266
incremental: Optional[bool] = None,
264267
xml: Optional[bool] = None,
265268
extensions: Optional[str] = None,
266-
*args,
267269
**kwargs,
268270
):
269271
"""
@@ -304,7 +306,7 @@ def blame(
304306
>>> svn.blame('new.txt')
305307
'1 ... example text'
306308
"""
307-
local_flags: list[str] = [target, *args]
309+
local_flags: list[str] = [str(target)]
308310

309311
if revision is not None:
310312
local_flags.append(f"--revision={revision}")
@@ -361,6 +363,7 @@ def cleanup(self, *args, **kwargs):
361363

362364
def commit(
363365
self,
366+
*,
364367
path: Union[list[pathlib.Path], pathlib.Path],
365368
targets: Optional[pathlib.Path] = None,
366369
message: Optional[str] = None,
@@ -371,7 +374,6 @@ def commit(
371374
force_log: Optional[bool] = None,
372375
keep_changelists: Optional[bool] = None,
373376
include_externals: Optional[bool] = None,
374-
*args,
375377
**kwargs,
376378
):
377379
"""

0 commit comments

Comments
 (0)