Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix django-stubs-ext missing breaking a production setup #2110

Merged
merged 5 commits into from
Feb 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion evap/evaluation/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@
from django.utils.translation import gettext_lazy as _
from django_fsm import FSMIntegerField, transition
from django_fsm.signals import post_transition
from django_stubs_ext import StrOrPromise

from evap.evaluation.models_logging import FieldAction, LoggedModel
from evap.evaluation.tools import (
StrOrPromise,
clean_email,
date_to_datetime,
is_external_email,
Expand Down
11 changes: 9 additions & 2 deletions evap/evaluation/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from abc import ABC, abstractmethod
from collections import defaultdict
from collections.abc import Iterable, Mapping
from typing import Any, Protocol, TypeVar
from typing import TYPE_CHECKING, Any, Protocol, TypeVar
from urllib.parse import quote

import xlwt
Expand All @@ -16,7 +16,14 @@
from django.utils.datastructures import MultiValueDict
from django.utils.translation import get_language
from django.views.generic import FormView
from django_stubs_ext import StrOrPromise

if TYPE_CHECKING:
from django_stubs_ext import StrOrPromise # use proper definition with mypy

Check warning on line 21 in evap/evaluation/tools.py

View check run for this annotation

Codecov / codecov/patch

evap/evaluation/tools.py#L21

Added line #L21 was not covered by tests
else:
try:
from django_stubs_ext import StrOrPromise # if installed, use proper definition for typeguard
except ImportError:
StrOrPromise = Any # on production setups, type alias to Any

Check warning on line 26 in evap/evaluation/tools.py

View check run for this annotation

Codecov / codecov/patch

evap/evaluation/tools.py#L25-L26

Added lines #L25 - L26 were not covered by tests

M = TypeVar("M", bound=Model)
T = TypeVar("T")
Expand Down
2 changes: 1 addition & 1 deletion evap/staff/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
from django.utils.translation import gettext_lazy, ngettext
from django.views.decorators.http import require_POST
from django.views.generic import CreateView, FormView, UpdateView
from django_stubs_ext import StrOrPromise

from evap.contributor.views import export_contributor_results
from evap.evaluation.auth import manager_required, reviewer_required, staff_permission_required
Expand Down Expand Up @@ -65,6 +64,7 @@
FormsetView,
HttpResponseNoContent,
SaveValidFormMixin,
StrOrPromise,
get_object_from_dict_pk_entry_or_logged_40x,
get_parameter_from_url_or_session,
sort_formset,
Expand Down
Loading