Skip to content

Commit

Permalink
Use XDG_CACHE_HOME for PYLINTHOME (#4661)
Browse files Browse the repository at this point in the history
Closes #3878

Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com>
  • Loading branch information
e-kwsm and Pierre-Sassoulas committed Jul 28, 2021
1 parent 24d03e9 commit ae6cbd1
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 5 deletions.
2 changes: 2 additions & 0 deletions CONTRIBUTORS.txt
Expand Up @@ -524,4 +524,6 @@ contributors:

* Marcin Kurczewski (rr-): contributor

* Eisuke Kawashima (e-kwsm): contributor

* Daniel van Noord (DanielNoord): contributor
4 changes: 4 additions & 0 deletions ChangeLog
Expand Up @@ -26,6 +26,10 @@ Release date: TBA

Close #4120

* The default for ``PYLINTHOME`` is now the standard ``XDG_CACHE_HOME``, and pylint now uses ``appdirs``.

Closes #3878


What's New in Pylint 2.9.6?
===========================
Expand Down
9 changes: 7 additions & 2 deletions doc/faq.rst
Expand Up @@ -93,8 +93,13 @@ localized using the following rules:

* value of the PYLINTHOME environment variable if set

* ".pylint.d" subdirectory of the user's home directory if it is found
(not always findable on Windows platforms)
* "pylint" subdirectory of the user's XDG_CACHE_HOME if the environment variable is set, otherwise

- Linux: "~/.cache/pylint"

- Mac OS X: "~/Library/Caches/pylint"

- Windows: "C:\Users\<username>\AppData\Local\pylint"

* ".pylint.d" directory in the current directory

Expand Down
12 changes: 11 additions & 1 deletion pylint/config/__init__.py
Expand Up @@ -36,6 +36,8 @@
import pickle
import sys

import appdirs

from pylint.config.configuration_mixin import ConfigurationMixIn
from pylint.config.find_default_config_files import find_default_config_files
from pylint.config.man_help_formatter import _ManHelpFormatter
Expand Down Expand Up @@ -63,7 +65,15 @@
elif USER_HOME == "~":
PYLINT_HOME = ".pylint.d"
else:
PYLINT_HOME = os.path.join(USER_HOME, ".pylint.d")
PYLINT_HOME = appdirs.user_cache_dir("pylint")

old_home = os.path.join(USER_HOME, ".pylint.d")
if os.path.exists(old_home):
print(
f"PYLINTHOME is now '{PYLINT_HOME}' but obsolescent '{old_home}' is found; "
"you can safely remove the latter",
file=sys.stderr,
)


def _get_pdata_path(base_name, recurs):
Expand Down
6 changes: 5 additions & 1 deletion setup.cfg
Expand Up @@ -42,6 +42,7 @@ project_urls =
[options]
packages = find:
install_requires =
appdirs>=1.4.0
astroid>=2.6.5,<2.7 # (You should also upgrade requirements_test_min.txt)
isort>=4.2.5,<6
mccabe>=0.6,<0.7
Expand Down Expand Up @@ -74,14 +75,17 @@ markers =
[isort]
multi_line_output = 3
line_length = 88
known_third_party = astroid, sphinx, isort, pytest, mccabe, six, toml
known_third_party = appdirs, astroid, sphinx, isort, pytest, mccabe, six, toml
include_trailing_comma = True
skip_glob = tests/functional/**,tests/input/**,tests/extensions/data/**,tests/regrtest_data/**,tests/data/**,astroid/**,venv/**
src_paths = pylint
[mypy]
scripts_are_modules = True
[mypy-appdirs]
ignore_missing_imports = True
[mypy-astroid.*]
ignore_missing_imports = True
Expand Down
3 changes: 2 additions & 1 deletion tests/lint/unittest_lint.py
Expand Up @@ -46,6 +46,7 @@
from os.path import abspath, basename, dirname, isdir, join, sep
from shutil import rmtree

import appdirs
import pytest

from pylint import checkers, config, exceptions, interfaces, lint, testutils
Expand Down Expand Up @@ -631,7 +632,7 @@ def test_pylint_home():
if uhome == "~":
expected = ".pylint.d"
else:
expected = os.path.join(uhome, ".pylint.d")
expected = appdirs.user_cache_dir("pylint")
assert config.PYLINT_HOME == expected

try:
Expand Down

0 comments on commit ae6cbd1

Please sign in to comment.