Merge pull request #19208 from edx/nedbat/fix-pycodestyle

Fix pycodestyle violations
This commit is contained in:
Ned Batchelder
2018-11-02 10:06:04 -04:00
committed by GitHub
8 changed files with 16 additions and 16 deletions

View File

@@ -182,7 +182,7 @@ class CourseRunRerunSerializer(CourseRunSerializerCommonFieldsMixin, CourseRunTe
}
fields.update(validated_data)
new_course_run_key = rerun_course(user, course_run_key, course_run_key.org, course_run_key.course, _id['run'],
fields, async=False)
fields, background=False)
course_run = get_course_and_check_access(new_course_run_key, user)
self.update_team(course_run, team)

View File

@@ -893,7 +893,7 @@ def create_new_course_in_store(store, user, org, number, run, fields):
return new_course
def rerun_course(user, source_course_key, org, number, run, fields, async=True):
def rerun_course(user, source_course_key, org, number, run, fields, background=True):
"""
Rerun an existing course.
"""
@@ -926,7 +926,7 @@ def rerun_course(user, source_course_key, org, number, run, fields, async=True):
json_fields = json.dumps(fields, cls=EdxJSONEncoder)
args = [unicode(source_course_key), unicode(destination_course_key), user.id, json_fields]
if async:
if background:
rerun_course_task.delay(*args)
else:
rerun_course_task(*args)

View File

@@ -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):

View File

@@ -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")

View File

@@ -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")

View File

@@ -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

View File

@@ -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:

View File

@@ -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