From f93a094256d4c2946768a7ed38302a35944a4f88 Mon Sep 17 00:00:00 2001 From: Avasam Date: Tue, 27 Feb 2024 23:19:18 -0500 Subject: [PATCH 1/3] Return an empty list by default in `ResourceManager.cleanup_resources` Subclasses are expected to return a list. There's no mention of this method potentially returning `None` in the docstring. --- pkg_resources/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg_resources/__init__.py b/pkg_resources/__init__.py index 10c6a9cd06..f2e5bb3645 100644 --- a/pkg_resources/__init__.py +++ b/pkg_resources/__init__.py @@ -1339,7 +1339,7 @@ def set_extraction_path(self, path): self.extraction_path = path - def cleanup_resources(self, force=False): + def cleanup_resources(self, force=False) -> list[str]: """ Delete all extracted resource files and directories, returning a list of the file and directory names that could not be successfully removed. @@ -1351,6 +1351,7 @@ def cleanup_resources(self, force=False): directory used for extractions. """ # XXX + return [] def get_default_cache(): From 29b36fa20c0350c3c998511890e6f578d91f4a87 Mon Sep 17 00:00:00 2001 From: Avasam Date: Tue, 27 Feb 2024 23:24:08 -0500 Subject: [PATCH 2/3] Create 4244.bugfix.rst --- newsfragments/4244.bugfix.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 newsfragments/4244.bugfix.rst diff --git a/newsfragments/4244.bugfix.rst b/newsfragments/4244.bugfix.rst new file mode 100644 index 0000000000..5d606de718 --- /dev/null +++ b/newsfragments/4244.bugfix.rst @@ -0,0 +1 @@ +Return an empty `list` by default in ``pkg_resources.ResourceManager.cleanup_resources`` -- by :user:`Avasam` From 5b538e1879edaa574a3c4cb7119bbddf3ee6cc9d Mon Sep 17 00:00:00 2001 From: Avasam Date: Tue, 27 Feb 2024 23:38:06 -0500 Subject: [PATCH 3/3] Update __init__.py --- pkg_resources/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg_resources/__init__.py b/pkg_resources/__init__.py index f2e5bb3645..67883b11f1 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 List, Protocol import zipfile import zipimport import warnings @@ -1339,7 +1339,7 @@ def set_extraction_path(self, path): self.extraction_path = path - def cleanup_resources(self, force=False) -> list[str]: + def cleanup_resources(self, force=False) -> List[str]: """ Delete all extracted resource files and directories, returning a list of the file and directory names that could not be successfully removed.