Skip to content

Commit

Permalink
Sanitize MD and initiate addition of tests
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
yarikoptic committed Aug 21, 2024
1 parent 2544c56 commit 65ba4e8
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 2 deletions.
6 changes: 6 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ install_requires =
PyGithub ~= 2.0
ruamel.yaml ~= 0.15

[options.extras_require]
test =
mypy
pytest
pytest-cov

[options.packages.find]
where = src

Expand Down
7 changes: 6 additions & 1 deletion src/solidation/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ def to_markdown(self) -> str:
if user is None:
user = i.user.login
s += (
f"- [{i.title}]({i.html_url}) by {user}"
f"- [{sanitize_md(i.title)}]({i.html_url}) by {user}"
f" [{i.repository.full_name}]\n"
)

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


def sanitize_md(s: str) -> str:
# Remove `[]` symbols to ensure correct markdown in the references
return re.sub(r'[\[\]]', '', s)


@click.command()
@click.option(
"-c",
Expand Down
Empty file.
5 changes: 5 additions & 0 deletions src/solidation/tests/test_main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from ..__main__ import sanitize_md


def test_sanitize_md() -> None:
assert sanitize_md("[gh-actions](deps): Bump") == "gh-actions(deps): Bump"
7 changes: 6 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
[tox]
envlist = lint,typing
envlist = lint,typing,py3
isolated_build = True
minversion = 3.3.0

[testenv]
extras = test
commands =
python -m pytest -v {posargs} src

[testenv:lint]
skip_install = True
deps =
Expand Down

0 comments on commit 65ba4e8

Please sign in to comment.