Skip to content

Commit

Permalink
fix mypy lint error
Browse files Browse the repository at this point in the history
  • Loading branch information
tianweidut committed Oct 11, 2022
1 parent 36a3a61 commit 58e93f7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
2 changes: 1 addition & 1 deletion client/starwhale/api/_impl/dataset/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ def _copy_files(
if _dest_path.resolve() == _obj_path:
continue
else:
_dest_path.unlink(missing_ok=True)
_dest_path.unlink()

_dest_path.symlink_to(_obj_path)

Expand Down
23 changes: 15 additions & 8 deletions client/starwhale/utils/venv.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
_ConfigsT = t.Optional[t.Dict[str, t.Dict[str, t.Union[str, t.List[str]]]]]
_DepsT = t.Optional[t.Dict[str, t.Union[t.List[str], str]]]
_PipConfigT = t.Optional[t.Dict[str, t.Union[str, t.List[str]]]]
_PipReqT = t.Union[str, Path, PosixPath]


class EnvTarType:
Expand Down Expand Up @@ -107,12 +108,18 @@ def _do_pip_install_req(
_hosts: t.List[str] = [_env.get("SW_PYPI_TRUSTED_HOST", "")]
_index: str = _env.get("SW_PYPI_INDEX_URL", "")

list_to_str: t.Callable[[t.Union[str, list]], str] = (
lambda x: " ".join(x) if isinstance(x, list) else x
)

_pip_index_url = list_to_str(pip_config.get("index_url", ""))
if _index:
_extra_index.append(pip_config.get("index_url", ""))
_extra_index.append(_pip_index_url)
else:
_index = pip_config.get("index_url", "")
_extra_index.extend(pip_config.get("extra_index_url", []))
_hosts.extend(pip_config.get("trusted_host", []))
_index = _pip_index_url

_extra_index.append(list_to_str(pip_config.get("extra_index_url", [])))
_hosts.append(list_to_str(pip_config.get("trusted_host", [])))

_s_index = _index.strip()
_s_extra_index = " ".join([s for s in _extra_index if s.strip()])
Expand Down Expand Up @@ -144,7 +151,7 @@ def _do_pip_install_req(

def venv_install_req(
venvdir: t.Union[str, Path],
req: t.Union[str, Path],
req: _PipReqT,
enable_pre: bool = False,
pip_config: _PipConfigT = None,
) -> None:
Expand Down Expand Up @@ -383,7 +390,7 @@ def conda_export(
if prefix:
cmd += ["--prefix", prefix]

cmd += ["--file", lock_fpath]
cmd += ["--file", str(lock_fpath)]
check_call(cmd)


Expand Down Expand Up @@ -856,10 +863,10 @@ def iter_pip_reqs(
workdir: Path,
wheels: t.Optional[t.List[str]],
deps: _DepsT,
) -> t.Generator[t.Union[str, Path, PosixPath], None, None]:
) -> t.Generator[_PipReqT, None, None]:
from starwhale.base.type import RuntimeArtifactType

reqs = []
reqs: t.List[_PipReqT] = []
deps = deps or {}
for _pf in deps.get("pip_files", []):
reqs.append(workdir / RuntimeArtifactType.DEPEND / _pf)
Expand Down

0 comments on commit 58e93f7

Please sign in to comment.