Josverl / micropython-stubber

Generate and maintain stubs for different MicroPython ports to use with VSCode and Pylance, PyRight, Thonny, PyCharm or MyPy
https://micropython-stubber.readthedocs.io
Other
172 stars 14 forks source link

update_pyi fails on running across all #154

Closed Josverl closed 2 years ago

Josverl commented 2 years ago

Describe the bug A clear and concise description of what the bug is.

update_pyi does not complete and update all the stubs there appear to be two errors

Maximum recursion depth exeeded

Generated files under C:\develop\MyPython\micropython-stubber\all-stubs\micropython-v1_10-frozen\unix\GENERIC\
Traceback (most recent call last):
  File "C:\Users\josverl\AppData\Local\Programs\Python\Python39\lib\pathlib.py", line 746, in __str__
  File "C:\Users\josverl\AppData\Local\Programs\Python\Python39\lib\pathlib.py", line 1424, in exists
    self.stat()
  File "C:\Users\josverl\AppData\Local\Programs\Python\Python39\lib\pathlib.py", line 1232, in stat
    return self._accessor.stat(self)
  File "C:\Users\josverl\AppData\Local\Programs\Python\Python39\lib\pathlib.py", line 753, in __fspath__
    return str(self)
  File "C:\Users\josverl\AppData\Local\Programs\Python\Python39\lib\pathlib.py", line 748, in __str__
    self._str = self._format_parsed_parts(self._drv, self._root,
  File "C:\Users\josverl\AppData\Local\Programs\Python\Python39\lib\pathlib.py", line 728, in _format_parsed_parts
    return drv + root + cls._flavour.join(parts[1:])
RecursionError: maximum recursion depth exceeded while calling a Python object

mypy stubgen internal error

Calling stubgen on C:\develop\MyPython\micropython-stubber\all-stubs\micropython-latest-docstubs\collections.py
Processing 1 files...
C:\develop\MyPython\micropython-stubber\.venv\lib\site-packages\mypy\typeshed\stdlib\typing_extensions.pyi: error: INTERNAL ERROR -- Please try using mypy master on Github:
https://mypy.readthedocs.io/en/stable/common_issues.html#using-a-development-mypy-build
Please report a bug at https://github.com/python/mypy/issues
version: 0.931
Traceback (most recent call last):
  File "C:\develop\MyPython\micropython-stubber\src\update_pyi.py", line 26, in <module>
    utils.generate_pyi_files(stub_path)
  File "C:\develop\MyPython\micropython-stubber\src\utils.py", line 150, in generate_pyi_files
    r = r and generate_pyi_files(mod_manifest.parent)
  File "C:\develop\MyPython\micropython-stubber\src\utils.py", line 203, in generate_pyi_files
    generate_pyi_from_file(py)
  File "mypy\build.py", line 1972, in wrap_context
  File "mypy\semanal_main.py", line 326, in semantic_analyze_target
  File "mypy\semanal.py", line 405, in refresh_partial
  File "mypy\semanal.py", line 420, in refresh_top_level
  File "mypy\semanal.py", line 502, in add_typing_extension_aliases
  File "mypy\semanal.py", line 512, in create_alias
  File "mypy\semanal.py", line 4562, in named_type_or_none
AssertionError: FuncDef:74(
  OrderedDict
  def (*args: Any) -> Any?
  VarArg(
    Var(args))
  Block:74(
    ExpressionStmt:75(
      StrExpr(\u000a    ``dict`` type subclass which remembers and preserves the order of keys\u000a    added. When ordered dict is iterated over, keys/items are returned in\u000a    the order they were added::\u000a\u000a        from collections import OrderedDict\u000a\u000a        # To make benefit of ordered keys, OrderedDict should be initialized\u000a        # from sequence of (key, value) pairs.\u000a        d = OrderedDict([("z", 1), ("a", 2)])\u000a        # More items can be added as usual\u000a        d["w"] = 5\u000a        d["b"] = 3\u000a        for k, v in d.items():\u000a            print(k, v)\u000a\u000a    Output::\u000a\u000a        z 1\u000a        a 2\u000a        w 5\u000a        b 3\u000a    ))
    ExpressionStmt:98(
      Ellipsis)))

To Reproduce python ./src/update_pyi.py .\all-stubs\

workaround: foreach ($dir in dir .\all-stubs\ -Directory ) { python .\src\update_pyi.py $dir }

Josverl commented 2 years ago

it also makes sense to only update a .pyi if the timestamp of the .py file is newer , specifically when running per file . this may save a lot of time in updates

Josverl commented 2 years ago

fixed by: 36f12b77ae71d41af13a8305ea8aed4b2bda9f8a