python / python/mypy

Cannot exclude __init__.py without excluding the entire dir

Aperta
#10,946 0 commenti 2 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

bug topic-configuration topic-usability
Lingua principale
Python
Stelle
20.6k
Fork
3.3k
Metriche di merge delle PR
Metriche PR in attesa

Descrizione

Bug Report

To Reproduce

$ mkdir foo
$ cd foo
$ mkdir testpkg
$ echo "def f(): pass" > testpkg/__init__.py
$ echo "def g(): pass" > testpkg/foo.py

$  mypy --disallow-untyped-defs --exclude "fo" testpkg   # <--- excludes foo.py
testpkg/__init__.py:1: error: Function is missing a return type annotation
testpkg/__init__.py:1: note: Use "-> None" if function does not return a value
Found 1 error in 1 file (checked 1 source file)

$ mypy --disallow-untyped-defs --exclude "init" testpkg   # <---- should exclude __init__.py
testpkg/__init__.py:1: error: Function is missing a return type annotation
testpkg/__init__.py:1: note: Use "-> None" if function does not return a value
testpkg/foo.py:1: error: Function is missing a return type annotation
testpkg/foo.py:1: note: Use "-> None" if function does not return a value
Found 2 errors in 2 files (checked 1 source file)

Expected Behavior

__init__.py should be ignored in the last command

Actual Behavior

__init__.py was not ignored in the last command

Your Environment

  • Mypy version used: 0.910
  • Mypy command-line flags: see above
  • Mypy configuration options from mypy.ini (and other config files): none
  • Python version used: 3.7.3
  • Operating system and version: Debian 10

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Riproduci i due comandi mypy usando testpkg/init.py e testpkg/foo.py, confrontando i risultati di --exclude "fo" e --exclude "init". Traccia il modo in cui il pattern di esclusione viene applicato ai file individuati, quindi aggiungi una copertura che mostri che __init__.py viene ignorato dal secondo pattern mentre foo.py continua a essere controllato.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
python
Ambito
devtools
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Ferma
Chiarezza
Specificata chiaramente
Idoneità per principianti
48/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.