You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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.
Many of this package's docstrings incorrectly conflate
Optional[T]
with default arguments.typing.Optional[T]
means "either aT
or aNone
", 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
new_task_name (Optional[str])): ...
means thatnew_task_name
has a type oftyping.Optional[str]
, but that is not the case. It has a type ofstr
. If you do not specify an argument fornew_task_name
, the default argument is used, which also has a type ofstr
.grpc_options (Optional[:class:
~nidaqmx.GrpcSessionOptions]): ...
is correct. The default argument has typeNone
, sotyping.Optional[GrpcSessionOptions]
is needed to accept either aGrpcSessionOptions
or aNone
.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.
The text was updated successfully, but these errors were encountered: