Skip to content

Commit

Permalink
Avoid adding pip related messages if installation method is different
Browse files Browse the repository at this point in the history
  • Loading branch information
audgirka committed Jun 12, 2023
1 parent 519ecd6 commit c150476
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/ansiblelint/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,18 @@ def in_venv() -> bool:

def guess_install_method() -> str:
"""Guess if pip upgrade command should be used."""
# pylint: disable=import-outside-toplevel
from importlib.metadata import distribution

package_name = "ansible-lint"

try:
if distribution("ansible-lint").read_text("INSTALLER").strip() != "pip": # type: ignore[union-attr]
return ""
except PackageNotFoundError as exc:
logging.debug(exc)
return ""

pip = ""
if in_venv():
_logger.debug("Found virtualenv, assuming `pip3 install` will work.")
Expand Down

0 comments on commit c150476

Please sign in to comment.