Script to update stubinfo.py#18367
Conversation
f7c4c4c to
8cf4db2
Compare
3ba41c3 to
24d90e2
Compare
cdce8p
left a comment
There was a problem hiding this comment.
Some minor comments. Was just in the process of reviewing it.
| import argparse | ||
| from pathlib import Path | ||
|
|
||
| import tomli as tomllib |
There was a problem hiding this comment.
| import tomli as tomllib | |
| if sys.version_info >= (3, 11): | |
| import tomllib | |
| else: | |
| import tomli as tomllib |
At some point we'll remove tomli from the requirements. The sys.version_info block will get flagged when we update the Python version.
| continue | ||
| typeshed_p_to_d[p.stem] = d | ||
|
|
||
| import mypy.stubinfo |
There was a problem hiding this comment.
Any reason to have the import inline and not at the top?
| print("=" * 40) | ||
| print("Add the following to non_bundled_packages_flat:") | ||
| print("=" * 40) | ||
| for p in sorted(typeshed_p_to_d.keys() - mypy_p): | ||
| if p in { | ||
| "pika", # see comment in stubinfo.py | ||
| "distutils", # don't recommend types-setuptools here | ||
| }: | ||
| continue | ||
| print(f'"{p}": "{typeshed_p_to_d[p]}",') | ||
| print() |
There was a problem hiding this comment.
Probably personal preference, but if I were to run the script, I'd like it to print the whole dict contents in a sorted order so I just need to copy-paste it. Ideally it would only be outputted if there are any changes to begin with.
| print("=" * 40) | ||
| print("Consider removing the following packages no longer in typeshed:") | ||
| print("=" * 40) | ||
| for p in sorted(mypy_p - typeshed_p_to_d.keys()): | ||
| if p in {"lxml", "pandas"}: # never in typeshed | ||
| continue | ||
| print(p) |
|
Thanks for the review! These would be nice improvements, but is a little fiddly (e.g. there are currently two dicts in stubinfo.py, see also #18372). I'll pick these up the next time I have to touch this misc script (or we can just delete the script). |
Additions in #18366 , will do removals once merged