Skip to content

Commit

Permalink
Create a OLD_DEFAULT_PYLINT_HOME constants
Browse files Browse the repository at this point in the history
  • Loading branch information
Pierre-Sassoulas committed Oct 24, 2021
1 parent f409218 commit c39a7f5
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
6 changes: 3 additions & 3 deletions pylint/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
from pylint.config.option_manager_mixin import OptionsManagerMixIn
from pylint.config.option_parser import OptionParser
from pylint.config.options_provider_mixin import OptionsProviderMixIn, UnsupportedAction
from pylint.constants import DEFAULT_PYLINT_HOME
from pylint.constants import DEFAULT_PYLINT_HOME, OLD_DEFAULT_PYLINT_HOME
from pylint.utils import LinterStats

__all__ = [
Expand All @@ -67,7 +67,7 @@
if USER_HOME == "~":
USER_HOME = os.path.dirname(PYLINT_HOME)
elif USER_HOME == "~":
PYLINT_HOME = ".pylint.d"
PYLINT_HOME = OLD_DEFAULT_PYLINT_HOME
else:
PYLINT_HOME = DEFAULT_PYLINT_HOME
# The spam prevention is due to pylint being used in parallel by
Expand All @@ -79,7 +79,7 @@
PYLINT_HOME,
datetime.now().strftime(prefix_spam_prevention + "_%Y-%m-%d.temp"),
)
old_home = os.path.join(USER_HOME, ".pylint.d")
old_home = os.path.join(USER_HOME, OLD_DEFAULT_PYLINT_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; "
Expand Down
3 changes: 3 additions & 0 deletions pylint/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@
# on all project using [MASTER] in their rcfile.
MAIN_CHECKER_NAME = "master"

# pylint: disable-next=fixme
# TODO Remove in 3.0 with all the surrounding code
OLD_DEFAULT_PYLINT_HOME = ".pylint.d"
DEFAULT_PYLINT_HOME = platformdirs.user_cache_dir("pylint")


Expand Down
5 changes: 3 additions & 2 deletions tests/lint/unittest_lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
MSG_STATE_CONFIDENCE,
MSG_STATE_SCOPE_CONFIG,
MSG_STATE_SCOPE_MODULE,
OLD_DEFAULT_PYLINT_HOME,
)
from pylint.exceptions import InvalidMessageError
from pylint.lint import ArgumentPreprocessingError, PyLinter, Run, preprocess_options
Expand Down Expand Up @@ -668,13 +669,13 @@ def pop_pylintrc() -> None:
def test_pylint_home() -> None:
uhome = os.path.expanduser("~")
if uhome == "~":
expected = ".pylint.d"
expected = OLD_DEFAULT_PYLINT_HOME
else:
expected = platformdirs.user_cache_dir("pylint")
assert config.PYLINT_HOME == expected

try:
pylintd = join(tempfile.gettempdir(), ".pylint.d")
pylintd = join(tempfile.gettempdir(), OLD_DEFAULT_PYLINT_HOME)
os.environ["PYLINTHOME"] = pylintd
try:
reload(config)
Expand Down

0 comments on commit c39a7f5

Please sign in to comment.