Skip to content

Commit aa1a1cb

Browse files
committed
Handle empty sequence in 'print_table'
1 parent 65e5b01 commit aa1a1cb

4 files changed

Lines changed: 8 additions & 8 deletions

File tree

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
## Unreleased
44

5+
### Fixed
6+
7+
* Handle empty sequence in 'print_table'
58

69
## 1.7.0 - 2025-09-01
710

qgis_plugin_manager/__main__.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ def outdated():
244244
("version", lambda n: str(n[0].version)),
245245
("latest", lambda n: n[1]),
246246
("folder", lambda n: n[0].install_folder),
247-
("source", lambda n: n[2])
247+
("source", lambda n: n[2]),
248248
),
249249
)
250250
else:
@@ -537,6 +537,7 @@ def plugin_versions_impl(args: Namespace):
537537

538538
versions = plugins.get(args.plugin_name)
539539
if versions:
540+
540541
def results() -> Iterator[Plugin]:
541542
for plugin in versions:
542543
if plugin.is_pre() and not args.pre:
@@ -637,11 +638,7 @@ def pred(p):
637638
return True
638639

639640
found = 0
640-
for name, version in remote.search(
641-
args.plugin_name,
642-
predicat=pred,
643-
latest=args.latest
644-
):
641+
for name, version in remote.search(args.plugin_name, predicat=pred, latest=args.latest):
645642
echo.echo(f"{name}=={version}")
646643
found += 1
647644
if not found:

qgis_plugin_manager/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ def getenv_bool(name: str) -> bool:
223223

224224
def print_table(seq: Sequence[T], columns: Sequence[Tuple[str, Callable[[T], str]]]):
225225
def colw(col: str, key: Callable[[T], str]) -> int:
226-
return max(max(len(key(n)) for n in seq), len(col))
226+
return max(max((len(key(n)) for n in seq), default=0), len(col))
227227

228228
cols = tuple((col, colw(col, key), key) for col, key in columns)
229229
echo.echo(" ".join("{:<{}}".format(col, w) for col, w, _ in cols))

tests/test_remote.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def test_search_with_space_in_name(fixtures: Path):
7676
]
7777

7878
# Test the search
79-
results = remote.search("lizmap", strict=False)
79+
results = remote.search("lizmap", strict=False)
8080
assert next(results)[0] == "Lizmap"
8181
assert next(results)[0] == "Lizmap server"
8282

0 commit comments

Comments
 (0)