Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion ports/stm32/boards/PYBV11/board.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
"DP": "Double-precision float",
"DP_THREAD": "Double precision float + Threads",
"NETWORK": "Wiznet 5200 Driver",
"THREAD": "Threading"
"THREAD": "Threading",
"TYPING_2B": "Typing_2b",
"TYPING_2C": "Typing_2c"
},
"vendor": "George Robotics"
}
1 change: 1 addition & 0 deletions ports/stm32/boards/PYBV11/mpconfigvariant_TYPING_2B.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
FROZEN_MANIFEST = $(BOARD_DIR)/../manifest_typing.py
1 change: 1 addition & 0 deletions ports/stm32/boards/PYBV11/mpconfigvariant_TYPING_2C.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
FROZEN_MANIFEST = $(BOARD_DIR)/../manifest_typing.py
10 changes: 10 additions & 0 deletions ports/stm32/boards/manifest_typing.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
TYPE_CHECKING = False
if TYPE_CHECKING:
from manifestfile import *


include("$(PORT_DIR)/boards/manifest.py")
include("$(PORT_DIR)/boards/manifest_pyboard.py")

# Typing
require("bundle-typing", extensions=True)
4 changes: 4 additions & 0 deletions ports/unix/variants/coverage/manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,7 @@
freeze_as_mpy("frzmpy")
freeze_mpy("$(MPY_DIR)/tests/assets")
require("ssl")

# used for typing runtime tests
require("abc")
require("bundle-typing", extensions=True)
8 changes: 8 additions & 0 deletions ports/unix/variants/typing1/manifest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
include("$(PORT_DIR)/variants/manifest.py")

include("$(MPY_DIR)/extmod/asyncio")


# Freeze typing modules from local micropython-stubs repo
require("__future__", opt_level=3)
module("typing.py", base_path="/home/jos/micropython-stubs/mip", opt=3)
31 changes: 31 additions & 0 deletions ports/unix/variants/typing1/mpconfigvariant.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2019 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/

// Set base feature level.
#define MICROPY_CONFIG_ROM_LEVEL (MICROPY_CONFIG_ROM_LEVEL_EXTRA_FEATURES)

// Enable extra Unix features.
#include "../mpconfigvariant_common.h"
3 changes: 3 additions & 0 deletions ports/unix/variants/typing1/mpconfigvariant.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# This is the default variant when you `make` the Unix port.

FROZEN_MANIFEST ?= $(VARIANT_DIR)/manifest.py
191 changes: 191 additions & 0 deletions ports/unix/variants/typing1/typing/typing.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
# Minimal MicroPython typing module


def cast(type, val):
return val


def get_origin(type):
return None


def get_args(type):
return ()


def no_type_check(func):
return func


def overload(func):
return None


def override(func):
return func


class _AnyCall:
def __init__(*args, **kwargs):
pass

def __call__(*args, **kwargs):
pass

def __getitem__(self, arg):
return _anyCall


_anyCall = _AnyCall()


class _SubscriptableType:
def __getitem__(self, arg):
return _anyCall


_Subscriptable = _SubscriptableType()


class Any:
pass


def TypeVar(
name,
*types,
bound: Any | None = None,
covariant=False,
contravariant=False,
infer_variance=False,
):
return None


def NewType(name, type):
return type


class BinaryIO:
pass


class ClassVar:
pass


class Final:
pass


class Hashable:
pass


class IO:
pass


class NoReturn:
pass


class Sized:
pass


class SupportsInt:
pass


class SupportsFloat:
pass


class SupportsComplex:
pass


class SupportsBytes:
pass


class SupportsIndex:
pass


class SupportsAbs:
pass


class SupportsRound:
pass


class TextIO:
pass


class Protocol:
pass


# CHECK
class Reversible:
pass


class NotRequired:
pass


LiteralString = AnyStr = str
TypedDict = dict
final = no_type_check # PEP 591 final decorator is a no-op in MicroPython runtime.
TypeAlias = Any

# Deprecated
Text = str
# Pattern = str
# Match = str

AbstractSet = _Subscriptable
Annotated = _Subscriptable
AsyncContextManager = _Subscriptable
AsyncGenerator = _Subscriptable
AsyncIterable = _Subscriptable
AsyncIterator = _Subscriptable
Awaitable = _Subscriptable
Callable = _Subscriptable
ChainMap = _Subscriptable
Collection = _Subscriptable
Container = _Subscriptable
ContextManager = _Subscriptable
Coroutine = _Subscriptable
Counter = _Subscriptable
DefaultDict = _Subscriptable
Deque = _Subscriptable
Dict = _Subscriptable
FrozenSet = _Subscriptable
Generator = _Subscriptable
Generic = _Subscriptable
Iterable = _Subscriptable
Iterator = _Subscriptable
List = _Subscriptable
Literal = _Subscriptable
Mapping = _Subscriptable
MutableMapping = _Subscriptable
MutableSequence = _Subscriptable
MutableSet = _Subscriptable
NamedTuple = _Subscriptable
Optional = _Subscriptable
OrderedDict = _Subscriptable
ReadOnly = _Subscriptable
Self = _Subscriptable
Sequence = _Subscriptable
Set = _Subscriptable
Tuple = _Subscriptable
Type = _Subscriptable
Union = _Subscriptable

TYPE_CHECKING = False
1 change: 1 addition & 0 deletions ports/unix/variants/typing1/typing_extensions/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from typing import *
10 changes: 10 additions & 0 deletions ports/unix/variants/typing2a/manifest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
TYPE_CHECKING = False
if TYPE_CHECKING:
from manifestfile import *

include("$(PORT_DIR)/variants/manifest.py")

include("$(MPY_DIR)/extmod/asyncio")

require("typing", opt_level=3)
# require("typing_extensions", opt_level=3)
31 changes: 31 additions & 0 deletions ports/unix/variants/typing2a/mpconfigvariant.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2019 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/

// Set base feature level.
#define MICROPY_CONFIG_ROM_LEVEL (MICROPY_CONFIG_ROM_LEVEL_EXTRA_FEATURES)

// Enable extra Unix features.
#include "../mpconfigvariant_common.h"
3 changes: 3 additions & 0 deletions ports/unix/variants/typing2a/mpconfigvariant.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# This is the default variant when you `make` the Unix port.

FROZEN_MANIFEST ?= $(VARIANT_DIR)/manifest.py
12 changes: 12 additions & 0 deletions ports/unix/variants/typing2b/manifest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
TYPE_CHECKING = False
if TYPE_CHECKING:
from manifestfile import *

include("$(PORT_DIR)/variants/manifest.py")

include("$(MPY_DIR)/extmod/asyncio")

# to reduce code size:
# - default optimization level is 3
# - extensions are disabled by default
require("bundle-typing", extensions=False)
31 changes: 31 additions & 0 deletions ports/unix/variants/typing2b/mpconfigvariant.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2019 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/

// Set base feature level.
#define MICROPY_CONFIG_ROM_LEVEL (MICROPY_CONFIG_ROM_LEVEL_EXTRA_FEATURES)

// Enable extra Unix features.
#include "../mpconfigvariant_common.h"
3 changes: 3 additions & 0 deletions ports/unix/variants/typing2b/mpconfigvariant.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# This is the default variant when you `make` the Unix port.

FROZEN_MANIFEST ?= $(VARIANT_DIR)/manifest.py
12 changes: 12 additions & 0 deletions ports/unix/variants/typing2c/manifest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
TYPE_CHECKING = False
if TYPE_CHECKING:
from manifestfile import *

include("$(PORT_DIR)/variants/manifest.py")

include("$(MPY_DIR)/extmod/asyncio")

# to reduce code size:
# - default optimization level is 3
# - extensions are disabled by default
require("bundle-typing", extensions=True)
Loading
Loading