Skip to content

Commit 65ba4e8

Browse files
committed
Sanitize MD and initiate addition of tests
dependabot sends PRs with `[]()` in the title eg [gh-actions](deps): Bump actions/setup-python from 4 to 5 making it not legitimate markdown - [[gh-actions](deps): Bump actions/setup-python from 4 to 5](dandi/zarr_checksum#42) (253 days) so with this change we just remove any of the [] symbols, making it a legit - [gh-actions(deps): Bump actions/setup-python from 4 to 5](dandi/zarr_checksum#42) (253 days)
1 parent 2544c56 commit 65ba4e8

File tree

5 files changed

+23
-2
lines changed

5 files changed

+23
-2
lines changed

setup.cfg

+6
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@ install_requires =
4141
PyGithub ~= 2.0
4242
ruamel.yaml ~= 0.15
4343

44+
[options.extras_require]
45+
test =
46+
mypy
47+
pytest
48+
pytest-cov
49+
4450
[options.packages.find]
4551
where = src
4652

src/solidation/__main__.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ def to_markdown(self) -> str:
250250
if user is None:
251251
user = i.user.login
252252
s += (
253-
f"- [{i.title}]({i.html_url}) by {user}"
253+
f"- [{sanitize_md(i.title)}]({i.html_url}) by {user}"
254254
f" [{i.repository.full_name}]\n"
255255
)
256256

@@ -437,6 +437,11 @@ def ensure_aware(dt: datetime) -> datetime:
437437
return dt.replace(tzinfo=timezone.utc) if dt.tzinfo is None else dt
438438

439439

440+
def sanitize_md(s: str) -> str:
441+
# Remove `[]` symbols to ensure correct markdown in the references
442+
return re.sub(r'[\[\]]', '', s)
443+
444+
440445
@click.command()
441446
@click.option(
442447
"-c",

src/solidation/tests/__init__.py

Whitespace-only changes.

src/solidation/tests/test_main.py

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from ..__main__ import sanitize_md
2+
3+
4+
def test_sanitize_md() -> None:
5+
assert sanitize_md("[gh-actions](deps): Bump") == "gh-actions(deps): Bump"

tox.ini

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
[tox]
2-
envlist = lint,typing
2+
envlist = lint,typing,py3
33
isolated_build = True
44
minversion = 3.3.0
55

6+
[testenv]
7+
extras = test
8+
commands =
9+
python -m pytest -v {posargs} src
10+
611
[testenv:lint]
712
skip_install = True
813
deps =

0 commit comments

Comments
 (0)