bt2: first pass of type annotation
Do a quick pass of adding type annotations on almost everything public
in the API. It's not perfect, for instance:
- Because of the structure of const vs non-const objects, the typings
claim that the non-const versions reutrn const properties, when in
reality then return non-const properties. For instance,
`_StreamClass.trace_class` should return a `_TraceClass`, not a
`_TraceClassConst`. Some refactoring will be needed to get that
right.
- The typings could sometimes return a more precise type with the use
of generics. For instance,
`_OptionWithUnsignedIntegerSelectorFieldClassConst.ranges()` should
return an `_UnsignedIntegerRangeSetConst`, but it returns an
`_IntegerRangeSetConst` right now (because the `ranges()` method is
shared with the signed version).
- I left out some more complex things, like the type of params (which
is also the type of the parameter to `bt2.create_value()`). That's a
project for later.
Still, I think it's better than nothing, and we have to start somewhere.
Even when the return value could be inferred, I chose to specify it
explicitly. It acts as documentation for anyone reading the code
without an analysis tool that can display the inferred value, and it
acts as validation that the functions keep returning what we want them
to return (especially if we ever run pyright or similar in the CI one
day).
Change-Id: I25999b855626ca3efb619b8cb07d267b4d8ec3ed
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/13403
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
29 files changed:
This page took 0.029678 seconds and 4 git commands to generate.