fix: Fixed new pylint warnings (#28724)
This commit is contained in:
@@ -229,7 +229,7 @@ class TabsAPITests(CourseTestCase):
|
||||
@ddt.data(
|
||||
dict(is_hidden=None),
|
||||
dict(is_hidden="abc"),
|
||||
dict(),
|
||||
{},
|
||||
)
|
||||
def test_toggle_tab_invalid_visibility(self, invalid_visibility):
|
||||
"""
|
||||
|
||||
@@ -718,7 +718,7 @@ class CourseGradingTest(CourseTestCase):
|
||||
'event_transaction_id': 'mockUUID',
|
||||
'event_transaction_type': 'edx.grades.grading_policy_changed',
|
||||
}
|
||||
) for policy_hash in {grading_policy_2, grading_policy_3}
|
||||
) for policy_hash in [grading_policy_2, grading_policy_3]
|
||||
], any_order=True)
|
||||
|
||||
@mock.patch('common.djangoapps.track.event_transaction_utils.uuid4')
|
||||
|
||||
@@ -341,7 +341,7 @@ def _get_redirect_to(request_host, request_headers, request_params, request_is_h
|
||||
header_accept = request_headers.get('HTTP_ACCEPT', '')
|
||||
accepts_text_html = any(
|
||||
mime_type in header_accept
|
||||
for mime_type in {'*/*', 'text/*', 'text/html'}
|
||||
for mime_type in ['*/*', 'text/*', 'text/html']
|
||||
)
|
||||
|
||||
# If we get a redirect parameter, make sure it's safe i.e. not redirecting outside our domain.
|
||||
|
||||
@@ -656,7 +656,7 @@ class UserProfile(models.Model):
|
||||
def get_meta(self): # pylint: disable=missing-function-docstring
|
||||
js_str = self.meta
|
||||
if not js_str:
|
||||
js_str = dict()
|
||||
js_str = {}
|
||||
else:
|
||||
js_str = json.loads(self.meta)
|
||||
|
||||
|
||||
@@ -300,7 +300,7 @@ class StubEdxNotesService(StubHttpService):
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
self.notes = list()
|
||||
self.notes = []
|
||||
|
||||
def get_all_notes(self):
|
||||
"""
|
||||
@@ -348,7 +348,7 @@ class StubEdxNotesService(StubHttpService):
|
||||
"""
|
||||
Removes all notes to the stub EdxNotes service.
|
||||
"""
|
||||
self.notes = list()
|
||||
self.notes = []
|
||||
|
||||
def filter_by_id(self, data, note_id):
|
||||
"""
|
||||
|
||||
@@ -118,7 +118,7 @@ class StubHttpRequestHandler(BaseHTTPRequestHandler):
|
||||
}
|
||||
|
||||
except: # lint-amnesty, pylint: disable=bare-except
|
||||
return dict()
|
||||
return {}
|
||||
|
||||
@lazy
|
||||
def get_params(self):
|
||||
@@ -252,7 +252,7 @@ class StubHttpService(ThreadingMixIn, HTTPServer):
|
||||
HTTPServer.__init__(self, address, self.HANDLER_CLASS)
|
||||
|
||||
# Create a dict to store configuration values set by the client
|
||||
self.config = dict()
|
||||
self.config = {}
|
||||
|
||||
# Start the server in a separate thread
|
||||
server_thread = threading.Thread(target=self.serve_forever)
|
||||
|
||||
@@ -71,7 +71,7 @@ def _parse_config_args(args):
|
||||
|
||||
Returns a dictionary with the configuration keys and values.
|
||||
"""
|
||||
config_dict = dict()
|
||||
config_dict = {}
|
||||
for config_str in args:
|
||||
try:
|
||||
components = config_str.split('=')
|
||||
|
||||
@@ -41,7 +41,7 @@ class StubYouTubeHandler(StubHttpRequestHandler):
|
||||
Allow callers to delete all the server configurations using the /del_config URL.
|
||||
"""
|
||||
if self.path == "/del_config" or self.path == "/del_config/":
|
||||
self.server.config = dict()
|
||||
self.server.config = {}
|
||||
self.log_message("Reset Server Configuration.")
|
||||
self.send_response(200)
|
||||
else:
|
||||
|
||||
@@ -40,7 +40,7 @@ class ThirdPartyAuthPermissionTest(TestCase):
|
||||
|
||||
def _create_request(self, auth_header=None):
|
||||
url = '/'
|
||||
extra = dict(HTTP_AUTHORIZATION=auth_header) if auth_header else dict()
|
||||
extra = dict(HTTP_AUTHORIZATION=auth_header) if auth_header else {}
|
||||
return RequestFactory().get(url, **extra)
|
||||
|
||||
def _create_session(self, request, user):
|
||||
|
||||
@@ -219,7 +219,7 @@ class EventTransformer(dict):
|
||||
|
||||
def load_payload(self):
|
||||
"""
|
||||
Create a data version of self[u'event'] at self.event
|
||||
Create a data version of self['event'] at self.event
|
||||
"""
|
||||
if 'event' in self:
|
||||
if isinstance(self['event'], str):
|
||||
@@ -229,7 +229,7 @@ class EventTransformer(dict):
|
||||
|
||||
def dump_payload(self):
|
||||
"""
|
||||
Write self.event back to self[u'event'].
|
||||
Write self.event back to self['event'].
|
||||
|
||||
Keep the same format we were originally given.
|
||||
"""
|
||||
|
||||
@@ -68,7 +68,7 @@ class PasswordPolicyValidatorsTestCase(unittest.TestCase):
|
||||
assert len(not_normalized_password) == 3
|
||||
|
||||
# When we normalize we expect the not_normalized password to fail
|
||||
# because it should be normalized to u'\u1E69' -> ṩ
|
||||
# because it should be normalized to '\u1E69' -> ṩ
|
||||
self.validation_errors_checker(not_normalized_password,
|
||||
'This password is too short. It must contain at least 2 characters.')
|
||||
|
||||
|
||||
@@ -42,4 +42,4 @@ class XBlockCacheFactory(DjangoModelFactory):
|
||||
course_key = COURSE_KEY
|
||||
usage_key = factory.Sequence('4x://edx/100/block/{}'.format)
|
||||
display_name = ''
|
||||
paths = list()
|
||||
paths = []
|
||||
|
||||
@@ -593,7 +593,7 @@ def get_course_run_details(course_run_key, fields):
|
||||
Returns:
|
||||
dict with language, start date, end date, and max_effort details about specified course run
|
||||
"""
|
||||
course_run_details = dict()
|
||||
course_run_details = {}
|
||||
user, catalog_integration = check_catalog_integration_and_get_user(
|
||||
error_message_field=f'Data for course_run {course_run_key}'
|
||||
)
|
||||
|
||||
@@ -348,7 +348,7 @@ def _get_user_course_outline_and_processors(course_key: CourseKey, # lint-amnes
|
||||
|
||||
# Run each OutlineProcessor in order to figure out what items we have to
|
||||
# remove from the CourseOutline.
|
||||
processors = dict()
|
||||
processors = {}
|
||||
usage_keys_to_remove = set()
|
||||
inaccessible_sequences = set()
|
||||
for name, processor_cls in processor_classes:
|
||||
|
||||
@@ -101,7 +101,7 @@ class CourseAccessMessageView(View):
|
||||
embargo.messages.BlockedMessage or None
|
||||
|
||||
"""
|
||||
message_dict = dict()
|
||||
message_dict = {}
|
||||
|
||||
# The access point determines which set of messages to use.
|
||||
# This allows us to show different messages to students who
|
||||
|
||||
@@ -89,7 +89,7 @@ def get_all_theme_template_dirs():
|
||||
(list): list of directories containing theme templates.
|
||||
"""
|
||||
themes = get_themes()
|
||||
template_paths = list()
|
||||
template_paths = []
|
||||
|
||||
for theme in themes:
|
||||
template_paths.extend(theme.template_dirs)
|
||||
|
||||
@@ -88,7 +88,7 @@ def delete_rows(model_mgr,
|
||||
try:
|
||||
list(model_mgr.raw(delete_sql))
|
||||
except TypeError:
|
||||
# The list() above is simply to get the RawQuerySet to be evaluated.
|
||||
# The [] above is simply to get the RawQuerySet to be evaluated.
|
||||
# Without evaluation, the raw DELETE SQL will *not* actually execute.
|
||||
# But - it will cause a "TypeError: 'NoneType' object is not iterable" to be ignored.
|
||||
pass
|
||||
|
||||
@@ -209,7 +209,7 @@ class LtiCourseTab(LtiCourseLaunchMixin, EnrolledTab):
|
||||
self.lti_config_id = tab_dict.get('lti_config_id') if tab_dict else lti_config_id
|
||||
|
||||
if tab_dict is None:
|
||||
tab_dict = dict()
|
||||
tab_dict = {}
|
||||
|
||||
if name is not None:
|
||||
tab_dict['name'] = name
|
||||
|
||||
@@ -114,7 +114,7 @@ def get_sass_directories(system, theme_dir=None):
|
||||
)
|
||||
system = SYSTEMS[system]
|
||||
|
||||
applicable_directories = list()
|
||||
applicable_directories = []
|
||||
|
||||
if theme_dir:
|
||||
# Add theme sass directories
|
||||
@@ -141,7 +141,7 @@ def get_common_sass_directories():
|
||||
"lookup_paths": [], # list of directories to be passed as lookup paths for @import resolution.
|
||||
}
|
||||
"""
|
||||
applicable_directories = list()
|
||||
applicable_directories = []
|
||||
|
||||
# add common sass directories
|
||||
applicable_directories.append({
|
||||
|
||||
@@ -135,7 +135,7 @@ def i18n_validate_transifex_config():
|
||||
home = path('~').expanduser()
|
||||
config = home / '.transifexrc'
|
||||
|
||||
if not config.isfile or config.getsize == 0:
|
||||
if not config.isfile or config.getsize == 0: # pylint: disable=comparison-with-callable
|
||||
msg = colorize(
|
||||
'red',
|
||||
"Cannot connect to Transifex, config file is missing"
|
||||
|
||||
@@ -331,7 +331,7 @@ class Env:
|
||||
"at '{path}'".format(path=env_path),
|
||||
file=sys.stderr,
|
||||
)
|
||||
return dict()
|
||||
return {}
|
||||
|
||||
# Otherwise, load the file as JSON and return the resulting dict
|
||||
try:
|
||||
@@ -351,7 +351,7 @@ class Env:
|
||||
"""
|
||||
Return a dictionary of feature flags configured by the environment.
|
||||
"""
|
||||
return self.env_tokens.get('FEATURES', dict())
|
||||
return self.env_tokens.get('FEATURES', {})
|
||||
|
||||
@classmethod
|
||||
def rsync_dirs(cls):
|
||||
|
||||
Reference in New Issue
Block a user