Skip to content

Commit 830cf1f

Browse files
authored
Prevent pip exception with version check (#2624)
1 parent 65a3d41 commit 830cf1f

1 file changed

Lines changed: 3 additions & 5 deletions

File tree

src/ansiblelint/config.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,6 @@ def guess_install_method() -> str:
227227
from pip._internal.metadata import get_default_environment
228228
from pip._internal.req.req_uninstall import uninstallation_paths
229229

230-
try:
231230
dist = get_default_environment().get_distribution(package_name)
232231
if dist:
233232
logging.debug("Found %s dist", dist)
@@ -236,10 +235,9 @@ def guess_install_method() -> str:
236235
else:
237236
logging.debug("Skipping %s as it is not installed.", package_name)
238237
use_pip = False
239-
except UninstallationError as exc:
240-
logging.debug(exc)
241-
use_pip = False
242-
except ImportError:
238+
except (UninstallationError, AttributeError, ImportError) as exc:
239+
# On Fedora 36, we got a AttributeError exception from pip that we want to avoid
240+
logging.debug(exc)
243241
use_pip = False
244242

245243
# We only want to recommend pip for upgrade if it looks safe to do so.

0 commit comments

Comments
 (0)