Adds type annotations for author model file

This commit is contained in:
Mouse Reeve 2024-08-27 16:10:39 -07:00
parent 3555ef9d2e
commit ef30c7cf65
2 changed files with 9 additions and 4 deletions

View file

@ -53,22 +53,22 @@ class Author(BookDataModel):
super().save(*args, **kwargs) super().save(*args, **kwargs)
@property @property
def isni_link(self): def isni_link(self) -> str:
"""generate the url from the isni id""" """generate the url from the isni id"""
clean_isni = re.sub(r"\s", "", self.isni) clean_isni = re.sub(r"\s", "", self.isni)
return f"https://isni.org/isni/{clean_isni}" return f"https://isni.org/isni/{clean_isni}"
@property @property
def openlibrary_link(self): def openlibrary_link(self) -> str:
"""generate the url from the openlibrary id""" """generate the url from the openlibrary id"""
return f"https://openlibrary.org/authors/{self.openlibrary_key}" return f"https://openlibrary.org/authors/{self.openlibrary_key}"
@property @property
def isfdb_link(self): def isfdb_link(self) -> str:
"""generate the url from the isni id""" """generate the url from the isni id"""
return f"https://www.isfdb.org/cgi-bin/ea.cgi?{self.isfdb}" 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""" """editions and works both use "book" instead of model_name"""
return f"{BASE_URL}/author/{self.id}" return f"{BASE_URL}/author/{self.id}"

View file

@ -13,6 +13,11 @@ implicit_reexport = True
[mypy-bookwyrm.connectors.*] [mypy-bookwyrm.connectors.*]
ignore_errors = False ignore_errors = False
[mypy-bookwyrm.models.author]
ignore_errors = False
allow_untyped_calls = True
disable_error_code = import-untyped, assignment
[mypy-bookwyrm.utils.*] [mypy-bookwyrm.utils.*]
ignore_errors = False ignore_errors = False