-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Script to update stubinfo.py #18367
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Script to update stubinfo.py #18367
Conversation
f7c4c4c
to
8cf4db2
Compare
3ba41c3
to
24d90e2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here.
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