Skip to content

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

Merged
merged 2 commits into from
Dec 30, 2024
Merged

Conversation

hauntsaninja
Copy link
Collaborator

@hauntsaninja hauntsaninja commented Dec 29, 2024

Additions in #18366 , will do removals once merged

hauntsaninja added a commit that referenced this pull request Dec 30, 2024
hauntsaninja added a commit that referenced this pull request Dec 30, 2024
@hauntsaninja hauntsaninja merged commit 1161487 into python:master Dec 30, 2024
12 checks passed
@hauntsaninja hauntsaninja deleted the stub-script branch December 30, 2024 23:54
Copy link
Collaborator

@cdce8p cdce8p left a 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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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
Copy link
Collaborator

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?

Comment on lines +45 to +55
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()
Copy link
Collaborator

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.

Comment on lines +57 to +63
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)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.

@hauntsaninja
Copy link
Collaborator Author

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants