Add linters configs

This commit is contained in:
2022-01-01 20:54:59 +03:00
parent 4a78d4f987
commit cbba30f2af
30 changed files with 580 additions and 298 deletions

View File

@@ -64,9 +64,13 @@ class AuthorAnnotation(ormar.Model):
id = ormar.Integer(primary_key=True, nullable=False)
author: Author = ormar.ForeignKey(Author, nullable=False, unique=True, related_name="annotations")
author: Author = ormar.ForeignKey(
Author, nullable=False, unique=True, related_name="annotations"
)
title: str = ormar.String(max_length=256, nullable=False, default="") # type: ignore
title: str = ormar.String(
max_length=256, nullable=False, default=""
) # type: ignore
text: str = ormar.Text(nullable=False, default="") # type: ignore
file: str = ormar.String(max_length=256, nullable=True) # type: ignore
@@ -89,7 +93,7 @@ class Sequence(ormar.Model):
class BookAuthors(ormar.Model):
class Meta(BaseMeta):
tablename = "book_authors"
id: int = ormar.Integer(primary_key=True, nullable=False) # type: ignore
@@ -103,7 +107,9 @@ class BookGenres(ormar.Model):
class BookSequences(ormar.Model):
class Meta(BaseMeta):
tablename = "book_sequences"
orders_by = ["position", ]
orders_by = [
"position",
]
id: int = ormar.Integer(primary_key=True, nullable=False) # type: ignore
@@ -113,7 +119,9 @@ class BookSequences(ormar.Model):
class Translation(ormar.Model):
class Meta(BaseMeta):
tablename = "translations"
orders_by = ["position", ]
orders_by = [
"position",
]
id: int = ormar.Integer(primary_key=True, nullable=False) # type: ignore
@@ -132,21 +140,27 @@ class Book(ormar.Model):
source: Source = ormar.ForeignKey(Source, nullable=False)
remote_id: int = ormar.Integer(minimum=0, nullable=False) # type: ignore
title: str = ormar.String(max_length=256, nullable=False, index=True) # type: ignore
title: str = ormar.String(
max_length=256, nullable=False, index=True
) # type: ignore
lang: str = ormar.String(max_length=3, nullable=False) # type: ignore
file_type: str = ormar.String(max_length=4, nullable=False) # type: ignore
uploaded: date = ormar.Date() # type: ignore
is_deleted: bool = ormar.Boolean(default=False, server_default=text("false"), nullable=False)
is_deleted: bool = ormar.Boolean(
default=False, server_default=text("false"), nullable=False
)
authors = ormar.ManyToMany(Author, through=BookAuthors)
translators = ormar.ManyToMany(Author, through=Translation, related_name="translated_books")
translators = ormar.ManyToMany(
Author, through=Translation, related_name="translated_books"
)
genres = ormar.ManyToMany(Genre, through=BookGenres)
sequences = ormar.ManyToMany(Sequence, through=BookSequences)
@ormar.property_field
def available_types(self) -> list[str]:
if self.file_type == 'fb2' and self.source.name == 'flibusta':
return ['fb2', 'fb2zip', 'epub', 'mobi']
if self.file_type == "fb2" and self.source.name == "flibusta":
return ["fb2", "fb2zip", "epub", "mobi"]
return [self.file_type]
@@ -161,8 +175,12 @@ class BookAnnotation(ormar.Model):
id = ormar.Integer(primary_key=True, nullable=False)
book: Book = ormar.ForeignKey(Book, nullable=False, unique=True, related_name="annotations")
book: Book = ormar.ForeignKey(
Book, nullable=False, unique=True, related_name="annotations"
)
title: str = ormar.String(max_length=256, nullable=False, default="") # type: ignore
title: str = ormar.String(
max_length=256, nullable=False, default=""
) # type: ignore
text: str = ormar.Text(nullable=False, default="") # type: ignore
file: str = ormar.String(max_length=256, nullable=True) # type: ignore