NathanVaughn/pyleft

Support directories that end in .py/.pyi

uneos-papr opened this issue · 3 comments

Running pyleft on a repository tree that contains a folder that ends on .py, will crash pyleft.

Traceback (most recent call last):
  File "/usr/local/python/current/bin/pyleft", line 8, in <module>
    sys.exit(run())
             ^^^^^
  File "/usr/local/python/3.11.3/lib/python3.11/site-packages/pyleft/console.py", line 13, in run
    all_issues = pyleft.api.main()
                 ^^^^^^^^^^^^^^^^^
  File "/usr/local/python/3.11.3/lib/python3.11/site-packages/pyleft/api.py", line 182, in main
    all_issues.extend(check_file(file))
                      ^^^^^^^^^^^^^^^^
  File "/usr/local/python/3.11.3/lib/python3.11/site-packages/pyleft/api.py", line 160, in check_file
    file_content = file.read_text(encoding="utf-8").splitlines()
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/python/3.11.3/lib/python3.11/pathlib.py", line 1058, in read_text
    with self.open(mode='r', encoding=encoding, errors=errors) as f:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/python/3.11.3/lib/python3.11/pathlib.py", line 1044, in open
    return io.open(self, mode, buffering, encoding, errors, newline)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
IsADirectoryError: [Errno 21] Is a directory: '/workspaces/.../tests/test_routers_document.py'

Results from these patterns here should only be added if they are actual files or symlinks to files

all_files.update(raw_path_obj.glob("**/*.py"))
all_files.update(raw_path_obj.glob("**/*.pyi"))

Fixed in 1.2.2

Thank you for fixing this so quickly!