Skip to content

Commit d701a97

Browse files
authored
pylint does not crash when PYLINT_HOME does not exist (#4884)
Closes #4883
1 parent bbc4f66 commit d701a97

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

ChangeLog

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ What's New in Pylint 2.10.1?
1515
============================
1616
Release date: TBA
1717

18-
..
19-
Put bug fixes that should not wait for a new minor version here
18+
* pylint does not crash when PYLINT_HOME does not exist.
2019

20+
Closes #4883
2121

2222

2323
What's New in Pylint 2.10.0?

pylint/config/__init__.py

+10-6
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
# For details: https://github.com/PyCQA/pylint/blob/main/LICENSE
3636

3737
import os
38+
import pathlib
3839
import pickle
3940
import sys
4041
from datetime import datetime
@@ -86,14 +87,17 @@
8687
file=sys.stderr,
8788
)
8889
# Remove old spam prevention file
89-
for filename in os.listdir(PYLINT_HOME):
90-
if prefix_spam_prevention in filename:
91-
try:
92-
os.remove(os.path.join(PYLINT_HOME, filename))
93-
except OSError:
94-
pass
90+
if os.path.exists(PYLINT_HOME):
91+
for filename in os.listdir(PYLINT_HOME):
92+
if prefix_spam_prevention in filename:
93+
try:
94+
os.remove(os.path.join(PYLINT_HOME, filename))
95+
except OSError:
96+
pass
97+
9598
# Create spam prevention file for today
9699
try:
100+
pathlib.Path(PYLINT_HOME).mkdir(parents=True, exist_ok=True)
97101
with open(spam_prevention_file, "w", encoding="utf8") as f:
98102
f.write("")
99103
except Exception: # pylint: disable=broad-except

0 commit comments

Comments
 (0)