Skip to content

Commit

Permalink
Fix typing
Browse files Browse the repository at this point in the history
Signed-off-by: Jean-Christophe Morin <jean_christophe_morin@hotmail.com>
  • Loading branch information
JeanChristopheMorinPerso committed Apr 29, 2024
1 parent e57ce92 commit 64de12b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
7 changes: 5 additions & 2 deletions src/rez_pip/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@


def isWheelPure(dist: importlib_metadata.Distribution) -> bool:
# dist.files should never be empty, but assert to silence mypy.
assert dist.files is not None

path = next(
f for f in dist.files if os.fspath(f.locate()).endswith(".dist-info/WHEEL")
)
Expand Down Expand Up @@ -72,7 +75,7 @@ def getSchemeDict(name: str, target: str) -> typing.Dict[str, str]:

def installWheel(
package: rez_pip.pip.PackageInfo,
wheelPath: pathlib.Path,
wheelPath: str,
targetPath: str,
) -> importlib_metadata.Distribution:
# TODO: Technically, target should be optional. We will always want to install in "pip install --target"
Expand All @@ -86,7 +89,7 @@ def installWheel(
)

_LOG.debug(f"Installing {wheelPath} into {targetPath!r}")
with installer.sources.WheelFile.open(wheelPath) as source:
with installer.sources.WheelFile.open(pathlib.Path(wheelPath)) as source:
installer.install(
source=source,
destination=destination,
Expand Down
2 changes: 1 addition & 1 deletion src/rez_pip/pip.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def name(self) -> str:
def version(self) -> str:
return self.metadata.version

def isDownloadRequired(self):
def isDownloadRequired(self) -> bool:
return not self.download_info.url.startswith("file://")

@property
Expand Down
10 changes: 7 additions & 3 deletions src/rez_pip/plugins/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,11 @@ def _getHookImplementations() -> typing.Dict[str, typing.List[str]]:

implementations = {}
for name, plugin in manager.list_name_plugin():
implementations[name] = [
caller.name for caller in manager.get_hookcallers(plugin)
]
hookcallers = manager.get_hookcallers(plugin)

# hookcallers will never be None because we get the names from list_name_plugin.
# But it silences mypy.
assert hookcallers is not None

implementations[name] = [caller.name for caller in hookcallers]
return implementations

0 comments on commit 64de12b

Please sign in to comment.