Skip to content

Commit

Permalink
Mypy: removed type ignore at table_form()
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderWatzinger committed Feb 8, 2024
1 parent 68ce756 commit fea2a89
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
6 changes: 1 addition & 5 deletions openatlas/forms/form.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,8 @@ class Form(FlaskForm):
return Form()


def get_table_form(
classes: list[str],
excluded: list[int] | list[Entity]) -> str:
def get_table_form(classes: list[str], excluded: list[int]) -> str:
entities = Entity.get_by_class(classes, types=True, aliases=True)
if excluded and isinstance(excluded[0], Entity):
excluded = [entity.id for entity in excluded] # type: ignore
table = Table([''] + g.table_headers[classes[0]], order=[[2, 'asc']])
if (classes[0] == 'file' and
(g.settings['image_processing'] or g.settings['iiif'])
Expand Down
6 changes: 3 additions & 3 deletions openatlas/views/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
from werkzeug.wrappers import Response

from openatlas import app
from openatlas.display.util import check_iiif_file_exist, \
convert_image_to_iiif, required_group
from openatlas.display.util import (
check_iiif_file_exist, convert_image_to_iiif, required_group)
from openatlas.forms.form import get_table_form
from openatlas.models.entity import Entity

Expand Down Expand Up @@ -62,7 +62,7 @@ def file_add(id_: int, view: str) -> str | Response:
'content.html',
content=get_table_form(
g.view_class_mapping[view],
entity.get_linked_entities('P67')),
[e.id for e in entity.get_linked_entities('P67')]),
title=entity.name,
crumbs=[
[_(entity.class_.view), url_for('index', view=entity.class_.view)],
Expand Down
8 changes: 5 additions & 3 deletions openatlas/views/link.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ def link_insert(id_: int, view: str) -> str | Response:
excluded = entity.get_linked_entities(property_code, inverse=inverse)
return render_template(
'content.html',
content=get_table_form(g.view_class_mapping[view], excluded),
content=get_table_form(
g.view_class_mapping[view],
[e.id for e in excluded]),
title=_(entity.class_.view),
crumbs=[
[_(entity.class_.view), url_for('index', view=entity.class_.view)],
Expand Down Expand Up @@ -232,7 +234,7 @@ def entity_add_file(id_: int) -> str | Response:
'content.html',
content=get_table_form(
['file'],
entity.get_linked_entities('P67', inverse=True)),
[e.id for e in entity.get_linked_entities('P67', inverse=True)]),
entity=entity,
title=entity.name,
crumbs=[
Expand All @@ -256,7 +258,7 @@ def entity_add_source(id_: int) -> str | Response:
'content.html',
content=get_table_form(
['source'],
entity.get_linked_entities('P67', inverse=True)),
[e.id for e in entity.get_linked_entities('P67', inverse=True)]),
title=entity.name,
crumbs=[
[_(entity.class_.view), url_for('index', view=entity.class_.view)],
Expand Down

0 comments on commit fea2a89

Please sign in to comment.