-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Make pkg_resources.find_nothing
return an (empty) Generator
of Distribution
#4249
Conversation
find_nothing
return an (empty) Generator
of Distribution
pkg_resources.find_nothing
return an (empty) Generator
of Distribution
7e89c92
to
59a7376
Compare
This aligns with `find_eggs_in_zip` and `find_on_path` and ensures `find_distributions` always returns a generator
59a7376
to
bc05c46
Compare
Hi @Avasam, would it make more sense that instead of changing the implementation we just consider that the If we consider the implementation, that seems to be the minimum requirement for the functions to work, isn't it? It is also more generic... So to me it makes sense to not raise the bar in terms of type specs. The documentation probably uses the term |
@abravalheri Yes it makes perfect sense. In fact going with I'd want to update the docstrings as well because "yield" is a bit misleading in Python given it has a special meaning (a meaning that is true most of the time, except in that special scenario). But if you want me to keep the docstrings as-is I can do so, my needs only really concern the type annotations. |
@Avasam would something like the following be an appropriate documentation change? diff --git i/pkg_resources/__init__.py w/pkg_resources/__init__.py
index 625d1f83d..8ee988114 100644
--- i/pkg_resources/__init__.py
+++ w/pkg_resources/__init__.py
@@ -2049,7 +2049,7 @@ def register_finder(importer_type, distribution_finder):
`importer_type` is the type or class of a PEP 302 "Importer" (sys.path item
handler), and `distribution_finder` is a callable that, passed a path
- item and the importer instance, yields ``Distribution`` instances found on
+ item and the importer instance, iterates over ``Distribution`` instances found on
that path item. See ``pkg_resources.find_on_path`` for an example."""
_distribution_finders[importer_type] = distribution_finder |
That's still not quite right, I'd say it "returns an |
Since the entire premise of this PR is wrong, and that the only change is docstring anyway. I'll avoid doing a ship of Theseus out of it and I'll just finish typing the |
Summary of changes
This aligns with
find_eggs_in_zip
andfind_on_path
and ensuresfind_distributions
always returns a generator.This was noticed when attempting to type the
pkg_resoruces
package for #2345xref python/typeshed#11512 (comment)
Pull Request Checklist
newsfragments/
.(See documentation for details)