apache / apache/libcloud

Is name=None correct for NodeImage constructor?

Aperta
#2,075 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
Python
Stelle
2.1k
Fork
931
Merge medio
1g 2h
PR unite (30g)
4

Descrizione

## Summary

If someone copy-pastes code from [this example](https://github.com/apache/libcloud/blob/v3.8.0/docs/examples/compute/create_ec2_node_custom_ami.py#L22), they will get type errors in a type checker like [pyright](https://github.com/microsoft/pyright).

## Detailed Information

The type hints for NodeImage say that `name` is a `str`:

https://github.com/apache/libcloud/blob/v3.8.0/libcloud/compute/base.py#L451

However, in one of the examples in docs, `name` is set to `None`:

https://github.com/apache/libcloud/blob/v3.8.0/docs/examples/compute/create_ec2_node_custom_ami.py#L22

https://libcloud.readthedocs.io/en/stable/compute/examples.html#create-ec2-node-using-a-custom-ami

This means that a type-checker like pyright will complain if you follow this example.

Should the type hint and/or the example be changed?

My workaround was to add `# type: ignore` to silence the warning, but I figured I can open an issue in case someone else might run into the same thing.

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Inizia con NodeImage in libcloud/compute/base.py e confronta la relativa annotazione del nome con il valore None in docs/examples/compute/create_ec2_node_custom_ami.py. Verifica l'esempio con pyright, quindi stabilisci se l'annotazione o l'esempio corrisponde all'API prevista. Il lavoro è completato quando l'esempio e i type hint concordano senza richiedere una soluzione alternativa con type-ignore.

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

Valutazione

Stack tecnologico
python
Ambito
api, cloud
Tipo di issue
Bug
Difficoltà
2/5
Tempo stimato
1-3 ore
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
48/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.