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)
|
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}"
|
||||||
|
|
||||||
|
|
5
mypy.ini
5
mypy.ini
|
@ -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
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue