diff options
author | Ashley Whetter <AWhetter@users.noreply.github.com> | 2021-08-20 19:40:14 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-20 19:40:14 -0700 |
commit | d701a979d95c5e4ca6dd4860ab30e08880a904d0 (patch) | |
tree | 9dcd380826f5ccd25bb3b0207548762ea46abba6 | |
parent | bbc4f6690724c3fa2325d6e3e4f1e5414a27983c (diff) | |
download | pylint-git-d701a979d95c5e4ca6dd4860ab30e08880a904d0.tar.gz |
pylint does not crash when PYLINT_HOME does not exist (#4884)
Closes #4883
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | pylint/config/__init__.py | 16 |
2 files changed, 12 insertions, 8 deletions
@@ -15,9 +15,9 @@ What's New in Pylint 2.10.1? ============================ Release date: TBA -.. - Put bug fixes that should not wait for a new minor version here +* pylint does not crash when PYLINT_HOME does not exist. + Closes #4883 What's New in Pylint 2.10.0? diff --git a/pylint/config/__init__.py b/pylint/config/__init__.py index 01c3e671e..b73d43e2d 100644 --- a/pylint/config/__init__.py +++ b/pylint/config/__init__.py @@ -35,6 +35,7 @@ # For details: https://github.com/PyCQA/pylint/blob/main/LICENSE import os +import pathlib import pickle import sys from datetime import datetime @@ -86,14 +87,17 @@ else: file=sys.stderr, ) # Remove old spam prevention file - for filename in os.listdir(PYLINT_HOME): - if prefix_spam_prevention in filename: - try: - os.remove(os.path.join(PYLINT_HOME, filename)) - except OSError: - pass + if os.path.exists(PYLINT_HOME): + for filename in os.listdir(PYLINT_HOME): + if prefix_spam_prevention in filename: + try: + os.remove(os.path.join(PYLINT_HOME, filename)) + except OSError: + pass + # Create spam prevention file for today try: + pathlib.Path(PYLINT_HOME).mkdir(parents=True, exist_ok=True) with open(spam_prevention_file, "w", encoding="utf8") as f: f.write("") except Exception: # pylint: disable=broad-except |