Skip to content

Commit 4e9ac70

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 3d268f5 commit 4e9ac70

File tree

3 files changed

+28
-2
lines changed

3 files changed

+28
-2
lines changed

bec2format/__init__.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,27 @@
1+
# Micropython does not provide the typing module, let's mock it
2+
try:
3+
import typing
4+
except ImportError:
5+
from types import ModuleType
6+
7+
class _TypingMock(ModuleType):
8+
def __getattr__(self, item):
9+
return self
10+
11+
def __getitem__(self, item):
12+
return item
13+
14+
def __or__(self, other):
15+
return other
16+
17+
def __ror__(self, other):
18+
return other
19+
20+
import sys
21+
22+
sys.modules["typing"] = _TypingMock(_TypingMock.__name__)
23+
24+
125
from .bec2file import (
226
CONFIG_SECURITY_CODE_SIZE,
327
Bec2File,

tasks.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,9 @@ def lint(ctx: Context, fix: bool = False) -> None:
3030
sys.exit(1)
3131

3232

33-
@task
33+
@task()
3434
def build_mip_package_json(ctx: Context) -> None:
35+
"""builds the package.json for micropython's package manager mip"""
3536
repo = "github:baltech-ag/bec2format"
3637
project_name, project_version = (
3738
ctx.run("poetry version", hide="out").stdout.strip().rsplit(" ", maxsplit=2)

tox.ini

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ description = Run invoke
88
deps =
99
invoke===2.0.0
1010
poetry==1.4.2
11-
commands_pre = python -m invoke install
11+
commands_pre =
12+
python -m invoke install
1213
commands =
1314
python -m invoke {posargs}

0 commit comments

Comments
 (0)