diff --git a/newsfragments/4249.bugfix.rst b/newsfragments/4249.bugfix.rst new file mode 100644 index 00000000000..555feb1e6a5 --- /dev/null +++ b/newsfragments/4249.bugfix.rst @@ -0,0 +1 @@ +Ensure `find_distributions` always returns a `Generator` as per its docstring by making `find_nothing` yield nothing rather than returning an empty `tuple` -- by :user:`Avasam` diff --git a/pkg_resources/__init__.py b/pkg_resources/__init__.py index 10c6a9cd060..a88a687becb 100644 --- a/pkg_resources/__init__.py +++ b/pkg_resources/__init__.py @@ -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 @@ -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)