Path 1: 1 calls (0.5)

PosixPath (1)

1def _warn_about_old_home(pylint_home: pathlib.Path) -> None:
2    """Warn users about the old pylint home being deprecated.
3
4    The spam prevention mechanism is due to pylint being used in parallel by
5    pre-commit, and the message being spammy in this context
6    Also if you work with an old version of pylint that recreates the
7    old pylint home, you can get the old message for a long time.
8    """
9    prefix_spam_prevention = "pylint_warned_about_old_cache_already"
10    spam_prevention_file = pathlib.Path(pylint_home) / datetime.now().strftime(
11        prefix_spam_prevention + "_%Y-%m-%d.temp"
12    )
13    old_home = pathlib.Path(USER_HOME) / OLD_DEFAULT_PYLINT_HOME
14
15    if old_home.exists() and not spam_prevention_file.exists():
16        print(
17            f"PYLINTHOME is now '{pylint_home}' but obsolescent '{old_home}' is found; "
18            "you can safely remove the latter",
19            file=sys.stderr,
20        )
21
22        # Remove old spam prevention file
23        if pylint_home.exists():
24            for filename in pylint_home.iterdir():
25                if prefix_spam_prevention in str(filename):
26                    try:
27                        os.remove(pylint_home / filename)
28                    except OSError:  # pragma: no cover
29                        pass
30
31        # Create spam prevention file for today
32        try:
33            pylint_home.mkdir(parents=True, exist_ok=True)
34            with open(spam_prevention_file, "w", encoding="utf8") as f:
35                f.write("")
36        except Exception as exc:  # pragma: no cover  # pylint: disable=broad-except
37            print(
38                "Can't write the file that was supposed to "
39                f"prevent 'pylint.d' deprecation spam in {pylint_home} because of {exc}."
40            )
            

Path 2: 1 calls (0.5)

PosixPath (1)

1def _warn_about_old_home(pylint_home: pathlib.Path) -> None:
2    """Warn users about the old pylint home being deprecated.
3
4    The spam prevention mechanism is due to pylint being used in parallel by
5    pre-commit, and the message being spammy in this context
6    Also if you work with an old version of pylint that recreates the
7    old pylint home, you can get the old message for a long time.
8    """
9    prefix_spam_prevention = "pylint_warned_about_old_cache_already"
10    spam_prevention_file = pathlib.Path(pylint_home) / datetime.now().strftime(
11        prefix_spam_prevention + "_%Y-%m-%d.temp"
12    )
13    old_home = pathlib.Path(USER_HOME) / OLD_DEFAULT_PYLINT_HOME
14
15    if old_home.exists() and not spam_prevention_file.exists():
16        print(
17            f"PYLINTHOME is now '{pylint_home}' but obsolescent '{old_home}' is found; "
18            "you can safely remove the latter",
19            file=sys.stderr,
20        )
21
22        # Remove old spam prevention file
23        if pylint_home.exists():
24            for filename in pylint_home.iterdir():
25                if prefix_spam_prevention in str(filename):
26                    try:
27                        os.remove(pylint_home / filename)
28                    except OSError:  # pragma: no cover
29                        pass
30
31        # Create spam prevention file for today
32        try:
33            pylint_home.mkdir(parents=True, exist_ok=True)
34            with open(spam_prevention_file, "w", encoding="utf8") as f:
35                f.write("")
36        except Exception as exc:  # pragma: no cover  # pylint: disable=broad-except
37            print(
38                "Can't write the file that was supposed to "
39                f"prevent 'pylint.d' deprecation spam in {pylint_home} because of {exc}."
40            )