8000 Fix potentially unbound issues in stubsabot by Avasam · Pull Request #9754 · python/typeshed · GitHub
[go: up one dir, main page]

Skip to content

Fix potentially unbound issues in stubsabot #9754

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 9 commits into from
Feb 18, 2023
Prev Previous commit
Next Next commit
Don't check the latest_release for py.typed twice
  • Loading branch information
Avasam committed Feb 18, 2023
commit 193dd1e28eb37bb8c3958ef2ddf6ef2d495986f4
9 changes: 4 additions & 5 deletions scripts/stubsabot.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,13 +170,12 @@ async def release_contains_py_typed(release_to_download: PypiReleaseDownload, *,
raise AssertionError(f"Unknown package type: {packagetype!r}")


async def find_first_release_with_py_typed(
pypi_info: PypiInfo, latest_release: PypiReleaseDownload, *, session: aiohttp.ClientSession
) -> PypiReleaseDownload | None:
if not (await release_contains_py_typed(latest_release, session=session)):
async def find_first_release_with_py_typed(pypi_info: PypiInfo, *, session: aiohttp.ClientSession) -> PypiReleaseDownload | None:
release_iter = pypi_info.releases_in_descending_order()
# If the latest release is not py.typed, assume none are.
if not (await release_contains_py_typed(release := next(release_iter), session=session)):
return None

release_iter = pypi_info.releases_in_descending_order()
first_release_with_py_typed: PypiReleaseDownload | None = None
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's not change the signature of this method and just have it assert that the return value is not None. This really should only be called with the precondition that release_contains_py_typed was True, otherwise we'll just download all packages for all time

Copy link
Collaborator

Choose a reason for hiding this comment

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

Alternatively I'd also be fine with moving release_contains_py_typed into here

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Something like 85a2d26 (#9754) ?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Wait, sorry I read a thing wrong, your change was fine as is!

while await release_contains_py_typed(release := next(release_iter), session=session):
if not release.version.is_prerelease:
Expand Down
0