Skip to content

Merge typeshed return annotations #4744

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 3 commits into from
May 29, 2025

Conversation

Avasam
Copy link
Contributor

@Avasam Avasam commented Nov 10, 2024

Summary of changes

Based on #4736, so merge that one first. Done
Blocked by setuptools/msvc.py dir methods and properties split off to #4755 for easier review Done

Step 6.2 of #2345 (comment)

This PR still doesn't do initialize_options as those have their own set of issues (and knowing they return None isn't that helpful to begin with), as well as complex Command-based overloads.

Pull Request Checklist

  • Changes have tests (type checkers, and this increases static type-checking coverage)
  • News fragment added in newsfragments/. (not public facing yet)
    (See documentation for details)

@Avasam Avasam marked this pull request as draft November 10, 2024 23:10
@Avasam Avasam changed the title ANN204 (missing return type for special methods) autofixes Merge typeshed return annotations Nov 10, 2024
@Avasam Avasam force-pushed the Merge-typeshed-return-annotations branch from fb5487b to aa0ad57 Compare November 10, 2024 23:22
Comment on lines +269 to +268
# We shouldn't find any non-pyc files in __pycache__
assert m is not None
Copy link
Contributor Author

@Avasam Avasam Nov 20, 2024

Choose a reason for hiding this comment

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

Not strictly an annotation change, but I included it here because it didn't feel worth doing a PR just for this
Would've been included in #4753 if I realised sooner this was an easy fix

Comment on lines 372 to 361
def run(self) -> None:
def run(self):
Copy link
Contributor Author

@Avasam Avasam Nov 20, 2024

Choose a reason for hiding this comment

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

I opted out of annotating this specific run in this PR for the same reason I didn't do initialize_options.

(note that I'm commenting on a specific commit, this PR doesn't remove any return annotation)

@Avasam Avasam marked this pull request as ready for review December 23, 2024 04:54
@Avasam Avasam changed the title Merge typeshed return annotations [blocked by #4755] Merge typeshed return annotations Jan 11, 2025
@Avasam Avasam changed the title [blocked by #4755] Merge typeshed return annotations Merge typeshed return annotations May 28, 2025
@Avasam Avasam force-pushed the Merge-typeshed-return-annotations branch from 8cba3e1 to 5a26893 Compare May 28, 2025 16:08
@Avasam Avasam requested a review from abravalheri May 28, 2025 16:08
Copy link
Contributor

@abravalheri abravalheri left a comment

Choose a reason for hiding this comment

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

Thank you very much Avasam.
I have some minor comments that I missed last time.

@@ -27,18 +28,20 @@ class develop(Command):
prefix = None
index_url = None

def run(self):
cmd = (
def run(self) -> None: # type: ignore[override] # Not including easy_install's show_deprecation argument
Copy link
Contributor

Choose a reason for hiding this comment

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

I am trying to understand this comment.

Maybe it is also a left over from merge/rebase from a time that develop extended easy_install before the recent removal in #4955?

Copy link
Contributor Author

@Avasam Avasam May 28, 2025

Choose a reason for hiding this comment

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

Indeed, this type-ignore no longer applies. This used to break the Liskov Substitution Principle.
I think we're not currently checking for unused type-ignores because of some inconsistent error codes with Python 3.8 and/or distutils.

@Avasam
Copy link
Contributor Author

Avasam commented May 28, 2025

Thanks for the reviews @abravalheri ! Only a few steps left until setuptool's public interface is on-par with TypeShed's stubs. Whilst benefiting from type-checking internally.

Co-authored-by: Anderson Bravalheri <[email protected]>
@abravalheri abravalheri merged commit 94ac34e into pypa:main May 29, 2025
24 checks passed
@Avasam Avasam deleted the Merge-typeshed-return-annotations branch May 29, 2025 14:03
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