From dbcf928e5c9b3bc87b63e305e75046a91eade6c7 Mon Sep 17 00:00:00 2001 From: Pierre Sassoulas Date: Thu, 1 Apr 2021 21:27:12 +0200 Subject: [PATCH] Factorize checks in expand_modules --- pylint/lint/expand_modules.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pylint/lint/expand_modules.py b/pylint/lint/expand_modules.py index dd59f7dcb..9848f4136 100644 --- a/pylint/lint/expand_modules.py +++ b/pylint/lint/expand_modules.py @@ -50,11 +50,11 @@ def expand_modules(files_or_modules, ignore_list, ignore_list_re): errors = [] path = sys.path.copy() for something in files_or_modules: - if os.path.basename(something) in ignore_list: + basename = os.path.basename(something) + if basename in ignore_list or _basename_in_ignore_list_re( + basename, ignore_list_re + ): continue - if _basename_in_ignore_list_re(os.path.basename(something), ignore_list_re): - continue - module_path = get_python_path(something) additional_search_path = [".", module_path] + path if os.path.exists(something): @@ -64,7 +64,7 @@ def expand_modules(files_or_modules, ignore_list, ignore_list_re): modutils.modpath_from_file(something, path=additional_search_path) ) except ImportError: - modname = os.path.splitext(os.path.basename(something))[0] + modname = os.path.splitext(basename)[0] if os.path.isdir(something): filepath = os.path.join(something, "__init__.py") else: