Skip to content

Commit 6899d13

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 benutzt. CUST-234
1 parent 109c90f commit 6899d13

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

bec2format/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
import sys
2+
3+
if sys.implementation.name == "micropython":
4+
import bec2format.micropython_compatibility_quirks
5+
6+
17
from .bec2file import (
28
CONFIG_SECURITY_CODE_SIZE,
39
Bec2File,
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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
20+
21+
22+
mock_module("typing")

0 commit comments

Comments
 (0)