Docstrings use `Optional[T]` incorrectly
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 35/100
- Tipo de issue
- Documentación
- Claridad
- Bastante claro
- Estado de actividad
- Estancado
- Stack tecnológico
- python
- Área
- documentation
Línea de trabajo
Comienza con el ejemplo de docstring en src/handwritten/task.py y lee el issue enlazado #209 sobre añadir type hints. Audita los package docstrings en busca de casos en los que Optional describa un valor predeterminado en lugar de un tipo nullable, y alinea la documentación con los tipos reales de los parámetros. Se considera terminado cuando las anotaciones Optional incorrectas se hayan corregido de forma coherente.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Many of this package's docstrings incorrectly conflate Optional[T] with default arguments.
typing.Optional[T] means "either a T or a None", which is orthogonal to whether the parameter has a default argument or not.
Example: https://github.com/ni/nidaqmx-python/blob/master/src/handwritten/task.py
def __init__(self, new_task_name='', *, grpc_options=None):
"""
Creates a DAQmx task.
Args:
new_task_name (Optional[str]): Specifies the name to assign to
the task.
If you use this method in a loop and specify a name for the
task, you must use the DAQmx Clear Task method within the loop
after you are finished with the task. Otherwise, NI-DAQmx
attempts to create multiple tasks with the same name, which
results in an error.
grpc_options (Optional[:class:`~nidaqmx.GrpcSessionOptions`]): Specifies
the gRPC session options.
"""
new_task_name (Optional[str])): ... means that new_task_name has a type of typing.Optional[str], but that is not the case. It has a type of str. If you do not specify an argument for new_task_name, the default argument is used, which also has a type of str.
grpc_options (Optional[:class:~nidaqmx.GrpcSessionOptions]): ... is correct. The default argument has type None, so typing.Optional[GrpcSessionOptions] is needed to accept either a GrpcSessionOptions or a None.
https://www.sphinx-doc.org/en/master/usage/extensions/example_google.html uses the syntax param2 (:obj:int, optional): . I don't know which meaning of "optional" it's using.
The best way to fix this is to add type hints and delete the types from the docstrings.
- Lenguaje dominante
- Python
- Estrellas
- 590
- Forks
- 199
- Merge medio
- 1 d 8 h
- PR fusionados (30 d)
- 7
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de ni/nidaqmx-python
-
Add PEP 723 dependency metadata to example programsPosiblemente ocupada @shrishsk la tomó hace 2 días. Abiertoenhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
ni/nidaqmx-python#1030 ·
-
tech debt
Dificultad 4/5 3-5 días Aptitud para principiantes 38/100
ni/nidaqmx-python#945 ·
-
bug
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
ni/nidaqmx-python#941 ·
-
Potential typos in the APIPosiblemente ocupada @KostaIlic2 la tomó hace 214 días. Abiertobug
Dificultad 3/5 1-2 días Aptitud para principiantes 42/100
ni/nidaqmx-python#939 ·
-
Add gRPC examplesAbiertoenhancement
Dificultad 3/5 1-2 días Aptitud para principiantes 45/100
ni/nidaqmx-python#917 · 1 comentario · 1 reacción ·
Todos los issues de ni/nidaqmx-python
Issues similares
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 65/100
521xueweihan/HelloGitHub#4025 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
aws-samples/sample-per-model-bedrock#321 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 1-3 horas Aptitud para principiantes 68/100
FavioVazquez/showtime#101 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
koush/ha_scrypted#81 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
google/osv-scanner-action#147 ·