apache / apache/libcloud

Is name=None correct for NodeImage constructor?

Ouverte
#2,075 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub
Langage dominant
Python
Étoiles
2.1k
Forks
931
Merge moyen
1 j 2 h
PR mergées (30 j)
4

Description

## 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.

Guide de contribution

Ouvrir le guide de contribution

Piste de recherche

Commencez par NodeImage dans libcloud/compute/base.py et comparez son annotation de nom avec la valeur None dans docs/examples/compute/create_ec2_node_custom_ami.py. Vérifiez l’exemple avec pyright, puis déterminez si l’annotation ou l’exemple correspond à l’API prévue. C’est terminé lorsque l’exemple et les indications de type concordent sans nécessiter de solution de contournement avec type-ignore.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
python
Domaine
api, cloud
Type d'issue
Bug
Difficulté
2/5
Temps estimé
1-3 heures
Activité
À l'abandon
Clarté
Plutôt claire
Accessibilité débutants
48/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.