Skip to content

Commit

Permalink
Fix types
Browse files Browse the repository at this point in the history
  • Loading branch information
Gerrit Vermeulen committed Sep 18, 2024
1 parent 7a22ab2 commit ff081c0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion home/import_assessments.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from openpyxl import load_workbook
from taggit.models import Tag # type: ignore
from treebeard.exceptions import NodeAlreadySaved # type: ignore
from wagtail.admin.panels import get_edit_handler
from wagtail.admin.panels import get_edit_handler # type: ignore
from wagtail.coreutils import get_content_languages # type: ignore
from wagtail.models import Locale, Page # type: ignore

Expand Down
17 changes: 10 additions & 7 deletions home/import_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,19 @@
from typing import Any

from django.core.exceptions import ValidationError # type: ignore
from django.forms import model_to_dict
from wagtail.admin.rich_text.converters.contentstate import ContentstateConverter
from django.db.models import Model # type: ignore
from django.forms import model_to_dict # type: ignore
from wagtail.admin.rich_text.converters.contentstate import (
ContentstateConverter, # type: ignore
)
from wagtail.blocks import ( # type: ignore
StreamBlockValidationError,
StreamValue,
StructValue, # type: ignore
)
from wagtail.blocks.list_block import ListValue
from wagtail.models import Locale
from wagtail.rich_text import RichText
from wagtail.blocks.list_block import ListValue # type: ignore
from wagtail.models import Locale # type: ignore
from wagtail.rich_text import RichText # type: ignore
from wagtail.test.utils.form_data import nested_form_data, streamfield # type: ignore


Expand Down Expand Up @@ -69,7 +72,7 @@ def wagtail_to_formdata(val: Any) -> Any:
return val


def validate_using_form(edit_handler, model, row_num):
def validate_using_form(edit_handler: Any, model: Model, row_num: int) -> None:
form_class = edit_handler.get_form_class()

form_data = nested_form_data(
Expand Down Expand Up @@ -123,7 +126,7 @@ def extract_errors(data: dict[str | int, Any] | list[str]) -> dict[str, str]:
elif isinstance(errors, StreamBlockValidationError):
json_data_errors = errors.as_json_data()
error_messages = []
error_message = "An unknown error occurred"
error_message = ["An unknown error occurred"]
if isinstance(json_data_errors["blockErrors"], dict):
error_level = list(json_data_errors["blockErrors"].keys())[0]

Expand Down

0 comments on commit ff081c0

Please sign in to comment.