astral-sh/ruff

INP001 false positive in tests folder

Open

#6 474 ouverte le 10 août 2023

Voir sur GitHub
 (11 commentaires) (8 réactions) (0 assignés)Rust (2 088 forks)batch import
help wanted

Métriques du dépôt

Stars
 (47 527 stars)
Métriques de merge PR
 (Merge moyen 3j 8h) (573 PRs mergées en 30 j)

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.

Guide contributeur