Skip to content

Commit

Permalink
flake8 fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
oliviacrain committed Oct 31, 2020
1 parent b15d6d3 commit 6ff2d7f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
9 changes: 7 additions & 2 deletions homu/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,12 @@

IGNORE_BLOCK_START = '<!-- homu-ignore:start -->'
IGNORE_BLOCK_END = '<!-- homu-ignore:end -->'
IGNORE_BLOCK_RE = re.compile(r'<!--\s*homu-ignore:start\s*-->.*<!--\s*homu-ignore:end\s*-->',
flags=re.MULTILINE|re.DOTALL|re.IGNORECASE)
IGNORE_BLOCK_RE = re.compile(
r'<!--\s*homu-ignore:start\s*-->'
r'.*'
r'<!--\s*homu-ignore:end\s*-->',
flags=re.MULTILINE | re.DOTALL | re.IGNORECASE
)

global_cfg = {}

Expand All @@ -54,6 +58,7 @@
def suppress_pings(text):
return re.sub(r'\B(@\S+)', r'`\g<1>`', text) # noqa


# Replace any text between IGNORE_BLOCK_START and IGNORE_BLOCK_END
# HTML comments with an empty string in merge commits
def suppress_ignore_block(text):
Expand Down
17 changes: 12 additions & 5 deletions homu/tests/test_pr_body.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
from homu.main import suppress_ignore_block, suppress_pings, IGNORE_BLOCK_START, IGNORE_BLOCK_END
from homu.main import (
suppress_ignore_block,
suppress_pings,
IGNORE_BLOCK_START,
IGNORE_BLOCK_END,
)


def test_suppress_pings_in_PR_body():
Expand All @@ -16,11 +21,13 @@ def test_suppress_pings_in_PR_body():

assert suppress_pings(body) == expect


def test_suppress_ignore_block_in_PR_body():
body = ("Rollup merge\n"
"{}\n"
"[Create a similar rollup](https://fake.xyz/?prs=1,2,3)\n"
"{}"
body = (
"Rollup merge\n"
"{}\n"
"[Create a similar rollup](https://fake.xyz/?prs=1,2,3)\n"
"{}"
)

body = body.format(IGNORE_BLOCK_START, IGNORE_BLOCK_END)
Expand Down

0 comments on commit 6ff2d7f

Please sign in to comment.