Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use XDG_CACHE_HOME for PYLINTHOME #4661

Merged
merged 2 commits into from
Jul 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CONTRIBUTORS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -522,4 +522,6 @@ contributors:

* Marcin Kurczewski (rr-): contributor

* Eisuke Kawashima (e-kwsm): contributor

* Daniel van Noord (DanielNoord): contributor
4 changes: 4 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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")
Pierre-Sassoulas marked this conversation as resolved.
Show resolved Hide resolved
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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