As requested by https://github.com/python/typeshed/issues/1526.
This addition takes mypy configuration from each distribution metadata file and constructs a single mypy.ini to run with. It assumes there is no mypy.ini but in case we ever need one, it would be simple to add these on top of an existing configuration file.
Might be relevant for #2852
As the issue did not really specify how the configuration would look, I added the following:
- You may add a mypy-tests section to the metadata file.
It looks like this:
[mypy-tests]
[mypy-tests.yaml]
module_name = "yaml"
[mypy-tests.yaml.values]
disallow_incomplete_defs = true
disallow_untyped_defs = true
- module_name can be of the form "a.*" like in mypy.ini.
- You can add several module sections for complex distributions with several modules.
- I added the '--warn-incomplete-stub' option since it is made specifically for typeshed runs. See docs.
* Rename _CursesWindow to window in Python >= 3.8
The name _CursesWindow is not exposed at runtime which makes explicit type annotation difficult. It has to be wrapped in quotes, and this doesn't seem to work for all type checkers: PyLance's typechecker accepts it but Jedi's doesn't (tested in VS Code). This is especially annoying because with curses.wrapper(callback) there is no way to infer the type of the passed window except with an explicit annotation.
Experimentally, the type is exposed under the name "_curses.window" in Python 3.9 on both Ubuntu and Windows (via [windows-curses](https://pypi.org/project/windows-curses/)). While this is not explicitly documented as public, it is the name used for all the window method docs, and it is probably unlikely to change since some might interpret the lack of underscore as indicating it is public. Unfortunately it doesn't seem to be exposed as such in Python 2, but `¯\_(ツ)_/¯`. Using the runtime name should allow type checking to work with most typecheckers/platforms without quotes, and the old name can be kept as an alias for backwards compatibility.
I discovered the name _curses.window is only actually exported in Python >= 3.8 so I moved the name behind a version check, and reverted the original class name to _CursesWindow
Co-authored-by: Akuli <akuviljanen17@gmail.com>
stubtest now checks this for overloads as well (previously it didn't,
due to some combination of laziness, that this used to short circuit and
prevent signature checking, and the fact that these are all not super
helpful)
Co-authored-by: hauntsaninja <>
If no arguments are passed to the TemporaryDirectory constructor, then
the class defaults to using str. Overload the __init__ function to
cover this case.
I just found and fixed a bug in pyright's "missing type arguments" check. When type arguments were omitted for a generic type within a subscript expression, the error was being suppressed. With this bug fixed, I found several new cases where type arguments were missing in stdlib stubs. (#5130)
Co-authored-by: Eric Traut <erictr@microsoft.com>
The turtle module re-exports methods of its classes as top-level functions.
Typeshed includes most of these, but `exitonclick` and others from the
`_Screen` class were missing.
Add them.
Co-authored-by: Petr Viktorin <encukou@gmail.com>