add annotations to __future__; don't generate __future__ stubs
This commit is contained in:
parent
1164f2b081
commit
dd239efc94
@ -36,6 +36,13 @@
|
|||||||
//| The `__future__` module is used by other Python implementations to
|
//| The `__future__` module is used by other Python implementations to
|
||||||
//| enable forward compatibility for features enabled by default in an upcoming version.
|
//| enable forward compatibility for features enabled by default in an upcoming version.
|
||||||
//| """
|
//| """
|
||||||
|
//|
|
||||||
|
//| annotations: Any
|
||||||
|
//| """In CPython, ``from __future import annotations``
|
||||||
|
//| indicates that evaluation of annotations is postponed, as described in PEP 563.
|
||||||
|
//| CircuitPython (and MicroPython) ignore annotations entirely, whether or not this feature is imported.
|
||||||
|
//| This is a limitation of CircuitPython and MicroPython for efficiency reasons.
|
||||||
|
//| """
|
||||||
|
|
||||||
STATIC const mp_rom_map_elem_t future_module_globals_table[] = {
|
STATIC const mp_rom_map_elem_t future_module_globals_table[] = {
|
||||||
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR___future__) },
|
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR___future__) },
|
||||||
|
@ -21,7 +21,9 @@ import circuitpython_typing
|
|||||||
import circuitpython_typing.socket
|
import circuitpython_typing.socket
|
||||||
|
|
||||||
|
|
||||||
IMPORTS_IGNORE = frozenset(
|
PATHS_IGNORE = frozenset({"shared-bindings/__future__"})
|
||||||
|
|
||||||
|
TYPE_MODULE_IMPORTS_IGNORE = frozenset(
|
||||||
{
|
{
|
||||||
"array",
|
"array",
|
||||||
"bool",
|
"bool",
|
||||||
@ -115,7 +117,7 @@ def extract_imports(tree):
|
|||||||
return
|
return
|
||||||
for node in ast.walk(anno_tree):
|
for node in ast.walk(anno_tree):
|
||||||
if isinstance(node, ast.Name):
|
if isinstance(node, ast.Name):
|
||||||
if node.id in IMPORTS_IGNORE:
|
if node.id in TYPE_MODULE_IMPORTS_IGNORE:
|
||||||
continue
|
continue
|
||||||
for module, imports in AVAILABLE_TYPE_MODULE_IMPORTS.items():
|
for module, imports in AVAILABLE_TYPE_MODULE_IMPORTS.items():
|
||||||
if node.id in imports:
|
if node.id in imports:
|
||||||
@ -158,6 +160,9 @@ def convert_folder(top_level, stub_directory):
|
|||||||
|
|
||||||
for filename in filenames:
|
for filename in filenames:
|
||||||
full_path = os.path.join(top_level, filename)
|
full_path = os.path.join(top_level, filename)
|
||||||
|
if full_path in PATHS_IGNORE:
|
||||||
|
continue
|
||||||
|
|
||||||
file_lines = []
|
file_lines = []
|
||||||
if os.path.isdir(full_path):
|
if os.path.isdir(full_path):
|
||||||
(mok, mtotal) = convert_folder(full_path, os.path.join(stub_directory, filename))
|
(mok, mtotal) = convert_folder(full_path, os.path.join(stub_directory, filename))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user