From 1dd73cd467bb8526d6fdebfadf9a379a9e50bf34 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Mon, 6 Jan 2025 15:19:42 -0800 Subject: [PATCH] pylint: simplify PYLINTRC setup The os.path.isfile(RC_FILE) check isn't necessary because RC_FILE always exists -- it's checking for a static file in depot_tools. os.environ.setdefault('PYLINTRC',...) is the same thing as checking 'PYLINTRC' in os.environ first. Use that to simplify and drop the if entirely. Change-Id: Ib1fb8323c9bceebc5b22484988e9794586aa5e9a Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6150451 Auto-Submit: Mike Frysinger Reviewed-by: Gavin Mak Commit-Queue: Gavin Mak --- pylint_main.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pylint_main.py b/pylint_main.py index f72e4e41b..a146370e5 100755 --- a/pylint_main.py +++ b/pylint_main.py @@ -41,8 +41,7 @@ def main(argv): # their own PYLINTRC, or set an empty PYLINTRC to use pylint's normal config # file resolution, which would include the "more global" options that are # normally overridden by the depot_tools config. - if os.path.isfile(RC_FILE) and 'PYLINTRC' not in os.environ: - os.environ['PYLINTRC'] = RC_FILE + os.environ.setdefault('PYLINTRC', RC_FILE) # This import has to happen after PYLINTRC is set because the module tries # to resolve the config file location on load.