Skip to content

Commit

Permalink
Make find_nothing return an (empty) Generator of Distribution
Browse files Browse the repository at this point in the history
This aligns with `find_eggs_in_zip` and `find_on_path` and ensures `find_distributions` always returns a generator
  • Loading branch information
Avasam committed Feb 29, 2024
1 parent 8c45d6e commit 59a7376
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions newsfragments/4249.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Ensure `pkg_resources.find_distributions` always returns a `Generator` as per its docstring by making `pkg_resources.find_nothing` yield nothing rather than returning an empty `tuple` -- by :user:`Avasam`
9 changes: 6 additions & 3 deletions pkg_resources/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import time
import re
import types
from typing import Protocol
from typing import Generator, Protocol
import zipfile
import zipimport
import warnings
Expand Down Expand Up @@ -2089,8 +2089,11 @@ def find_eggs_in_zip(importer, path_item, only=False):
register_finder(zipimport.zipimporter, find_eggs_in_zip)


def find_nothing(importer, path_item, only=False):
return ()
def find_nothing(
importer, path_item, only=False
) -> Generator["Distribution", None, None]:
return
yield


register_finder(object, find_nothing)
Expand Down

0 comments on commit 59a7376

Please sign in to comment.