Is name=None correct for NodeImage constructor?
- Lenguaje dominante
- Python
- Estrellas
- 2.1k
- Forks
- 931
- Merge medio
- 1 d 2 h
- PR fusionados (30 d)
- 4
Descripción
## 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.
Guía de contribución
Línea de trabajo
Comienza con NodeImage en libcloud/compute/base.py y compara su anotación de nombre con el valor None en docs/examples/compute/create_ec2_node_custom_ami.py. Comprueba el ejemplo con pyright y decide después si la anotación o el ejemplo coincide con la API prevista. Se considera terminado cuando el ejemplo y las indicaciones de tipo coinciden sin requerir una solución alternativa con type-ignore.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- python
- Área
- api, cloud
- Tipo de issue
- Error
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 48/100