Skip to content

Commit a71de72

Browse files
committed
Remove deprecated Remote.ls_remotes(...)
Use Remote.list_heads(...) instead Assisted-by: Kimi-k2.7
1 parent 28b4342 commit a71de72

5 files changed

Lines changed: 18 additions & 78 deletions

File tree

AGENTS.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,7 @@ modules:
5656
`repository.py`, `callbacks.py`, `config.py`, `index.py`, `remotes.py`,
5757
`settings.py`, `submodules.py`, `transaction.py`, `filter.py`, `blob.py`,
5858
`blame.py`, `branches.py`, `credentials.py`, `errors.py`, `options.py`,
59-
`packbuilder.py`, `references.py`, `refspec.py`, `utils.py`, `enums.py`,
60-
`legacyenums.py`.
59+
`packbuilder.py`, `references.py`, `refspec.py`, `utils.py`, `enums.py`.
6160

6261
- **`test/`** — pytest suite with fixture-based repository handling.
6362
- **`docs/`** — Sphinx documentation (RTD theme).
@@ -167,6 +166,9 @@ make -C docs html # requires sphinx-rtd-theme
167166
- Target Python: 3.11+
168167
- Quote style: single quotes
169168
- Selected rules: `E4`, `E7`, `E9`, `F`, `I`, `UP035`, `UP007`
169+
- Run `ruff format` and `ruff check` on changed files before committing.
170+
CI runs `ruff format --diff` and `ruff check`; formatting failures will
171+
fail the build.
170172
- **Type checker**: mypy (strict settings enabled; see `mypy.ini`)
171173
- All Python source files must include the standard GPLv2 copyright header.
172174
- `pygit2/__init__.py` is large because it re-exports a large surface of
@@ -275,5 +277,6 @@ and skips `*musllinux_ppc64le` plus testing on `*-*linux_ppc64le` and
275277
extension. Keep it in sync when adding or changing low-level APIs.
276278
- **Header stub order matters**: `pygit2/_run.py` concatenates `decl/*.h` in a
277279
fixed list; add new stubs in the correct position if dependencies require it.
278-
- Run the full test suite and type checks before considering a change complete:
279-
`sh build.sh test` and `sh build.sh mypy`.
280+
- Run the full test suite, type checks, and linting/formatting before
281+
considering a change complete:
282+
`sh build.sh test`, `sh build.sh mypy`, `ruff check .`, and `ruff format .`.

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ Breaking changes:
1515
by default. The previous string-returning behavior is still available
1616
with `use_deprecated=True`, but is deprecated.
1717

18+
- Remove deprecated `Remote.ls_remotes(...)`, use `Remote.list_heads(...)`
19+
instead
20+
1821

1922
# 1.19.3 (2026-06-13)
2023

pygit2/remotes.py

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525

2626
from __future__ import annotations
2727

28-
import warnings
2928
from collections.abc import Generator, Iterator
3029
from typing import TYPE_CHECKING, Any, Literal
3130

@@ -281,30 +280,6 @@ def list_heads(
281280

282281
return results
283282

284-
def ls_remotes(
285-
self,
286-
callbacks: RemoteCallbacks | None = None,
287-
proxy: str | None | bool = None,
288-
connect: bool = True,
289-
) -> list[dict[str, Any]]:
290-
"""
291-
Deprecated interface to list_heads
292-
"""
293-
warnings.warn('Use list_heads', DeprecationWarning)
294-
295-
heads = self.list_heads(callbacks, proxy, connect)
296-
297-
return [
298-
{
299-
'local': h.local,
300-
'oid': h.oid,
301-
'loid': h.loid if h.local else None,
302-
'name': h.name,
303-
'symref_target': h.symref_target,
304-
}
305-
for h in heads
306-
]
307-
308283
def prune(self, callbacks: RemoteCallbacks | None = None) -> None:
309284
"""Perform a prune against this remote."""
310285
with git_remote_callbacks(callbacks) as payload:

test/test_remote.py

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -204,31 +204,6 @@ def test_list_heads(testrepo: Repository) -> None:
204204
assert next(iter(r for r in refs if r.name == 'refs/tags/v0.28.2'))
205205

206206

207-
@utils.requires_network
208-
def test_ls_remotes_deprecated(testrepo: Repository) -> None:
209-
assert 1 == len(testrepo.remotes)
210-
remote = testrepo.remotes[0]
211-
212-
new_refs = remote.list_heads()
213-
214-
with pytest.warns(DeprecationWarning, match='Use list_heads'):
215-
old_refs = remote.ls_remotes()
216-
217-
assert new_refs
218-
assert old_refs
219-
220-
for new, old in zip(new_refs, old_refs, strict=True):
221-
assert new.name == old['name']
222-
assert new.oid == old['oid']
223-
assert new.local == old['local']
224-
assert new.symref_target == old['symref_target']
225-
if new.local:
226-
assert new.loid == old['loid']
227-
else:
228-
assert new.loid == pygit2.Oid(b'')
229-
assert old['loid'] is None
230-
231-
232207
@utils.requires_network
233208
def test_list_heads_without_implicit_connect(testrepo: Repository) -> None:
234209
assert 1 == len(testrepo.remotes)

test/test_repository.py

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1142,17 +1142,13 @@ def get_hello_txt_from_repo() -> str:
11421142
return blob.data.decode()
11431143

11441144
# no change
1145-
res = testrepo.merge_file_from_index(
1146-
hello_txt, hello_txt, hello_txt
1147-
)
1145+
res = testrepo.merge_file_from_index(hello_txt, hello_txt, hello_txt)
11481146
assert res == MergeFileResult(
11491147
True, hello_txt.path, hello_txt.mode, get_hello_txt_from_repo()
11501148
)
11511149

11521150
# executable switch on ours
1153-
res = testrepo.merge_file_from_index(
1154-
hello_txt, hello_txt_executable, hello_txt
1155-
)
1151+
res = testrepo.merge_file_from_index(hello_txt, hello_txt_executable, hello_txt)
11561152
assert res == MergeFileResult(
11571153
True,
11581154
hello_txt.path,
@@ -1161,9 +1157,7 @@ def get_hello_txt_from_repo() -> str:
11611157
)
11621158

11631159
# executable switch on theirs
1164-
res = testrepo.merge_file_from_index(
1165-
hello_txt, hello_txt, hello_txt_executable
1166-
)
1160+
res = testrepo.merge_file_from_index(hello_txt, hello_txt, hello_txt_executable)
11671161
assert res == MergeFileResult(
11681162
True,
11691163
hello_txt.path,
@@ -1183,31 +1177,23 @@ def get_hello_txt_from_repo() -> str:
11831177
)
11841178

11851179
# path switch on ours
1186-
res = testrepo.merge_file_from_index(
1187-
hello_txt, hello_world, hello_txt
1188-
)
1180+
res = testrepo.merge_file_from_index(hello_txt, hello_world, hello_txt)
11891181
assert res == MergeFileResult(
11901182
True, hello_world.path, hello_txt.mode, get_hello_txt_from_repo()
11911183
)
11921184

11931185
# path switch on theirs
1194-
res = testrepo.merge_file_from_index(
1195-
hello_txt, hello_txt, hello_world
1196-
)
1186+
res = testrepo.merge_file_from_index(hello_txt, hello_txt, hello_world)
11971187
assert res == MergeFileResult(
11981188
True, hello_world.path, hello_txt.mode, get_hello_txt_from_repo()
11991189
)
12001190

12011191
# path switch on both
1202-
res = testrepo.merge_file_from_index(
1203-
hello_txt, hello_world, hello_world
1204-
)
1192+
res = testrepo.merge_file_from_index(hello_txt, hello_world, hello_world)
12051193
assert res == MergeFileResult(True, None, hello_txt.mode, get_hello_txt_from_repo())
12061194

12071195
# path switch on ours, executable flag switch on theirs
1208-
res = testrepo.merge_file_from_index(
1209-
hello_txt, hello_world, hello_txt_executable
1210-
)
1196+
res = testrepo.merge_file_from_index(hello_txt, hello_world, hello_txt_executable)
12111197
assert res == MergeFileResult(
12121198
True,
12131199
hello_world.path,
@@ -1216,9 +1202,7 @@ def get_hello_txt_from_repo() -> str:
12161202
)
12171203

12181204
# path switch on theirs, executable flag switch on ours
1219-
res = testrepo.merge_file_from_index(
1220-
hello_txt, hello_txt_executable, hello_world
1221-
)
1205+
res = testrepo.merge_file_from_index(hello_txt, hello_txt_executable, hello_world)
12221206
assert res == MergeFileResult(
12231207
True,
12241208
hello_world.path,

0 commit comments

Comments
 (0)