From 5c128af61d4d46a8973eb9485aa4c9ab8acfa49f Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sat, 6 Nov 2021 11:01:18 -0400 Subject: [PATCH] Prefer contextlib.suppress to except/pass --- distutils/command/install.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/distutils/command/install.py b/distutils/command/install.py index 0db71e94..2aabf3cc 100644 --- a/distutils/command/install.py +++ b/distutils/command/install.py @@ -4,6 +4,7 @@ import sys import os +import contextlib from distutils import log from distutils.core import Command @@ -91,15 +92,13 @@ def _load_schemes(): schemes = dict(INSTALL_SCHEMES) - try: + with contextlib.supress(ImportError, AttributeError): import sysconfig sysconfig_schemes = { scheme: sysconfig.get_paths(scheme, expand=False) for scheme in sysconfig.get_scheme_names() } schemes.update(sysconfig_schemes) - except (ImportError, AttributeError): - pass return schemes