astral-sh/ruff

INP001 false positive in tests folder

Open

#6,474 opened on Aug 10, 2023

View on GitHub
 (11 comments) (8 reactions) (0 assignees)Rust (47,527 stars) (2,088 forks)batch import
help wanted

Description

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

INP001 false positive in tests folder · astral-sh/ruff#6474 | Good First Issue