Skip to content

Commit

Permalink
🏷️ Use TypeIs where possible
Browse files Browse the repository at this point in the history
  • Loading branch information
Viicos committed May 22, 2024
1 parent 393c5de commit 1bac703
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/openforms/config/checks.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
from typing import Any, Generator, Protocol, TypeGuard
from typing import Any, Generator, Protocol

from django.utils.encoding import force_str
from django.utils.translation import gettext as _

from typing_extensions import TypeIs

from openforms.appointments.registry import register as appointments_register
from openforms.contrib.brk.checks import BRKValidatorCheck
from openforms.contrib.kadaster.config_check import BAGCheck, LocatieServerCheck
Expand Down Expand Up @@ -30,7 +32,7 @@ def _subset_match(requested: str | None, checking: str) -> bool:
return requested == checking


def is_plugin(plugin: Any) -> TypeGuard[AbstractBasePlugin]:
def is_plugin(plugin: Any) -> TypeIs[AbstractBasePlugin]:
if hasattr(plugin, "identifier"):
return True
return False
Expand Down
5 changes: 3 additions & 2 deletions src/openforms/formio/utils.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import logging
from dataclasses import dataclass
from typing import Any, Callable, Iterator, TypeAlias, TypeGuard
from typing import Any, Callable, Iterator, TypeAlias

import elasticapm
from glom import Coalesce, Path, glom
from typing_extensions import TypeIs

from openforms.typing import DataMapping, JSONObject, JSONValue
from openforms.utils.glom import _glom_path_to_str
Expand All @@ -21,7 +22,7 @@
)


def _is_column_component(component: ComponentLike) -> TypeGuard[ColumnsComponent]:
def _is_column_component(component: ComponentLike) -> TypeIs[ColumnsComponent]:
return component.get("type") == "columns"


Expand Down

0 comments on commit 1bac703

Please sign in to comment.