It seems like there is a strong desire to implement better typing in the robotpy-commands-v2 library. There are potentially several ways to improve typing. The approach shown here uses TypeVar to create a generic type of ProfiledPIDController, named GenericProfiledPIDController. The generic type is defined in new typing.py file. The new generic type is then used in profiledpidsubsystem.py file as a type hint. See the file differences for more details.
Advantages:
Eliminates the use of type Unions.
Should be easy to maintain as the WPI C++ library evolves over time.
It seems like there is a strong desire to implement better typing in the robotpy-commands-v2 library. There are potentially several ways to improve typing. The approach shown here uses TypeVar to create a generic type of ProfiledPIDController, named GenericProfiledPIDController. The generic type is defined in new typing.py file. The new generic type is then used in profiledpidsubsystem.py file as a type hint. See the file differences for more details.
Advantages: