Skip to content

sp-repo-review fails indeterministically if src directory contains files #451

Description

@maxnoe

I have a python project that has a compiled component, the tree looks like this:

pyproject.toml
CMakeLists.txt
src/
   package/
       __init__.py
   cpp_source_file.cpp

sp-repo-review fails sometimes with the following error:

╭───────────────────── Traceback (most recent call last) ──────────────────────╮
│ /root/.cache/pre-commit/repoo84nzjav/py_env-python3.11/bin/repo-review:8 in  │
│ <module>                                                                     │
│                                                                              │
│   5 from repo_review.__main__ import main                                    │
│   6 if __name__ == '__main__':                                               │
│   7 │   sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])     │
│ ❱ 8 │   sys.exit(main())                                                     │
│   9                                                                          │
│                                                                              │
│ /root/.cache/pre-commit/repoo84nzjav/py_env-python3.11/lib/python3.11/site-p │
│ ackages/click/core.py:1157 in __call__                                       │
│                                                                              │
│ /root/.cache/pre-commit/repoo84nzjav/py_env-python3.11/lib/python3.11/site-p │
│ ackages/rich_click/rich_command.py:152 in main                               │
│                                                                              │
│ /root/.cache/pre-commit/repoo84nzjav/py_env-python3.11/lib/python3.11/site-p │
│ ackages/click/core.py:1434 in invoke                                         │
│                                                                              │
│ /root/.cache/pre-commit/repoo84nzjav/py_env-python3.11/lib/python3.11/site-p │
│ ackages/click/core.py:783 in invoke                                          │
│                                                                              │
│ /root/.cache/pre-commit/repoo84nzjav/py_env-python3.11/lib/python3.11/site-p │
│ ackages/repo_review/__main__.py:301 in main                                  │
│                                                                              │
│   298 │                                                                      │
│   299 │   result = 0                                                         │
│   300 │   for n, package in enumerate(packages):                             │
│ ❱ 301 │   │   result |= on_each(                                             │
│   302 │   │   │   package,                                                   │
│   303 │   │   │   format_opt,                                                │
│   304 │   │   │   stderr_fmt,                                                │
│                                                                              │
│ /root/.cache/pre-commit/repoo84nzjav/py_env-python3.11/lib/python3.11/site-p │
│ ackages/repo_review/__main__.py:362 in on_each                               │
│                                                                              │
│   359 │   │   base_package = package                                         │
│   360 │   │   header = package.name                                          │
│   361 │                                                                      │
│ ❱ 362 │   families, processed = process(                                     │
│   363 │   │   base_package, select=select_list, ignore=ignore_list, subdir=p │
│   364 │   )                                                                  │
│   365                                                                        │
│                                                                              │
│ /root/.cache/pre-commit/repoo84nzjav/py_env-python3.11/lib/python3.11/site-p │
│ ackages/repo_review/processor.py:219 in process                              │
│                                                                              │
│   216 │   ts = graphlib.TopologicalSorter(graph)                             │
│   217 │   for name in ts.static_order():                                     │
│   218 │   │   if all(completed.get(n, "") == "" for n in graph[name]):       │
│ ❱ 219 │   │   │   result = apply_fixtures({"name": name, **fixtures}, tasks[ │
│   220 │   │   │   completed[name] = process_result_bool(result, tasks[name], │
│   221 │   │   else:                                                          │
│   222 │   │   │   completed[name] = None                                     │
│                                                                              │
│ /root/.cache/pre-commit/repoo84nzjav/py_env-python3.11/lib/python3.11/site-p │
│ ackages/repo_review/fixtures.py:106 in apply_fixtures                        │
│                                                                              │
│   103 │   kwargs = {                                                         │
│   104 │   │   name: value for name, value in fixtures.items() if name in sig │
│   105 │   }                                                                  │
│ ❱ 106 │   return func(**kwargs)                                              │
│   107                                                                        │
│   108                                                                        │
│   109 def collect_fixtures() -> dict[str, Callable[[Traversable], Any]]:     │
│                                                                              │
│ /root/.cache/pre-commit/repoo84nzjav/py_env-python3.11/lib/python3.11/site-p │
│ ackages/sp_repo_review/checks/general.py:88 in check                         │
│                                                                              │
│    85 │   │   src = package.joinpath("src")                                  │
│    86 │   │   if src.is_dir():                                               │
│    87 │   │   │   for pkg in src.iterdir():                                  │
│ ❱  88 │   │   │   │   if len([p for p in pkg.iterdir() if "test" in p.name]) │
│    89 │   │   │   │   │   return True                                        │
│    90 │   │   return False                                                   │
│    91                                                                        │
│                                                                              │
│ /root/.cache/pre-commit/repoo84nzjav/py_env-python3.11/lib/python3.11/site-p │
│ ackages/sp_repo_review/checks/general.py:88 in <listcomp>                    │
│                                                                              │
│    85 │   │   src = package.joinpath("src")                                  │
│    86 │   │   if src.is_dir():                                               │
│    87 │   │   │   for pkg in src.iterdir():                                  │
│ ❱  88 │   │   │   │   if len([p for p in pkg.iterdir() if "test" in p.name]) │
│    89 │   │   │   │   │   return True                                        │
│    90 │   │   return False                                                   │
│    91                                                                        │
│                                                                              │
│ /usr/local/lib/python3.11/pathlib.py:931 in iterdir                          │
│                                                                              │
│    928 │   │   """Iterate over the files in this directory.  Does not yield  │
│    929 │   │   result for the special paths '.' and '..'.                    │
│    930 │   │   """                                                           │
│ ❱  931 │   │   for name in os.listdir(self):                                 │
│    932 │   │   │   yield self._make_child_relpath(name)                      │
│    933 │                                                                     │
│    934 │   def _scandir(self):                                               │
╰──────────────────────────────────────────────────────────────────────────────╯
NotADirectoryError: [Errno 20] Not a directory: 'src/rawzfits.cpp'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions