astral-sh/ruff

INP001 false positive in tests folder

Open

#6,474 opened on 2023年8月10日

GitHub で見る
 (11 comments) (8 reactions) (0 assignees)Rust (2,088 forks)batch import
help wanted

Repository metrics

Stars
 (47,527 stars)
PR merge metrics
 (平均マージ 3d 8h) (30d で 573 merged PRs)

説明

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.

コントリビューターガイド