fix: potentional iteration through None (#1043)

Signed-off-by: Vitalii Dmitriev <dmitvitalii@gmail.com>
This commit is contained in:
Vitalii Dmitriev 2023-10-25 12:21:46 +03:00 committed by GitHub
parent f89f47ebd3
commit 0f441198d8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 1 deletions

View File

@ -85,9 +85,10 @@ class AbstractPostForm(forms.ModelForm):
abstract = True
def clean_coauthors(self):
coauthors = [coauthor.replace("@", "", 1) for coauthor in self.cleaned_data.get("coauthors")]
coauthors = self.cleaned_data.get("coauthors")
if not coauthors:
return []
coauthors = [coauthor.replace("@", "", 1) for coauthor in coauthors]
seen = set()
duplicated_coauthors = [coauthor for coauthor in coauthors if coauthor in seen or seen.add(coauthor)]