astral-sh/ruff

INP001 false positive in tests folder

Open

#6,474 创建于 2023年8月10日

在 GitHub 查看
 (11 评论) (8 反应) (0 负责人)Rust (2,088 fork)batch import
help wanted

仓库指标

Star
 (47,527 star)
PR 合并指标
 (平均合并 3天 8小时) (30 天内合并 573 个 PR)

描述

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.

贡献者指南