Skip to content

Commit

Permalink
fix return
Browse files Browse the repository at this point in the history
  • Loading branch information
YairGlik committed Jun 2, 2024
1 parent 4c74bde commit 2e3f72e
Showing 1 changed file with 6 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,23 @@ class FileNameHasSeparatorsValidator(BaseValidator[ContentTypes]):
error_message = "The {0} files {1} should be named {2}, respectively, without any separators in the base name."
related_field = "file path"
is_auto_fixable = False
invalid_files: List[str] = []
valid_files: List[str] = []

def is_valid(self, content_items: Iterable[ContentTypes]) -> List[ValidationResult]:
return [
ValidationResult(
validator=self,
message=self.error_message.format(
content_item.content_type,
" and ".join([f"'{word}'" for word in self.invalid_files]),
" and ".join([f"'{word}'" for word in self.valid_files]),
" and ".join([f"'{word}'" for word in files_name[0]]),
" and ".join([f"'{word}'" for word in files_name[1]]),
),
content_object=content_item,
)
for content_item in content_items
if (self.check_separators_in_files(content_item))
if bool(files_name:= self.check_separators_in_files(content_item))
]

def check_separators_in_files(self, content_item: ContentTypes) -> bool:
def check_separators_in_files(self, content_item: ContentTypes) -> tuple:
"""
Check if there are separators in the file names of the content item.
Expand Down Expand Up @@ -84,11 +82,9 @@ def check_separators_in_files(self, content_item: ContentTypes) -> bool:
valid_files.append(valid_base_name.join(file_name.rsplit(base_name, 1)))

if invalid_files:
self.invalid_files = invalid_files
self.valid_files = valid_files
return True
return (invalid_files, valid_files)

return False
return ()

def remove_separators_from_name(self, base_name: str) -> str:
"""
Expand Down

0 comments on commit 2e3f72e

Please sign in to comment.