-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Changes from 1 commit
b78eff7
20720cc
51251fa
5262fe9
1c0ce24
85a2d26
286823b
193dd1e
b95d93b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -170,8 +170,9 @@ 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, *, session: aiohttp.ClientSession) -> PypiReleaseDownload: | ||
async def find_first_release_with_py_typed(pypi_info: PypiInfo, *, session: aiohttp.ClientSession) -> PypiReleaseDownload | None: | ||
release_iter = pypi_info.releases_in_descending_order() | ||
first_release_with_py_typed: PypiReleaseDownload | None = None | ||
while await release_contains_py_typed(release := next(release_iter), session=session): | ||
if not release.version.is_prerelease: | ||
first_release_with_py_typed = release | ||
|
@@ -418,10 +419,12 @@ async def determine_action(stub_path: Path, session: aiohttp.ClientSession) -> U | |
if latest_version in spec: | ||
return NoUpdate(stub_info.distribution, "up to date") | ||
|
||
obsolete_since: PypiReleaseDownload | None = None | ||
is_obsolete = await release_contains_py_typed(latest_release, session=session) | ||
if is_obsolete: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: let's get rid of is_obsolete and directly There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Alright, wasn't sure if you'd like to keep the variable name just for readability. |
||
first_release_with_py_typed = await find_first_release_with_py_typed(pypi_info, session=session) | ||
relevant_version = version_obsolete_since = first_release_with_py_typed.version | ||
obsolete_since = await find_first_release_with_py_typed(pypi_info, session=session) | ||
assert obsolete_since is not None | ||
relevant_version = obsolete_since.version | ||
else: | ||
relevant_version = latest_version | ||
|
||
|
@@ -437,23 +440,21 @@ async def determine_action(stub_path: Path, session: aiohttp.ClientSession) -> U | |
if diff_info is not None: | ||
github_repo_path, old_tag, new_tag, diff_url = diff_info | ||
links["Diff"] = diff_url | ||
diff_analysis = await analyze_diff( | ||
github_repo_path=github_repo_path, stub_path=stub_path, old_tag=old_tag, new_tag=new_tag, session=session | ||
) | ||
else: | ||
diff_analysis = None | ||
|
||
if is_obsolete: | ||
if obsolete_since: | ||
return Obsolete( | ||
stub_info.distribution, | ||
stub_path, | ||
obsolete_since_version=str(version_obsolete_since), | ||
obsolete_since_date=first_release_with_py_typed.upload_date, | ||
obsolete_since_version=str(obsolete_since.version), | ||
obsolete_since_date=obsolete_since.upload_date, | ||
links=links, | ||
) | ||
|
||
if diff_info is None: | ||
diff_analysis: DiffAnalysis | None = None | ||
else: | ||
diff_analysis = await analyze_diff( | ||
github_repo_path=github_repo_path, stub_path=stub_path, old_tag=old_tag, new_tag=new_tag, session=session | ||
) | ||
|
||
return Update( | ||
distribution=stub_info.distribution, | ||
stub_path=stub_path, | ||
|
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.
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
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.
Alternatively I'd also be fine with moving release_contains_py_typed into here
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.
Something like
85a2d26
(#9754) ?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.
Wait, sorry I read a thing wrong, your change was fine as is!