Skip to content
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

Don't show download count, it's always -1 for PyPI #23

Merged
merged 1 commit into from
Apr 19, 2024

Conversation

hugovk
Copy link
Contributor

@hugovk hugovk commented Apr 19, 2024

The downloads count is always -1 in the JSON response for PyPI packages, so we might as well not show it:

https://mail.python.org/pipermail/distutils-sig/2013-May/020855.html

That says 0, but it was later changed to -1 to make it more obviously not-real.

(It's possible other package indexes do return a download count, but it looks like this tool only checks PyPI, and I would expect that to be the most common one anyway.)

@@ -42,9 +42,6 @@ class PackageURL(NamedTuple):
digests: dict[str, str]
"""The digests for the URL."""

downloads: int
"""The number of downloads for the URL."""

Copy link
Owner

Choose a reason for hiding this comment

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

I'd prefer to still keep this in the class.

@@ -89,7 +86,6 @@ def from_json(cls, data: dict[str, Any]) -> "PackageURL":
return cls(
comment_text=url("comment_text"),
digests=url("digests", {}),
downloads=url("downloads", 0),
Copy link
Owner

Choose a reason for hiding this comment

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

As mentioned elsewhere, I think I'd prefer to keep this in the class.

@@ -208,7 +208,6 @@ def compose(self) -> ComposeResult:
("MD5 Digest", self._url.md5_digest, Value),
("Uploaded", self._url.upload_time_iso_8601, Value),
("Has Signature", "Yes" if self._url.has_sig else "No", Value),
("Downloads", f"{self._url.downloads:,}", Value),
Copy link
Owner

Choose a reason for hiding this comment

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

Yeah, good call. I've even said a couple of times on stream while tidying this up that I should either filter out the -1 or just plain not show it anyway now.

@hugovk
Copy link
Contributor Author

hugovk commented Apr 19, 2024

Updated!

@hugovk hugovk changed the title Remove download count, it's always -1 for PyPI Don't show download count, it's always -1 for PyPI Apr 19, 2024
@davep
Copy link
Owner

davep commented Apr 19, 2024

Awesome, thanks. I know it seems a bit daft still loading the unused stuff anyway, but I was considering a sort of "show all values" toggle at some point, perhaps, maybe, possibly.

@davep davep merged commit ca455ef into davep:main Apr 19, 2024
@hugovk hugovk deleted the rm-downloads branch April 19, 2024 19:06
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