diff options
author | Daniƫl van Noord <13665637+DanielNoord@users.noreply.github.com> | 2022-06-02 19:43:58 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-02 19:43:58 +0200 |
commit | dee9de56f84837be3de915aec8c2e9629dd9c548 (patch) | |
tree | bb6970562ac3dc60932d4012797544e3a4430b53 /pylint/config/find_default_config_files.py | |
parent | dc7b03266fad7e885da1374ac312dfc0b63ebbfd (diff) | |
download | pylint-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.py | 8 |
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() |