style: code cleanups from Steven Burch (#29292)
* chore: update deprecated import from collections * chore: remove outdated imports from markdown library as it hasn't been supported since 2.0.3 and we're on 3.x. This was deprecated at least as early as 2012! * docs: add docstring and remove lint-amnesty to markdown plugin * chore: remove deprecated etree import * style: remove unnecessary-comprehension for sets * style: resolve a number of amnestied pylint complaints Co-authored-by: stvn <stvn@mit.edu>
This commit is contained in:
@@ -307,7 +307,7 @@ class AccountLegacyProfileSerializer(serializers.HyperlinkedModelSerializer, Rea
|
||||
"""
|
||||
Enforce all languages are unique.
|
||||
"""
|
||||
language_proficiencies = [language for language in value] # lint-amnesty, pylint: disable=unnecessary-comprehension
|
||||
language_proficiencies = list(value)
|
||||
unique_language_proficiencies = {language["code"] for language in language_proficiencies}
|
||||
if len(language_proficiencies) != len(unique_language_proficiencies):
|
||||
raise serializers.ValidationError("The language_proficiencies field must consist of unique languages.")
|
||||
@@ -317,7 +317,7 @@ class AccountLegacyProfileSerializer(serializers.HyperlinkedModelSerializer, Rea
|
||||
"""
|
||||
Enforce only one entry for a particular social platform.
|
||||
"""
|
||||
social_links = [social_link for social_link in value] # lint-amnesty, pylint: disable=unnecessary-comprehension
|
||||
social_links = list(value)
|
||||
unique_social_links = {social_link["platform"] for social_link in social_links}
|
||||
if len(social_links) != len(unique_social_links):
|
||||
raise serializers.ValidationError("The social_links field must consist of unique social platforms.")
|
||||
|
||||
@@ -152,10 +152,10 @@ class RetirementTestCase(TestCase):
|
||||
return [create_retirement_status(UserFactory(), state=state) for state in RetirementState.objects.all()]
|
||||
|
||||
def _get_non_dead_end_states(self):
|
||||
return [state for state in RetirementState.objects.filter(is_dead_end_state=False)] # lint-amnesty, pylint: disable=unnecessary-comprehension
|
||||
return RetirementState.objects.filter(is_dead_end_state=False)
|
||||
|
||||
def _get_dead_end_states(self):
|
||||
return [state for state in RetirementState.objects.filter(is_dead_end_state=True)] # lint-amnesty, pylint: disable=unnecessary-comprehension
|
||||
return RetirementState.objects.filter(is_dead_end_state=True)
|
||||
|
||||
|
||||
def fake_requested_retirement(user):
|
||||
|
||||
@@ -401,7 +401,7 @@ class EmailOptInListTest(ModuleStoreTestCase):
|
||||
try:
|
||||
with open(output_path) as output_file:
|
||||
reader = csv.DictReader(output_file, fieldnames=self.OUTPUT_FIELD_NAMES)
|
||||
rows = [row for row in reader] # lint-amnesty, pylint: disable=unnecessary-comprehension
|
||||
rows = list(reader)
|
||||
except OSError:
|
||||
self.fail(f"Could not find or open output file at '{output_path}'")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user