Skip to content

Commit 59a7376

Browse files
committed
Make find_nothing return an (empty) Generator of Distribution
This aligns with `find_eggs_in_zip` and `find_on_path` and ensures `find_distributions` always returns a generator
1 parent 8c45d6e commit 59a7376

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

newsfragments/4249.bugfix.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
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`

pkg_resources/__init__.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
import time
2828
import re
2929
import types
30-
from typing import Protocol
30+
from typing import Generator, Protocol
3131
import zipfile
3232
import zipimport
3333
import warnings
@@ -2089,8 +2089,11 @@ def find_eggs_in_zip(importer, path_item, only=False):
20892089
register_finder(zipimport.zipimporter, find_eggs_in_zip)
20902090

20912091

2092-
def find_nothing(importer, path_item, only=False):
2093-
return ()
2092+
def find_nothing(
2093+
importer, path_item, only=False
2094+
) -> Generator["Distribution", None, None]:
2095+
return
2096+
yield
20942097

20952098

20962099
register_finder(object, find_nothing)

0 commit comments

Comments
 (0)