robotpy / robotpy-build

(mostly) automated C++ wrapping for Python
BSD 3-Clause "New" or "Revised" License
37 stars 16 forks source link

[BUG]: Type hint order matters for VSCode intellisense #162

Closed TheTripleV closed 2 years ago

TheTripleV commented 2 years ago

Problem description

Might not be an issue and may be a side-effect of robotpy/robotpy-wpimath#29.

From pathplannerlib's generated .pyi file:

class PathPlannerTrajectory():
    class PathPlannerState():
        ... # stuff here
    class Waypoint():
        ... # stuff here
    def asWPILibTrajectory(self) -> wpimath._controls._controls.trajectory.Trajectory: ...
    def getEndState(self) -> PathPlannerTrajectory.PathPlannerState: ...
    def getInitialState(self) -> PathPlannerTrajectory.PathPlannerState: ...
    def getState(self, i: int) -> PathPlannerTrajectory.PathPlannerState: ...
    def getStates(self) -> typing.List[PathPlannerTrajectory.PathPlannerState]: ...
    def getTotalTime(self) -> seconds: ...
    def numStates(self) -> int: ...
    def sample(self, time: seconds) -> PathPlannerTrajectory.PathPlannerState: ...
    pass

PathPlannerTrajectory's methods come after internal classes. These methods are not recommended by VSCode and are considered errors by PyRight/PyLance.

Operating System

MacOS

Installed Python Packages

No response

Reproducible example code

No response

auscompgeek commented 2 years ago

:thinking: I think this is a bug in Pyright. Everything in the type stub should be read as though from __future__ import annotations is active (and indeed our type stubs actually explicitly include that), so those return types should be completely valid.

virtuald commented 2 years ago

It seems likely that the messed up units are interfering with this. Revisit after those are fixed?

TheTripleV commented 2 years ago

It's fine now that the units resolve.