Skip to content

Commit f9c1f61

Browse files
committed
Fix flake8 failures with newer flake8 versions
1 parent eff92a2 commit f9c1f61

File tree

4 files changed

+18
-14
lines changed

4 files changed

+18
-14
lines changed

ocfweb/component/markdown.py

+11-11
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@
1212
from ocfweb.caching import cache
1313

1414
# tags of a format like: [[!meta title="Backups"]]
15-
META_REGEX = re.compile('\[\[!meta ([a-z]+)="([^"]*)"\]\]')
15+
META_REGEX = re.compile(r'\[\[!meta ([a-z]+)="([^"]*)"\]\]')
1616

1717

1818
class HtmlCommentsInlineLexerMixin:
1919
"""Strip HTML comments inside lines."""
2020

2121
def enable_html_comments(self):
2222
self.rules.html_comment = re.compile(
23-
'^<!--(.*?)-->',
23+
r'^<!--(.*?)-->',
2424
)
2525
self.default_rules.insert(0, 'html_comment')
2626

@@ -33,7 +33,7 @@ class HtmlCommentsBlockLexerMixin:
3333

3434
def enable_html_comments(self):
3535
self.rules.html_comment = re.compile(
36-
'^<!--(.*?)-->',
36+
r'^<!--(.*?)-->',
3737
)
3838
self.default_rules.insert(0, 'html_comment')
3939

@@ -74,16 +74,16 @@ class DjangoLinkInlineLexerMixin:
7474
[[human readable name|doc staff/backend/backups#something]]
7575
"""
7676

77-
split_words = re.compile('((?:\S|\\\\ )+)')
77+
split_words = re.compile(r'((?:\S|\\ )+)')
7878

7979
def enable_django_links(self):
8080
self.rules.django_link = re.compile(
81-
'^\[\[(?!\!)'
82-
'([\s\S]+?)'
83-
'\|'
84-
'([^#]+?)'
85-
'(?:#(.*?))?'
86-
'\]\]',
81+
r'^\[\[(?!\!)'
82+
r'([\s\S]+?)'
83+
r'\|'
84+
r'([^#]+?)'
85+
r'(?:#(.*?))?'
86+
r'\]\]',
8787
)
8888
self.default_rules.insert(0, 'django_link')
8989

@@ -141,7 +141,7 @@ def header(self, text, level, raw=None):
141141
else:
142142
id = 'h{level}_{title}'.format(
143143
level=level,
144-
title=re.sub('[^a-z0-9\-_ ]', '', strip_tags(text).lower()).strip().replace(' ', '-'),
144+
title=re.sub(r'[^a-z0-9\-_ ]', '', strip_tags(text).lower()).strip().replace(' ', '-'),
145145
)
146146

147147
# dumb collision avoidance

ocfweb/docs/urls.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def send_redirect(request, redir_src):
5757
def doc_name(doc_name):
5858
# we can't actually deal with escaping into a regex, so we just use a whitelist
5959
assert re.match(r'^/[a-zA-Z0-9\-/]+$', doc_name), 'Bad document name: ' + doc_name
60-
return doc_name[1:].replace('-', '\-')
60+
return doc_name[1:].replace('-', '\\-')
6161

6262

6363
doc_names = '|'.join(map(doc_name, DOCS.keys()))

ocfweb/main/hosting_logos.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def hosting_logo(request, image):
6060
student group websites."""
6161
# legacy images
6262
if image in LEGACY_IMAGES:
63-
return redirect('hosting-logo', re.sub('\.[a-z]+$', '.png', image), permanent=True)
63+
return redirect('hosting-logo', re.sub(r'\.[a-z]+$', '.png', image), permanent=True)
6464
elif image in REPLACED_IMAGES:
6565
return redirect('hosting-logo', REPLACED_IMAGES[image], permanent=True)
6666

tox.ini

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
[flake8]
22
max-line-length = 119
33
# flake8 complains about 'redefinition' of imported pytest fixtures
4-
ignore = F811
4+
# W503/W504 contradict each other, so we choose one to stick with
5+
#
6+
# We can't use default-ignore, since we still want to check against some of the
7+
# error checks that are ignored by default
8+
ignore = F811, W504
59

610
[pep8]
711
# autopep8 will rewrite lines to be shorter, even though we raised the length

0 commit comments

Comments
 (0)