mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-22 09:31:08 +00:00
Adds type annotations for author model file
This commit is contained in:
parent
3555ef9d2e
commit
ef30c7cf65
2 changed files with 9 additions and 4 deletions
|
@ -53,22 +53,22 @@ class Author(BookDataModel):
|
|||
super().save(*args, **kwargs)
|
||||
|
||||
@property
|
||||
def isni_link(self):
|
||||
def isni_link(self) -> str:
|
||||
"""generate the url from the isni id"""
|
||||
clean_isni = re.sub(r"\s", "", self.isni)
|
||||
return f"https://isni.org/isni/{clean_isni}"
|
||||
|
||||
@property
|
||||
def openlibrary_link(self):
|
||||
def openlibrary_link(self) -> str:
|
||||
"""generate the url from the openlibrary id"""
|
||||
return f"https://openlibrary.org/authors/{self.openlibrary_key}"
|
||||
|
||||
@property
|
||||
def isfdb_link(self):
|
||||
def isfdb_link(self) -> str:
|
||||
"""generate the url from the isni id"""
|
||||
return f"https://www.isfdb.org/cgi-bin/ea.cgi?{self.isfdb}"
|
||||
|
||||
def get_remote_id(self):
|
||||
def get_remote_id(self) -> str:
|
||||
"""editions and works both use "book" instead of model_name"""
|
||||
return f"{BASE_URL}/author/{self.id}"
|
||||
|
||||
|
|
5
mypy.ini
5
mypy.ini
|
@ -13,6 +13,11 @@ implicit_reexport = True
|
|||
[mypy-bookwyrm.connectors.*]
|
||||
ignore_errors = False
|
||||
|
||||
[mypy-bookwyrm.models.author]
|
||||
ignore_errors = False
|
||||
allow_untyped_calls = True
|
||||
disable_error_code = import-untyped, assignment
|
||||
|
||||
[mypy-bookwyrm.utils.*]
|
||||
ignore_errors = False
|
||||
|
||||
|
|
Loading…
Reference in a new issue