summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPierre Sassoulas <pierre.sassoulas@gmail.com>2021-08-20 21:26:42 +0200
committerPierre Sassoulas <pierre.sassoulas@gmail.com>2021-08-20 21:46:46 +0200
commit56fdadb1faa9e42a15efe8e8b2b3d373270d88f4 (patch)
tree572a2bfdfdec996775a00b5aa07c717b88774c15
parenta3464cb741dbf3481d550f3784295710c4f1fd94 (diff)
downloadpylint-git-56fdadb1faa9e42a15efe8e8b2b3d373270d88f4.tar.gz
[PYLINT-HOME change] Less spam when using pylint in parallel
The spam prevention is due to pylint being used in parallel by pre-commit, and the message being spammy in this context Also if you work with old version of pylint that recreate the old pylint home, you can get the old message for a long time.
-rw-r--r--pylint/config/__init__.py23
1 files changed, 21 insertions, 2 deletions
diff --git a/pylint/config/__init__.py b/pylint/config/__init__.py
index 7868ada49..292b31f41 100644
--- a/pylint/config/__init__.py
+++ b/pylint/config/__init__.py
@@ -35,6 +35,7 @@
import os
import pickle
import sys
+from datetime import datetime
import appdirs
@@ -66,14 +67,32 @@ elif USER_HOME == "~":
PYLINT_HOME = ".pylint.d"
else:
PYLINT_HOME = appdirs.user_cache_dir("pylint")
-
+ # The spam prevention is due to pylint being used in parallel by
+ # pre-commit, and the message being spammy in this context
+ # Also if you work with old version of pylint that recreate the
+ # old pylint home, you can get the old message for a long time.
+ prefix_spam_prevention = "pylint_warned_about_old_cache_already"
+ spam_prevention_file = os.path.join(
+ PYLINT_HOME,
+ datetime.now().strftime(prefix_spam_prevention + "_%Y-%m-%d.temp"),
+ )
old_home = os.path.join(USER_HOME, ".pylint.d")
- if os.path.exists(old_home):
+ if os.path.exists(old_home) and not os.path.exists(spam_prevention_file):
print(
f"PYLINTHOME is now '{PYLINT_HOME}' but obsolescent '{old_home}' is found; "
"you can safely remove the latter",
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
+ # Create spam prevention file for today
+ with open(spam_prevention_file, "w", encoding="utf8") as f:
+ f.write("")
def _get_pdata_path(base_name, recurs):