Skip to content

Commit

Permalink
Lint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
andreymal committed Sep 10, 2023
1 parent 557e01f commit 870c9f3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions mini_fiction/logic/tags/private.py
Expand Up @@ -3,9 +3,9 @@
from dataclasses import dataclass
from datetime import datetime
from itertools import chain, islice
from typing import List, Optional, Tuple
from typing import List, Optional, Tuple, Union

from flask_babel import lazy_gettext
from flask_babel import LazyString, lazy_gettext
from pony import orm

from mini_fiction.logic.adminlog import log_changed_fields, log_changed_generic
Expand Down Expand Up @@ -179,7 +179,7 @@ def set_blacklist(tag: Tag, user: Optional[Author], reason: Optional[str]) -> No
log_changed_generic(by=user, what=tag, message=log_message)


def validate_tag_name(raw_tag_name: str) -> Optional[str]:
def validate_tag_name(raw_tag_name: str) -> Optional[Union[str, LazyString]]:
iname = normalize_tag(raw_tag_name)
if not iname:
return lazy_gettext("Empty tag")
Expand Down
12 changes: 6 additions & 6 deletions mini_fiction/logic/tags/public.py
Expand Up @@ -3,7 +3,7 @@
from operator import attrgetter
from typing import Collection, Dict, List, Literal, Optional, Tuple, Union

from flask_babel import lazy_gettext
from flask_babel import LazyString, lazy_gettext
from pony.orm import desc

from mini_fiction.logic.adminlog import log_addition, log_changed_fields, log_deletion
Expand Down Expand Up @@ -52,7 +52,7 @@ class TagsResponse:
"""Aliased tags that were replaced with canonical ones"""
blacklisted: List[Tag]
"""Blocked tags"""
invalid: List[Tuple[str, str]]
invalid: List[Tuple[str, Union[str, LazyString]]]
"""List of invalid tags alongside with reasons"""
created: List[Tag]
"""Created tags, if specified to do so"""
Expand All @@ -76,8 +76,8 @@ def get_tags_objects(
tags_db = {x.iname: x for x in tags if isinstance(x, Tag)}

# Ищем недостающие теги в базе
inames = [normalize_tag(x) for x in tags_search]
inames = [x for x in inames if x]
inames_opt = [normalize_tag(x) for x in tags_search]
inames = [x for x in inames_opt if x]
if inames:
# Алгоритм сравнения строк в БД может отличаться от такового в Python,
# из-за чего при запросе всех тегов одним запросом будет проблематично
Expand Down Expand Up @@ -177,12 +177,12 @@ def get_tags_objects(


def get_all_tags(*, sort: TagsSortType) -> List[Tag]:
field, reverse = TAG_SORTING[sort]
sorting_field, reverse = TAG_SORTING[sort]
return sorted(
Tag.select()
.filter(lambda x: not x.is_blacklisted and not x.is_alias)
.prefetch(Tag.category),
key=attrgetter(field),
key=attrgetter(sorting_field),
reverse=reverse,
)

Expand Down

0 comments on commit 870c9f3

Please sign in to comment.