Closed jasminlapalme closed 1 year ago
It would be useful to add typings of the keys and values of the __members__ dictionary on class that represent enum in C.
__members__
enum
For example, with this pybind11 code of library named lib :
lib
py::enum_<Number>(m, "Number") .value("Zero", Number::Zero) .value("One", Number::One) .value("Tow", Number::Two);
instead of :
class Number(): .... __members__: dict # value = {'Zero': <Number.Zero: 0>, 'One': < Number.One: 1>, 'Two': <Number.Two: 2>}
to have :
class Number(): .... __members__: dict[str, lib.Number] # value = {'Zero': <Number.Zero: 0>, 'One': < Number.One: 1>, 'Two': <Number.Two: 2>}
When we import code with these kinds of stubs and use mypy to type checked the code, we have this warning.
mypy
error: Missing type parameters for generic type "dict" [type-arg]
Thanks for the suggestion!
Implemented in #112
Example from tests: https://github.com/sizmailov/pybind11-stubgen/blob/a1cd5faab09e642d4c0692474790ca737a271baf/tests/stubs/demo/_bindings/enum.pyi#L39-L41
It would be useful to add typings of the keys and values of the
__members__
dictionary on class that representenum
in C.For example, with this pybind11 code of library named
lib
:instead of :
to have :
When we import code with these kinds of stubs and use
mypy
to type checked the code, we have this warning.