Skip to content

Commit cb47c8e

Browse files
committed
[internal] Micropython Kompatibilität: Fallback für typing Modul hinzugefügt
Micropython bietet kein typing Modul (ist in Arbeit, siehe micropython/micropython-lib#584). Stattdessen wird ein Mock Type benutzt. CUST-234
1 parent 53af28f commit cb47c8e

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

bec2format/__init__.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
import sys
2+
3+
if sys.implementation.name == "micropython":
4+
from .compatibility import mock_module
5+
6+
mock_module("typing")
7+
18
from .bec2file import (
29
CONFIG_SECURITY_CODE_SIZE,
310
Bec2File,

bec2format/compatibility.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import sys
2+
3+
4+
class _Mock:
5+
def __getattr__(self, item):
6+
return self
7+
8+
def __getitem__(self, item):
9+
return self
10+
11+
def __or__(self, other):
12+
return other
13+
14+
def __ror__(self, other):
15+
return other
16+
17+
18+
def mock_module(module_name: str) -> None:
19+
sys.modules[module_name] = _Mock() # type: ignore

0 commit comments

Comments
 (0)