astral-sh/ruff

INP001 false positive in tests folder

Open

#6.474 geöffnet am 10. Aug. 2023

Auf GitHub ansehen
 (11 Kommentare) (8 Reaktionen) (0 zugewiesene Personen)Rust (2.088 Forks)batch import
help wanted

Repository-Metriken

Stars
 (47.527 Stars)
PR-Merge-Metriken
 (Durchschn. Merge 3T 8h) (573 gemergte PRs in 30 T)

Beschreibung

The recommended Python + Pytest layout is

  • src/
    • mypkg/
      • __init__.py
      • subpkg/
        • __init__.py
  • tests/
    • test_thing.py
    • test_more/
      • test_other_thing.py

Notably, tests and all files under it aren’t packages. The recommended import mode enforces that you can’t import from them.

Therefore INP001 shouldn’t trigger when tests is on top level of the project.

In fact, it would be great to have both a rule that enforces the opposite and to ensure that tests/**/test_*.py files don’t import things from each other.

Contributor Guide