Skip to content

Commit

Permalink
[internal] Micropython Kompatibilität: Fallback für typing Modul hinz…
Browse files Browse the repository at this point in the history
…ugefügt

Micropython bietet kein typing Modul (ist in Arbeit, siehe
micropython/micropython-lib#584). Stattdessen wird ein
Mock Type benutzt.

CUST-234
  • Loading branch information
jkatins committed May 31, 2023
1 parent 3d268f5 commit 3148433
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
23 changes: 23 additions & 0 deletions bec2format/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
# Micropython does not provide the typing module, let's mock it
try:
import typing
except ImportError:

class _TypingMock:
def __getattr__(self, item):
return self

def __getitem__(self, item):
return item

def __or__(self, other):
return other

def __ror__(self, other):
return other

import sys

sys.modules["typing"] = _TypingMock() # type: ignore


from .bec2file import (
CONFIG_SECURITY_CODE_SIZE,
Bec2File,
Expand Down
3 changes: 2 additions & 1 deletion tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ def lint(ctx: Context, fix: bool = False) -> None:
sys.exit(1)


@task
@task()
def build_mip_package_json(ctx: Context) -> None:
"""builds the package.json for micropython's package manager mip"""
repo = "github:baltech-ag/bec2format"
project_name, project_version = (
ctx.run("poetry version", hide="out").stdout.strip().rsplit(" ", maxsplit=2)
Expand Down
3 changes: 2 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ description = Run invoke
deps =
invoke===2.0.0
poetry==1.4.2
commands_pre = python -m invoke install
commands_pre =
python -m invoke install
commands =
python -m invoke {posargs}

0 comments on commit 3148433

Please sign in to comment.