typeshed
typeshed copied to clipboard
Collection of library stubs for Python, with static types
This came up at a mentored sprint event at pycon just now -- a new contributor was trying to use a conda virtual environment instead of the stdlib `venv`, but...
```py import tempfile with tempfile.NamedTemporaryFile() as file: reveal_type(file) # tempfile._TemporaryFileWrapper[builtins.bytes] file.asdfasdf # no error ``` https://mypy-play.net/?mypy=latest&python=3.10&flags=show-error-context%2Cshow-error-codes%2Cstrict%2Ccheck-untyped-defs%2Cdisallow-any-decorated%2Cdisallow-any-expr%2Cdisallow-any-explicit%2Cdisallow-any-generics%2Cdisallow-any-unimported%2Cdisallow-incomplete-defs%2Cdisallow-subclassing-any%2Cdisallow-untyped-calls%2Cdisallow-untyped-decorators%2Cdisallow-untyped-defs%2Cno-implicit-optional%2Cno-implicit-reexport%2Clocal-partial-types%2Cstrict-equality%2Cwarn-incomplete-stub%2Cwarn-redundant-casts%2Cwarn-return-any%2Cwarn-unreachable%2Cwarn-unused-configs%2Cwarn-unused-ignores&gist=ef2074a29b833738372beb1008fd3ead tested with both mypy and pyright
https://mypy-play.net/?mypy=latest&python=3.10&gist=6f7d6d1036646b8e8a41ed3a5dab3b98&flags=strict ```python from unittest import mock import subprocess def foo() -> None: with mock.patch.object( subprocess, "Popen", **{"return_value.communicate.side_effect": KeyboardInterrupt} ): pass ```
Welcome to typeshed! Like most projects, reading our [CONTRIBUTING.md](https://github.com/python/typeshed/blob/master/CONTRIBUTING.md) and scrolling through our issues is a good way to find things that need improvement. In fact, many of our issues...
Currently several properties are concrete, even though `IO` and `TextIO` are ABCs. Originally https://github.com/python/mypy/issues/266.
I had a patch to stubtest that added checking of base classes. Unfortunately, it was too noisy to consider merging, although some fixes did come out of it. I complicated...
Currently `property.__get__` returns `Any`, which loose information: https://github.com/python/typeshed/blob/c58a93b928b07a5123fa8ceebe6087fa262fe238/stdlib/3/builtins.pyi#L877 This would be more correct for `property.__get__` to be generic and return `T`. Similar to cached_property: https://github.com/python/typeshed/blob/1dd1b701c97e4bff9b8e05fb58ce8d3dd27aa213/stdlib/3/functools.pyi#L113 ```py class A: @cached_property def...
Running mypy --install-types on a project containing `import OpenSSL.crypto` suggests installing `types-openssl-python` but installing this package does not resolve the issue. Ona repeated run, I still get the following error...
My understanding is that symbols defined at the module scope of a stub file and begin with an underscore are meant to be private to the stub — that they...
Often the return value of a callback function is ignored. In those cases, I have previously used `Callable[[], None]`, but then @srittau told me to use `Callable[[], Any]`, and I...