Skip to content

Commit 8e405e2

Browse files
committed
[internal] Fallback für fehlendes typing Modul in Micropython 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 ab21716 commit 8e405e2

5 files changed

Lines changed: 35 additions & 2 deletions

File tree

bec2format/__init__.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
# Micropython does not provide a typing module, let's use a mock instead
2+
try:
3+
import typing
4+
except ImportError:
5+
import sys
6+
7+
from . import typing_mock
8+
9+
sys.modules["typing"] = typing_mock
10+
11+
112
from .bec2file import (
213
CONFIG_SECURITY_CODE_SIZE,
314
Bec2File,

bec2format/typing_mock.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
class _TypeMock:
2+
def __getitem__(self, item):
3+
return self
4+
5+
def __or__(self, other):
6+
return self
7+
8+
def __ror__(self, other):
9+
return self
10+
11+
12+
_typeMock = _TypeMock()
13+
14+
15+
def __getattr__(name):
16+
return _typeMock

package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,10 @@
185185
"bec2format/bec2format/hwcids.py",
186186
"github:baltech-ag/bec2format/bec2format/hwcids.py"
187187
],
188+
[
189+
"bec2format/bec2format/typing_mock.py",
190+
"github:baltech-ag/bec2format/bec2format/typing_mock.py"
191+
],
188192
[
189193
"bec2format/bec2format/__init__.py",
190194
"github:baltech-ag/bec2format/bec2format/__init__.py"

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)