[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.
diff --git a/pylint/config/__init__.py b/pylint/config/__init__.py
index 7868ada..292b31f 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 @@
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):