terrencepreilly / darglint

A python documentation linter which checks that the docstring description matches the definition.
MIT License
482 stars 41 forks source link

Searching config file results in Permission Error #124

Closed pawamoy closed 4 years ago

pawamoy commented 4 years ago

I ran flakehell with wemake-python-styleguide installed, which depends on darglint.

It crashed with this exception (click to see) ``` Traceback (most recent call last): File "/home/ldap/user/.cache/pypoetry/virtualenvs/testing-NP9KOKbc-py3.6/lib/python3.6/site-packages/flake8/plugins/manager.py", line 157, in load_plugin self._load() File "/home/ldap/user/.cache/pypoetry/virtualenvs/testing-NP9KOKbc-py3.6/lib/python3.6/site-packages/flake8/plugins/manager.py", line 134, in _load self._plugin = self.entry_point.load() File "/home/ldap/user/.cache/pypoetry/virtualenvs/testing-NP9KOKbc-py3.6/lib/python3.6/site-packages/importlib_metadata/__init__.py", line 105, in load module = import_module(match.group('module')) File "/home/ldap/user/.pyenv/versions/3.6.11/lib/python3.6/importlib/__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "", line 994, in _gcd_import File "", line 971, in _find_and_load File "", line 955, in _find_and_load_unlocked File "", line 665, in _load_unlocked File "", line 678, in exec_module File "", line 219, in _call_with_frames_removed File "/home/ldap/user/.cache/pypoetry/virtualenvs/testing-NP9KOKbc-py3.6/lib/python3.6/site-packages/darglint/flake8_entry.py", line 10, in from .function_description import ( File "/home/ldap/user/.cache/pypoetry/virtualenvs/testing-NP9KOKbc-py3.6/lib/python3.6/site-packages/darglint/function_description.py", line 17, in from .analysis.raise_visitor import ( File "/home/ldap/user/.cache/pypoetry/virtualenvs/testing-NP9KOKbc-py3.6/lib/python3.6/site-packages/darglint/analysis/raise_visitor.py", line 15, in from ..config import get_logger File "/home/ldap/user/.cache/pypoetry/virtualenvs/testing-NP9KOKbc-py3.6/lib/python3.6/site-packages/darglint/config.py", line 380, in _config = get_config_from_file() File "/home/ldap/user/.cache/pypoetry/virtualenvs/testing-NP9KOKbc-py3.6/lib/python3.6/site-packages/darglint/config.py", line 373, in get_config_from_file filename = find_config_file() File "/home/ldap/user/.cache/pypoetry/virtualenvs/testing-NP9KOKbc-py3.6/lib/python3.6/site-packages/darglint/config.py", line 359, in find_config_file possible_config_filename = find_config_file_in_path(path) File "/home/ldap/user/.cache/pypoetry/virtualenvs/testing-NP9KOKbc-py3.6/lib/python3.6/site-packages/darglint/config.py", line 333, in find_config_file_in_path filenames = os.listdir(path) PermissionError: [Errno 13] Permission denied: '/home/ldap' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/home/ldap/user/.cache/pypoetry/virtualenvs/testing-NP9KOKbc-py3.6/bin/flakehell", line 8, in sys.exit(entrypoint()) File "/home/ldap/user/.cache/pypoetry/virtualenvs/testing-NP9KOKbc-py3.6/lib/python3.6/site-packages/flakehell/_cli.py", line 42, in entrypoint exit_code, msg = main(argv) File "/home/ldap/user/.cache/pypoetry/virtualenvs/testing-NP9KOKbc-py3.6/lib/python3.6/site-packages/flakehell/_cli.py", line 34, in main return COMMANDS[command_name](argv=argv[1:]) File "/home/ldap/user/.cache/pypoetry/virtualenvs/testing-NP9KOKbc-py3.6/lib/python3.6/site-packages/flakehell/commands/_lint.py", line 12, in lint_command app.run(argv) File "/home/ldap/user/.cache/pypoetry/virtualenvs/testing-NP9KOKbc-py3.6/lib/python3.6/site-packages/flake8/main/application.py", line 360, in run self._run(argv) File "/home/ldap/user/.cache/pypoetry/virtualenvs/testing-NP9KOKbc-py3.6/lib/python3.6/site-packages/flake8/main/application.py", line 347, in _run self.initialize(argv) File "/home/ldap/user/.cache/pypoetry/virtualenvs/testing-NP9KOKbc-py3.6/lib/python3.6/site-packages/flake8/main/application.py", line 328, in initialize self.find_plugins(config_finder) File "/home/ldap/user/.cache/pypoetry/virtualenvs/testing-NP9KOKbc-py3.6/lib/python3.6/site-packages/flakehell/_patched/_app.py", line 165, in find_plugins self.check_plugins.load_plugins() File "/home/ldap/user/.cache/pypoetry/virtualenvs/testing-NP9KOKbc-py3.6/lib/python3.6/site-packages/flake8/plugins/manager.py", line 415, in load_plugins plugins = list(self.manager.map(load_plugin)) File "/home/ldap/user/.cache/pypoetry/virtualenvs/testing-NP9KOKbc-py3.6/lib/python3.6/site-packages/flakehell/_patched/_plugins.py", line 51, in map yield func(plugin, *args, **kwargs) File "/home/ldap/user/.cache/pypoetry/virtualenvs/testing-NP9KOKbc-py3.6/lib/python3.6/site-packages/flake8/plugins/manager.py", line 413, in load_plugin return plugin.load_plugin() File "/home/ldap/user/.cache/pypoetry/virtualenvs/testing-NP9KOKbc-py3.6/lib/python3.6/site-packages/flake8/plugins/manager.py", line 164, in load_plugin raise failed_to_load flake8.exceptions.FailedToLoadPlugin: Flake8 failed to load plugin "DAR" due to [Errno 13] Permission denied: '/home/ldap'. ```

As we can see, it's triggered by the function searching for a config file. It happens that my user account doesn't have read permission on /home/ldap, so by walking the filesystem up, we get a permission error.

I think this error could be caught and ignored to continue walking up.

pawamoy commented 4 years ago

I'll go ahead and close this even if it's not released yet :slightly_smiling_face: