Skip to content

Commit 8ae3045

Browse files
committed
Silence Python warnings about invalid backslashes.
This patch fixes the following warnings: /home/collin/.local/src/redis-docs/build/components/component.py:464: SyntaxWarning: invalid escape sequence '\.' f'find {self._content} -regex ".*\.md"').strip().split('\n') /home/collin/.local/src/redis-docs/build/components/markdown.py:250: SyntaxWarning: invalid escape sequence '\[' self.payload = re.sub(f'(\[.+?\])(\(.+?\))', rep, self.payload) /home/collin/.local/src/redis-docs/build/components/example.py:17: SyntaxWarning: invalid escape sequence '\[' 'c#': '\[Fact\]|\[SkipIfRedis\(.*\)\]' The first one should be marked raw since we want the '\' to be passed to the shell. The others are not needed. Using "\]" is only required when trying to match the literal ']' in a set of characers.
1 parent 6b69025 commit 8ae3045

File tree

3 files changed

+4
-5
lines changed

3 files changed

+4
-5
lines changed

build/components/component.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ def _process_module_docs(self, files: list) -> None:
461461
md.persist()
462462

463463
files = run(
464-
f'find {self._content} -regex ".*\.md"').strip().split('\n')
464+
fr'find {self._content} -regex ".*\.md"').strip().split('\n')
465465
for f in files:
466466
md = Markdown(f)
467467
t = md.fm_data.pop('type', None)

build/components/example.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
'java-sync': '@Test',
1515
'java-async': '@Test',
1616
'java-reactive': '@Test',
17-
'c#': '\[Fact\]|\[SkipIfRedis\(.*\)\]'
17+
'c#': r'\[Fact]|\[SkipIfRedis\(.*\)]'
1818
}
1919
PREFIXES = {
2020
'python': '#',

build/components/markdown.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,8 @@ def add_github_metadata(self, github_repo: str, github_branch: str, github_path:
7777
self.fm_data['github_path'] = github_path
7878

7979
def report_links(self) -> None:
80-
links = re.findall(r'(\[.+\])(\(.+\))', self.payload)
8180
exc = ['./', '#', '/commands', '/community', '/docs', '/topics']
82-
for link in links:
81+
for link in re.finditer(r'(\[.+])(\(.+\))', self.payload):
8382
ex = False
8483
for e in exc:
8584
if link[1].startswith(f'({e}'):
@@ -247,4 +246,4 @@ def rep(x):
247246
return r
248247
else:
249248
return x.group(0)
250-
self.payload = re.sub(f'(\[.+?\])(\(.+?\))', rep, self.payload)
249+
self.payload = re.sub(r'(\[.+])(\(.+\))', rep, self.payload)

0 commit comments

Comments
 (0)