From b23716bd58ccbdfa9e3421dcc0f8a3439e5cae71 Mon Sep 17 00:00:00 2001 From: Frederik Hennig <frederik.hennig@fau.de> Date: Mon, 24 Mar 2025 10:05:35 +0100 Subject: [PATCH] make SupportsFieldExtraction and SupportsVectorExtraction runtime-checkable --- src/pystencilssfg/lang/extractions.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/pystencilssfg/lang/extractions.py b/src/pystencilssfg/lang/extractions.py index e920fcb..39f8462 100644 --- a/src/pystencilssfg/lang/extractions.py +++ b/src/pystencilssfg/lang/extractions.py @@ -1,10 +1,11 @@ from __future__ import annotations -from typing import Protocol +from typing import Protocol, runtime_checkable from abc import abstractmethod from .expressions import AugExpr +@runtime_checkable class SupportsFieldExtraction(Protocol): """Protocol for field pointer and indexing extraction. @@ -13,7 +14,7 @@ class SupportsFieldExtraction(Protocol): They can therefore be passed to `sfg.map_field <SfgBasicComposer.map_field>`. """ -# how-to-guide begin + # how-to-guide begin @abstractmethod def _extract_ptr(self) -> AugExpr: """Extract the field base pointer. @@ -47,9 +48,12 @@ class SupportsFieldExtraction(Protocol): :meta public: """ + + # how-to-guide end +@runtime_checkable class SupportsVectorExtraction(Protocol): """Protocol for component extraction from a vector. -- GitLab