Fix 'W605 invalid escape sequence' errors from pycodestyle
This commit is contained in:
@@ -537,13 +537,13 @@ class EvaluatorTest(unittest.TestCase):
|
||||
"""
|
||||
variables = {'R1': 2.0, 'R3': 4.0}
|
||||
|
||||
with self.assertRaisesRegexp(calc.UndefinedVariable, 'QWSEKO'):
|
||||
with self.assertRaisesRegexp(calc.UndefinedVariable, r'QWSEKO'):
|
||||
calc.evaluator({}, {}, "5+7*QWSEKO")
|
||||
with self.assertRaisesRegexp(calc.UndefinedVariable, 'r2'):
|
||||
with self.assertRaisesRegexp(calc.UndefinedVariable, r'r2'):
|
||||
calc.evaluator({'r1': 5}, {}, "r1+r2")
|
||||
with self.assertRaisesRegexp(calc.UndefinedVariable, 'r1, r3'):
|
||||
with self.assertRaisesRegexp(calc.UndefinedVariable, r'r1, r3'):
|
||||
calc.evaluator(variables, {}, "r1*r3", case_sensitive=True)
|
||||
with self.assertRaisesRegexp(calc.UndefinedVariable, 'did you forget to use \*'):
|
||||
with self.assertRaisesRegexp(calc.UndefinedVariable, r'did you forget to use \*'):
|
||||
calc.evaluator(variables, {}, "R1(R3 + 1)")
|
||||
|
||||
def test_mismatched_parens(self):
|
||||
|
||||
@@ -647,7 +647,7 @@ class StringResponseTest(ResponseTest): # pylint: disable=missing-docstring
|
||||
for answer in answers:
|
||||
self.assert_grade(problem, answer, "correct")
|
||||
|
||||
problem = self.build_problem(answer="^(-\|){2,5}$", case_sensitive=False, regexp=True)
|
||||
problem = self.build_problem(answer=r"^(-\|){2,5}$", case_sensitive=False, regexp=True)
|
||||
self.assert_grade(problem, "-|-|-|", "correct")
|
||||
self.assert_grade(problem, "-|", "incorrect")
|
||||
self.assert_grade(problem, "-|-|-|-|-|-|", "incorrect")
|
||||
|
||||
@@ -1002,9 +1002,9 @@ class DiscussionEditorPreviewTest(UniqueCourseTest):
|
||||
appear in the preview box
|
||||
"""
|
||||
self.page.set_new_post_editor_value(
|
||||
'\\begin{equation}'
|
||||
'\\tau_g(\omega) = - \\frac{d}{d\omega}\phi(\omega) \hspace{2em} (1) '
|
||||
'\\end{equation}'
|
||||
r'\begin{equation}'
|
||||
r'\tau_g(\omega) = - \frac{d}{d\omega}\phi(\omega) \hspace{2em} (1) '
|
||||
r'\end{equation}'
|
||||
)
|
||||
self.assertIsNotNone(self.page.get_new_post_preview_text())
|
||||
self.page.click_element(".cancel")
|
||||
|
||||
@@ -41,7 +41,7 @@ class TestDumpToNeo4jCommandBase(SharedModuleStoreTestCase):
|
||||
"""
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
"""
|
||||
r"""
|
||||
Creates two courses; one that's just a course module, and one that
|
||||
looks like:
|
||||
course
|
||||
|
||||
@@ -82,7 +82,7 @@ def _get_username_from_social_link(platform_name, new_social_link):
|
||||
parse_result = urlparse(new_social_link)
|
||||
url_domain_and_path = parse_result[1] + parse_result[2]
|
||||
url_stub = re.escape(settings.SOCIAL_PLATFORMS[platform_name]['url_stub'])
|
||||
username_match = re.search('(www\.)?' + url_stub + '(?P<username>.*?)[/]?$', url_domain_and_path, re.IGNORECASE)
|
||||
username_match = re.search(r'(www\.)?' + url_stub + r'(?P<username>.*?)[/]?$', url_domain_and_path, re.IGNORECASE)
|
||||
if username_match:
|
||||
username = username_match.group('username')
|
||||
else:
|
||||
|
||||
@@ -173,7 +173,7 @@ class BaseLinter(object):
|
||||
"""
|
||||
if self.LINE_COMMENT_DELIM is not None:
|
||||
line_start_index = StringLines(template).index_to_line_start_index(start_index)
|
||||
uncommented_line_start_index_regex = re.compile("^(?!\s*{})".format(self.LINE_COMMENT_DELIM), re.MULTILINE)
|
||||
uncommented_line_start_index_regex = re.compile(r"^(?!\s*{})".format(self.LINE_COMMENT_DELIM), re.MULTILINE)
|
||||
# Finds the line start index of the first uncommented line, including the current line.
|
||||
match = uncommented_line_start_index_regex.search(template, line_start_index)
|
||||
if match is None:
|
||||
@@ -1160,8 +1160,8 @@ class MakoTemplateLinter(BaseLinter):
|
||||
# Dedent expression internals so it is parseable.
|
||||
# Note that the final columns reported could be off somewhat.
|
||||
adjusted_python_code = textwrap.dedent(python_code)
|
||||
first_letter_match = re.search('\w', python_code)
|
||||
adjusted_first_letter_match = re.search('\w', adjusted_python_code)
|
||||
first_letter_match = re.search(r'\w', python_code)
|
||||
adjusted_first_letter_match = re.search(r'\w', adjusted_python_code)
|
||||
if first_letter_match is not None and adjusted_first_letter_match is not None:
|
||||
start_offset += (first_letter_match.start() - adjusted_first_letter_match.start())
|
||||
python_code = adjusted_python_code
|
||||
|
||||
Reference in New Issue
Block a user