Fixes#8778
Note that not fixing this has some advantages, particularly if stubsabot
waits a little while after releases before making PRs (as discussed
earlier). Specifically, it gives us more coverage of upstream versions
and might provide a natural division of changes, compared to PRs that
make updates corresponding to several upstream versions.
There are even newer versions available (4.*), but I had found a bug
in it which prevented it from working with mypy-protobuf. For now,
sticking to just 3.20.1
Since stubgen will usually create definition complete stubs, we should have
stubtest check missing definitions so we can know to reflect any future
additions.
Co-authored-by: hauntsaninja <>
Per the suggestion in https://github.com/dropbox/mypy-protobuf/issues/344
This generates more permissive constructors (which protobuf itself actually
accepts).
Philosophically, I think it makes sense for the generated code hosted on
typeshed to be most permissive, while the generated code of individual
projects can make individual decisions (defaulting to less permissive).
This tool is a simple wrapper around stubgen and other tools that simplifies the
creation of "baseline" stubs with minimal annotation coverage. These stubs allow
basic type checking (e.g. number of arguments, whether X is valid as a base class),
and once we have baseline stubs, it's easy to contribute incremental changes that
add type annotations.
Here's a summary of what the tool does:
1. Check that the package is installed
2. Run stubgen
3. Copy generated stubs to the correct directory under `stubs/`
4. Run black
5. Run isort
6. Generate basic metadata with correct package version
7. Update pyright exclusions (needed since there are missing types)
8. Print suggestions about next steps needed to contribute stubs to typeshed
For example, to generate stubs for `iso8601`, you can run it like this:
```
python scripts/create_baseline_stubs.py iso8601
```
Sometimes the project name is different from the runtime package name. In
this case run the tool with `--package <runtime-package>`.