summaryrefslogtreecommitdiff
path: root/pylint/config/find_default_config_files.py
diff options
context:
space:
mode:
authorDaniƫl van Noord <13665637+DanielNoord@users.noreply.github.com>2022-06-02 19:43:58 +0200
committerGitHub <noreply@github.com>2022-06-02 19:43:58 +0200
commitdee9de56f84837be3de915aec8c2e9629dd9c548 (patch)
treebb6970562ac3dc60932d4012797544e3a4430b53 /pylint/config/find_default_config_files.py
parentdc7b03266fad7e885da1374ac312dfc0b63ebbfd (diff)
downloadpylint-git-dee9de56f84837be3de915aec8c2e9629dd9c548.tar.gz
Don't crash if we can't find the user's home directory (#6806)
Diffstat (limited to 'pylint/config/find_default_config_files.py')
-rw-r--r--pylint/config/find_default_config_files.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/pylint/config/find_default_config_files.py b/pylint/config/find_default_config_files.py
index 595548285..36917a380 100644
--- a/pylint/config/find_default_config_files.py
+++ b/pylint/config/find_default_config_files.py
@@ -63,8 +63,12 @@ def find_default_config_files() -> Iterator[Path]:
if Path(os.environ["PYLINTRC"]).is_file():
yield Path(os.environ["PYLINTRC"]).resolve()
else:
- user_home = Path.home()
- if str(user_home) not in ("~", "/root"):
+ try:
+ user_home = Path.home()
+ except RuntimeError:
+ # If the home directory does not exist a RuntimeError will be raised
+ user_home = None
+ if user_home is not None and str(user_home) not in ("~", "/root"):
home_rc = user_home / ".pylintrc"
if home_rc.is_file():
yield home_rc.resolve()