Skip to content

Commit

Permalink
Move check to _fn
Browse files Browse the repository at this point in the history
  • Loading branch information
Avasam committed Jun 21, 2024
1 parent ad033e8 commit 807d7c1
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions pkg_resources/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1704,8 +1704,7 @@ def run_script(self, script_name: str, namespace: dict[str, Any]):
**locals()
),
)
if not self.egg_info:
raise TypeError("Provider is missing egg_info", self.egg_info)

script_text = self.get_metadata(script).replace('\r\n', '\n')
script_text = script_text.replace('\r', '\n')
script_filename = self._fn(self.egg_info, script)
Expand Down Expand Up @@ -1741,7 +1740,11 @@ def _listdir(self, path) -> list[str]:
"Can't perform this operation for unregistered loader type"
)

def _fn(self, base: str, resource_name: str):
def _fn(self, base: str | None, resource_name: str):
if base is None:
raise TypeError(
"`base` parameter in `_fn` is `None`. Either override this method or check the parameter first."
)
self._validate_resource_path(resource_name)
if resource_name:
return os.path.join(base, *resource_name.split('/'))
Expand Down

0 comments on commit 807d7c1

Please sign in to comment.