Complaint about @staticmethod outside a class

Aperta
#1,006 3 commenti 1 reazione 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
25/100
Tipo di issue
Bug
Chiarezza
Da chiarire
Stato di attività
Ferma
Stack tecnologico
python
Ambito
tooling

Direzione di ricerca

The issue only supplies an inline Python example and the reported diagnostic; begin by reproducing it with mypy, then trace the diagnostic handling for staticmethod used inside a function. Done should be a decided behavior for this case, documented by a regression test if the project confirms it as a bug.

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

Descrizione

false-positive feature priority-2-low

I found code like this:

def foo():
    @staticmethod
    def bar():
        pass

This gets an error:

/Users/guido/mypy_tests/mypy_static.py: note: In function "foo":
/Users/guido/mypy_tests/mypy_static.py:2: error: 'staticmethod' used with a non-method

It can be silenced by putting # type: ignore on the @staticmethod line.

Lingua principale
Python
Stelle
20.6k
Fork
3.3k
Merge medio
1g 18h
PR unite (30g)
54

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.

Altre issue di python/mypy

Tutte le issue di python/mypy

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.