-
Notifications
You must be signed in to change notification settings - Fork 416
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Apply repo-review suggestions #1519
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,7 +32,7 @@ def inject_dep( | |
) -> bool: | ||
logger.debug("Injecting package %s", package_spec) | ||
|
||
if not venv_dir.exists() or not next(venv_dir.iterdir()): | ||
if not venv_dir.exists() or next(venv_dir.iterdir(), None) is None: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
raise PipxError( | ||
f""" | ||
Can't inject {package_spec!r} into nonexistent Virtual Environment | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -198,11 +198,11 @@ def run( | |
# we can't parse this as a package | ||
package_name = app | ||
|
||
content = None if spec is not None else maybe_script_content(app, is_path) | ||
content = None if spec is not None else maybe_script_content(app, is_path) # type: ignore[redundant-expr] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Do we still want to defend against an actual |
||
if content is not None: | ||
run_script(content, app_args, python, pip_args, venv_args, verbose, use_cache) | ||
else: | ||
package_or_url = spec if spec is not None else app | ||
package_or_url = spec if spec is not None else app # type: ignore[redundant-expr] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same. |
||
run_package( | ||
package_name, | ||
package_or_url, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -125,7 +125,7 @@ def uninject( | |
) -> ExitCode: | ||
"""Returns pipx exit code""" | ||
|
||
if not venv_dir.exists() or not next(venv_dir.iterdir()): | ||
if not venv_dir.exists() or next(venv_dir.iterdir(), None) is None: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
raise PipxError(f"Virtual environment {venv_dir.name} does not exist.") | ||
|
||
venv = Venv(venv_dir, verbose=verbose) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -277,7 +277,7 @@ def run_pipx_command(args: argparse.Namespace, subparsers: Dict[str, argparse.Ar | |
not args.no_cache, | ||
) | ||
# We should never reach here because run() is NoReturn. | ||
return ExitCode(1) | ||
return ExitCode(1) # type: ignore[unreachable] | ||
elif args.command == "install": | ||
return commands.install( | ||
None, | ||
|
@@ -409,7 +409,7 @@ def run_pipx_command(args: argparse.Namespace, subparsers: Dict[str, argparse.Ar | |
python_flag_passed=python_flag_passed, | ||
) | ||
elif args.command == "runpip": | ||
if not venv_dir: | ||
if not venv_dir: # type: ignore[truthy-bool] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In theory, Do we still want to defend against an actual |
||
raise PipxError("Developer error: venv_dir is not defined.") | ||
return commands.run_pip(package, venv_dir, args.pipargs, args.verbose) | ||
elif args.command == "ensurepath": | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -114,7 +114,7 @@ def upgrade(self, *, pip_args: List[str], verbose: bool = False, raises: bool = | |
return | ||
|
||
if pip_args is None: | ||
pip_args = [] | ||
pip_args = [] # type: ignore[unreachable] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Do we still want to defend against an actual |
||
|
||
logger.info(f"Upgrading shared libraries in {self.root}") | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
value
is notOptional
, so in theory it cannot beNone
.Do we still want to defend against an actual
None
?