provide `typing.Protocol` for `dash_duo`
Nessuno ha ancora preso questa issue.
- Lingua principale
- Python
- Stelle
- 24.4k
- Fork
- 2.3k
- Merge medio
- 2g 7h
- PR unite (30g)
- 13
Descrizione
Is your feature request related to a problem? Please describe.
The DX for using the pytest fixture dash.testing.plugin.dash_duo() could be improved by providing a typing.Protocol to type hint available methods and their signatures.
Describe the solution you'd like
from typing import Protocol
import dash
from dash.testing.application_runners import import_app
from dash.testing.wait import wait_for_element_by_css_selector, wait_for_text_to_equal
class DashDuo(Protocol):
"The dash_duo pytest fixture lives in dash.testing.plugin.dash_duo."
def start_server(self, start_server) -> None:
...
def find_element(self, selector: str) -> dash.development.base_component.Component:
...
def test_example_app(dash_duo: DashDuo): # type hint for dash_duo enables auto-complete
app = import_app("example")
dash_duo.start_server(app)
my_component = dash_duo.find_element("#hello-world")
assert "my-value" == my_component.get_attribute("value")
....
Screenshot from VS Code showing auto-complete in action

Describe alternatives you've considered
None
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia dal fixture dash.testing.plugin.dash_duo e ispeziona i metodi e le firme che espone, inclusi start_server e find_element. Definisci un typing.Protocol che rappresenti questi metodi del fixture e verifica che annotare un test pytest con esso fornisca le firme dei metodi richieste e il supporto per il completamento automatico.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python
- Ambito
- developer-experience, testing-qa
- Tipo di issue
- Funzionalità
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100