Josverl / micropython-stubs

Stubs of most MicroPython ports, boards and versions to make writing code that much simpler.
https://micropython-stubs.readthedocs.io
MIT License
157 stars 22 forks source link

pylance flags an error for : Object of type "BufferedWriter" cannot be used with "with" because it does not implement __enter__ #718

Open Josverl opened 1 year ago

Josverl commented 1 year ago
            with open(_toml, "wb") as output:
                tomli_w.dump(pyproject, output)

raises the errors Object of type "BufferedWriter" cannot be used with "with" because it does not implement enter

class BufferedWriter:
    def flush(self, *args, **kwargs) -> Any: ...
    def write(self, *args, **kwargs) -> Any: ...
    def __init__(self, *argv, **kwargs) -> None: ...
Josverl commented 1 year ago

Set BinaryIO as the baseclass for BufferedWriter will need to be done using a codemod as the class is not documented in the docstubs

already tried lookup: "BufferedWriter": "IOBase", # DOCME: not in documentation