photonlibpy: Fix some type check failures (#1548)

This fixes a variety of type check failures raised by both mypy and pyright. See #1548
This commit is contained in:
David Vo
2024-11-12 16:53:43 +11:00
committed by GitHub
parent 31ec9baa95
commit af03ae0a8b
6 changed files with 40 additions and 17 deletions

View File

@@ -1,9 +1,12 @@
from dataclasses import dataclass, field
from typing import Optional
from typing import TYPE_CHECKING, ClassVar, Optional
from .multiTargetPNPResult import MultiTargetPNPResult
from .photonTrackedTarget import PhotonTrackedTarget
if TYPE_CHECKING:
from .. import generated
@dataclass
class PhotonPipelineMetadata:
@@ -17,7 +20,7 @@ class PhotonPipelineMetadata:
timeSinceLastPong: int = -1
photonStruct: "PhotonPipelineMetadataSerde" = None
photonStruct: ClassVar["generated.PhotonPipelineMetadataSerde"]
@dataclass
@@ -57,7 +60,7 @@ class PhotonPipelineResult:
def hasTargets(self) -> bool:
return len(self.targets) > 0
def getBestTarget(self) -> PhotonTrackedTarget:
def getBestTarget(self) -> Optional[PhotonTrackedTarget]:
"""
Returns the best target in this pipeline result. If there are no targets, this method will
return null. The best target is determined by the target sort mode in the PhotonVision UI.
@@ -66,4 +69,4 @@ class PhotonPipelineResult:
return None
return self.getTargets()[0]
photonStruct: "PhotonPipelineResultSerde" = None
photonStruct: ClassVar["generated.PhotonPipelineResultSerde"]