Skip to content

PC191 raises TypeError if no ruff config and --show-fixes not in pre-commit config #745

@mfisher87

Description

@mfisher87

sp-repo-review doesn't like this repo (github.com/continuous-dems/fetchez) at commit a00be597f010cfb27e82f9548f8948aefb08af73. I ran with no arguments and:

$ sp-repo-review .
╭───────────────────────────────────────────────────────────────────────────── Traceback (most recent call last) ─────────────────────────────────────────────────────────────────────────────╮
│ /home/robatt/.local/bin/sp-repo-review:10 in <module>                                                                                                                                       │
│                                                                                                                                                                                             │
│    7 │   │   sys.argv[0] = sys.argv[0][:-11]                                                                                                                                                │
│    8 │   elif sys.argv[0].endswith(".exe"):                                                                                                                                                 │
│    9 │   │   sys.argv[0] = sys.argv[0][:-4]                                                                                                                                                 │
│ ❱ 10 │   sys.exit(main())                                                                                                                                                                   │
│   11                                                                                                                                                                                        │
│                                                                                                                                                                                             │
│ /home/robatt/.local/share/uv/tools/sp-repo-review/lib/python3.14/site-packages/click/core.py:1485 in __call__                                                                               │
│                                                                                                                                                                                             │
│ /home/robatt/.local/share/uv/tools/sp-repo-review/lib/python3.14/site-packages/click/core.py:1406 in main                                                                                   │
│                                                                                                                                                                                             │
│ /home/robatt/.local/share/uv/tools/sp-repo-review/lib/python3.14/site-packages/click/core.py:1269 in invoke                                                                                 │
│                                                                                                                                                                                             │
│ /home/robatt/.local/share/uv/tools/sp-repo-review/lib/python3.14/site-packages/click/core.py:824 in invoke                                                                                  │
│                                                                                                                                                                                             │
│ /home/robatt/.local/share/uv/tools/sp-repo-review/lib/python3.14/site-packages/repo_review/__main__.py:388 in main                                                                          │
│                                                                                                                                                                                             │
│   385 │                                                                                                                                                                                     │
│   386 │   result = 0                                                                                                                                                                        │
│   387 │   for n, package in enumerate(packages):                                                                                                                                            │
│ ❱ 388 │   │   result |= on_each(                                                                                                                                                            │
│   389 │   │   │   package,                                                                                                                                                                  │
│   390 │   │   │   format_opt,                                                                                                                                                               │
│   391 │   │   │   stderr_fmt,                                                                                                                                                               │
│                                                                                                                                                                                             │
│ /home/robatt/.local/share/uv/tools/sp-repo-review/lib/python3.14/site-packages/repo_review/__main__.py:455 in on_each                                                                       │
│                                                                                                                                                                                             │
│   452 │   │   base_package = package                                                                                                                                                        │
│   453 │   │   header = package.name                                                                                                                                                         │
│   454 │                                                                                                                                                                                     │
│ ❱ 455 │   families, processed = process(                                                                                                                                                    │
│   456 │   │   base_package,                                                                                                                                                                 │
│   457 │   │   select=select_list,                                                                                                                                                           │
│   458 │   │   ignore=ignore_list,                                                                                                                                                           │
│                                                                                                                                                                                             │
│ /home/robatt/.local/share/uv/tools/sp-repo-review/lib/python3.14/site-packages/repo_review/processor.py:251 in process                                                                      │
│                                                                                                                                                                                             │
│   248 │   ts = graphlib.TopologicalSorter(graph)                                                                                                                                            │
│   249 │   for name in ts.static_order():                                                                                                                                                    │
│   250 │   │   if all(completed.get(n, "") == "" for n in graph[name]):                                                                                                                      │
│ ❱ 251 │   │   │   result = apply_fixtures({"name": name, **fixtures_copy}, tasks[name].check)                                                                                               │
│   252 │   │   │   completed[name] = process_result_bool(result, tasks[name], name)                                                                                                          │
│   253 │   │   │   if fixtures != fixtures_copy:                                                                                                                                             │
│   254 │   │   │   │   fixtures_copy = copy.deepcopy(fixtures)                                                                                                                               │
│                                                                                                                                                                                             │
│ /home/robatt/.local/share/uv/tools/sp-repo-review/lib/python3.14/site-packages/repo_review/fixtures.py:105 in apply_fixtures                                                                │
│                                                                                                                                                                                             │
│   102 │   kwargs = {                                                                                                                                                                        │
│   103 │   │   name: value for name, value in fixtures.items() if name in signature.parameters                                                                                               │
│   104 │   }                                                                                                                                                                                 │
│ ❱ 105 │   return func(**kwargs)                                                                                                                                                             │
│   106                                                                                                                                                                                       │
│   107                                                                                                                                                                                       │
│   108 def collect_fixtures() -> dict[str, Callable[[Traversable], Any]]:                                                                                                                    │
│                                                                                                                                                                                             │
│ /home/robatt/.local/share/uv/tools/sp-repo-review/lib/python3.14/site-packages/sp_repo_review/checks/precommit.py:164 in check                                                              │
│                                                                                                                                                                                             │
│   161 │   │   │   │   │   │   and "args" in hook                                                                                                                                            │
│   162 │   │   │   │   │   │   and "--fix" in hook["args"]                                                                                                                                   │
│   163 │   │   │   │   │   ):                                                                                                                                                                │
│ ❱ 164 │   │   │   │   │   │   return "--show-fixes" in hook["args"] or "show-fixes" in ruff                                                                                                 │
│   165 │   │   │   │   return None                                                                                                                                                           │
│   166 │   │   return False                                                                                                                                                                  │
│   167                                                                                                                                                                                       │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
TypeError: argument of type 'NoneType' is not a container or iterable

I did some print debugging and ruff has value None. hook["args"] has value ["--fix"]. So the first half of the conditional is False, and then it tries the second half and errors.

If I add any ruff config to pyproject.toml, even foo = "bar", then the check no longer raises a TypeError.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions