21.6.0: mypy errors

#54 · closed · 4 comments

View on GitHub ↗

mtelka

``` $ python -m mypy.stubtest --allowlist dev/mypy.allowlist contextlib2 error: not checking stubs due to mypy build errors: contextlib2/__init__.pyi:41: error: Class contextlib2._GeneratorContextManager has abstract attributes "__exit__" [misc] contextlib2/__init__.pyi:41: note: If it is meant to be abstract, add 'abc.ABCMeta' as an explicit metaclass contextlib2/__init__.pyi:55: error: Class contextlib2.closing has abstract attributes "__exit__" [misc] contextlib2/__init__.pyi:55: note: If it is meant to be abstract, add 'abc.ABCMeta' as an explicit metaclass contextlib2/__init__.pyi:62: error: Class contextlib2.aclosing has abstract attributes "__aexit__" [misc] contextlib2/__init__.pyi:62: note: If it is meant to be abstract, add 'abc.ABCMeta' as an explicit metaclass contextlib2/__init__.pyi:74: error: Class contextlib2.redirect_stdout has abstract attributes "__exit__" [misc] contextlib2/__init__.pyi:74: note: If it is meant to be abstract, add 'abc.ABCMeta' as an explicit metaclass contextlib2/__init__.pyi:77: error: Class contextlib2.redirect_stderr has abstract attributes "__exit__" [misc] contextlib2/__init__.pyi:77: note: If it is meant to be abstract, add 'abc.ABCMeta' as an explicit metaclass contextlib2/__init__.pyi:116: error: Return type "Awaitable[AsyncExitStack]" of "__aenter__" incompatible with return type "Coroutine[Any, Any, AsyncExitStack]" in supertype "AbstractAsyncContextManager" [override] contextlib2/__init__.pyi:117: error: Return type "Awaitable[bool]" of "__aexit__" incompatible with return type "Coroutine[Any, Any, Optional[bool]]" in supertype "AbstractAsyncContextManager" [override] $ ```

Comments

ncoghlan

This may be covered by #43 (updating to a new base version of all the contextlib files)

ncoghlan

Getting CI running again showed that the nominally python3.10 test environment wasn't actually running on Python 3.10, it was running on whatever happened to be the system Python in the GitHub action containers. This was 3.8 in the old Ubuntu 20.04 runners, and only went up to 3.10 when the runners updated to Ubuntu 22.04 That was after the last merged contextlib2 update (which synced with the Python 3.10 beta version in June 2021), hence this problem not being detected in CI.

ncoghlan

I take that back, it is failing everywhere (maybe a newer `mypy` is the issue?). Turning off the check for now, will turn it back on after the sync with newer versions.

ncoghlan

I did run into one weird apparent mypy misbehaviour while working on this: https://github.com/python/mypy/issues/17277