Skip to content

Commit a45097a

Browse files
github-actions[bot]tobiasraabepre-commit-ci[bot]
authored
[automated] Update plugin list (#824)
Co-authored-by: Tobias Raabe <tobiasraabe@users.noreply.github.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Tobias Raabe <raabe@posteo.de>
1 parent df189d9 commit a45097a

4 files changed

Lines changed: 66 additions & 36 deletions

File tree

docs/source/plugin_list.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@ Packages classified as inactive are excluded.
55

66
!!! warning
77

8-
Please be aware that this list is not a curated collection of projects and does not
9-
undergo a systematic review process. It serves purely as an informational resource to
10-
aid in the discovery of `pytask` plugins.
8+
```
9+
Please be aware that this list is not a curated collection of projects and does not
10+
undergo a systematic review process. It serves purely as an informational resource
11+
to aid in the discovery of `pytask` plugins.
1112
12-
Do not presume any endorsement from the `pytask` project or its developers, and always
13-
conduct your own quality assessment before incorporating any of these plugins into your
14-
own projects.
13+
Do not presume any endorsement from the `pytask` project or its developers, and
14+
always conduct your own quality assessment before incorporating any of these plugins
15+
into your own projects.
16+
```
1517

1618
This list contains 6 plugins.
1719

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ docs = [
5757
"zensical>=0.0.23",
5858
]
5959
docs-live = ["sphinx-autobuild>=2024.10.3"]
60-
plugin-list = ["httpx>=0.27.0", "tabulate[widechars]>=0.9.0", "tqdm>=4.66.3"]
60+
plugin-list = ["httpx>=0.27.0", "tabulate[widechars]>=0.9.0"]
6161
test = [
6262
"cloudpickle>=3.0.0",
6363
"deepdiff>=7.0.0",

scripts/update_plugin_list.py

Lines changed: 49 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -37,27 +37,27 @@
3737

3838
import httpx
3939
import packaging.version
40-
import tabulate
4140
import wcwidth
42-
from tqdm import tqdm
4341

4442
if TYPE_CHECKING:
4543
from collections.abc import Generator
4644

4745
_FILE_HEAD = """# Plugin List
4846
49-
PyPI projects that match `pytask-*` are considered plugins and are listed
50-
automatically. Packages classified as inactive are excluded.
47+
PyPI projects that match `pytask-*` are considered plugins and are listed automatically.
48+
Packages classified as inactive are excluded.
5149
5250
!!! warning
5351
54-
Please be aware that this list is not a curated collection of projects and does not
55-
undergo a systematic review process. It serves purely as an informational resource
56-
to aid in the discovery of `pytask` plugins.
52+
```
53+
Please be aware that this list is not a curated collection of projects and does not
54+
undergo a systematic review process. It serves purely as an informational resource
55+
to aid in the discovery of `pytask` plugins.
5756
58-
Do not presume any endorsement from the `pytask` project or its developers, and
59-
always conduct your own quality assessment before incorporating any of these plugins
60-
into your own projects.
57+
Do not presume any endorsement from the `pytask` project or its developers, and
58+
always conduct your own quality assessment before incorporating any of these plugins
59+
into your own projects.
60+
```
6161
6262
"""
6363

@@ -86,6 +86,43 @@ def _escape_markdown(text: str) -> str:
8686
return text.replace("|", "\\|")
8787

8888

89+
def _pad(text: str, width: int) -> str:
90+
"""Pad text to the requested display width."""
91+
return text + " " * (width - wcwidth.wcswidth(text))
92+
93+
94+
def _create_table(entries: list[dict[str, str]]) -> str:
95+
"""Create a markdown table in the repository's canonical format."""
96+
if not entries:
97+
msg = "Cannot create a plugin table without entries."
98+
raise ValueError(msg)
99+
100+
headers = list(entries[0])
101+
widths = [
102+
max(
103+
wcwidth.wcswidth(header),
104+
*(wcwidth.wcswidth(row[header]) for row in entries),
105+
)
106+
for header in headers
107+
]
108+
109+
header_cells = (
110+
_pad(header, width) for header, width in zip(headers, widths, strict=False)
111+
)
112+
header = "| " + " | ".join(header_cells) + " |"
113+
separator = "| " + " | ".join("-" * width for width in widths) + " |"
114+
rows = [
115+
"| "
116+
+ " | ".join(
117+
_pad(row[header], width)
118+
for header, width in zip(headers, widths, strict=False)
119+
)
120+
+ " |"
121+
for row in entries
122+
]
123+
return "\n".join([header, separator, *rows])
124+
125+
89126
def _iter_plugins() -> Generator[dict[str, str], None, None]: # noqa: C901
90127
"""Iterate over all plugins and format entries."""
91128
regex = r">([\d\w-]*)</a>"
@@ -98,7 +135,7 @@ def _iter_plugins() -> Generator[dict[str, str], None, None]: # noqa: C901
98135
and match.groups()[0] not in _EXCLUDED_PACKAGES
99136
]
100137

101-
for match in tqdm(matches, smoothing=0):
138+
for match in matches:
102139
name = match.groups()[0]
103140
response = httpx.get(f"https://pypi.org/pypi/{name}/json", timeout=20)
104141
if response.status_code == 404: # noqa: PLR2004
@@ -168,10 +205,7 @@ def main() -> None:
168205
with plugin_list.open("w") as f:
169206
f.write(_FILE_HEAD)
170207
f.write(f"This list contains {len(plugins)} plugins.\n\n")
171-
172-
assert wcwidth # reference library that must exist for tabulate to work
173-
plugin_table = tabulate.tabulate(plugins, headers="keys", tablefmt="github")
174-
f.write(plugin_table)
208+
f.write(_create_table(plugins))
175209
f.write("\n")
176210

177211

0 commit comments

Comments
 (0)