Skip to content

Add typing to more build tools #133403

Closed
Closed

Description

@sobolevn

Feature or enhancement

Right now we support typing in several build tools:

files =
Tools/build/compute-changes.py,
Tools/build/generate_sbom.py

I think that some other files / tools from this folder can benefit from being checked with mypy.

I have a PR ready for Tools/build/update_file.py of parser.c generation.
What else can be easily typed?

Linked PRs

Activity

  1. added
    infraCI, GitHub Actions, buildbots, Dependabot, etc.
    type-featureA feature request or enhancement
    on May 4, 2025
  2. self-assigned this
    on May 4, 2025
  3. added 4 commits that reference this issue on May 4, 2025
  4. sobolevn commented on May 4, 2025

    @sobolevn
    MemberAuthor

    Tools/build/verify_ensurepip_wheels.py also has annotations, but it is not checked. Will add in a separate PR, since it requires a bit of modification:

    Tools/build/verify_ensurepip_wheels.py:41: error: Argument 1 to "print_error" has
    incompatible type "Path"; expected "str"  [arg-type]
                        print_error(p, f"Found more than one wheel for package {package_n...
                                    ^
    Tools/build/verify_ensurepip_wheels.py:56: error: Argument 1 to "print_error" has
    incompatible type "Path"; expected "str"  [arg-type]
                    package_path,
                    ^~~~~~~~~~~~
    Tools/build/verify_ensurepip_wheels.py:66: error: Argument 1 to "print_error" has
    incompatible type "Path"; expected "str"  [arg-type]
                print_error(package_path, f"Could not fetch JSON metadata for {package_na...
                            ^~~~~~~~~~~~
    Tools/build/verify_ensurepip_wheels.py:76: error: Argument 1 to "print_error" has
    incompatible type "Path"; expected "str"  [arg-type]
                print_error(package_path, f"No digest for {package_name} found from PyPI....
                            ^~~~~~~~~~~~
    Tools/build/verify_ensurepip_wheels.py:82: error: Name "expected_digest" may be undefined 
    [possibly-undefined]
            print(f"Expected digest: {expected_digest}")
                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Tools/build/verify_ensurepip_wheels.py:87: error: Argument 1 to "print_error" has
    incompatible type "Path"; expected "str"  [arg-type]
                    package_path, f"Failed to verify the checksum of the {package_name} w...
                    ^~~~~~~~~~~~
    Tools/build/verify_ensurepip_wheels.py:92: error: Argument 1 to "print_notice" has
    incompatible type "Path"; expected "str"  [arg-type]
                package_path,
                ^~~~~~~~~~~~
    Found 7 errors in 1 file (checked 4 source files)
                                              
  5. sobolevn commented on May 4, 2025

    @sobolevn
    MemberAuthor

    We should also merge #133405 before any other PR.

  6. Flosckow commented on May 5, 2025

    @Flosckow
    Contributor

    Can I work on it?

  7. sobolevn commented on May 5, 2025

    @sobolevn
    MemberAuthor

    @Flosckow sure, you can help with #133403 (comment) I haven't started yet :)

    Thank you!

  8. Flosckow commented on May 5, 2025

    @Flosckow
    Contributor

    @Flosckowконечно, вы можете помочь с #133403 (комментарий) Я еще не начал :)

    Спасибо!

    Yes, I'll try to do this, the only thing I might be a little slow is this is my first pr in cpython.

  9. sobolevn commented on May 5, 2025

    @sobolevn
    MemberAuthor

    No worries, I can surely help with any questions you might have. Feel free to ask them :)

  10. added a commit that references this issue on May 5, 2025
  11. 51 remaining items

  12. added a commit that references this issue on Aug 27, 2025
  13. added 3 commits that reference this issue on Sep 9, 2025
  14. added 3 commits that reference this issue on Dec 31, 2025
  15. RafaelWO commented on Feb 1, 2026

    @RafaelWO
    Contributor

    Hey there, I also would like to help out and add typing to more of the build scripts.

    Currently, the following script are not yet checked by mypy:

    • Tools/build/freeze_modules.py
    • Tools/build/generate_global_objects.py
    • Tools/build/generate_levenshtein_examples.py (open PR gh-133403: Add type annotations to generate_levenshtein_examples.py #143317)
    • Tools/build/generate_re_casefix.py
    • Tools/build/generate_sre_constants.py
    • Tools/build/generate_token.py
    • Tools/build/parse_html5_entities.py
    • Tools/build/smelly.py
    • Tools/build/stable_abi.py

    Are there any scripts that don't need typing? Otherwise, I would start with Tools/build/generate_re_casefix.py.

  16. picnixz commented on Feb 1, 2026

    @picnixz
    Member

    It depends on whether the codeowner/maintainer of those modules want such additions and whether adding them brings real value.

  17. added a commit that references this issue on Apr 18, 2026
  18. added a commit that references this issue on Apr 18, 2026
  19. added a commit that references this issue on Apr 19, 2026
  20. added a commit that references this issue on Apr 25, 2026
  21. StanFromIreland commented on Aug 27, 2026

    @StanFromIreland
    Member

    I'm closing this, let's create new issues for the remaining tools so that decisions can be made on a case-by-case basis.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

infraCI, GitHub Actions, buildbots, Dependabot, etc.type-featureA feature request or enhancement

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions