Skip to content

Commit

Permalink
Changed Optional[] type annotations to more modern annotations for fi…
Browse files Browse the repository at this point in the history
…eld_provider.py
  • Loading branch information
SeaTechRC committed Sep 26, 2024
1 parent d3b0816 commit eb8dd7e
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions field_friend/automations/field_provider.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import logging
import uuid
from typing import Any, Optional
from typing import Any

import rosys
from geographiclib.geodesic import Geodesic
Expand Down Expand Up @@ -138,7 +138,7 @@ def get_distance(row: Row, direction: str):
self.fields[field_index].rows = sorted(field.rows, key=lambda row: get_distance(row, direction=direction))
self.FIELDS_CHANGED.emit()

async def add_field_point(self, field: Field, point: Optional[GeoPoint] = None, new_point: Optional[GeoPoint] = None) -> None:
async def add_field_point(self, field: Field, point: GeoPoint | None = None, new_point: GeoPoint | None = None) -> None:
assert self.gnss.current is not None
positioning = self.gnss.current.location
if positioning is None or positioning.lat == 0 or positioning.long == 0:
Expand All @@ -155,15 +155,15 @@ async def add_field_point(self, field: Field, point: Optional[GeoPoint] = None,
field.points.append(new_point)
self.invalidate()

def remove_field_point(self, field: Field, point: Optional[GeoPoint] = None) -> None:
def remove_field_point(self, field: Field, point: GeoPoint | None = None) -> None:
if point is not None:
index = field.points.index(point)
del field.points[index]
elif field.points:
del field.points[-1]
self.invalidate()

def add_obstacle_point(self, field: Field, obstacle: FieldObstacle, point: Optional[GeoPoint] = None, new_point: Optional[GeoPoint] = None) -> None:
def add_obstacle_point(self, field: Field, obstacle: FieldObstacle, point: GeoPoint | None = None, new_point: GeoPoint | None = None) -> None:
if new_point is None:
assert self.gnss.current is not None
positioning = self.gnss.current.location
Expand All @@ -181,7 +181,7 @@ def add_obstacle_point(self, field: Field, obstacle: FieldObstacle, point: Optio
obstacle.points.append(new_point)
self.invalidate()

def remove_obstacle_point(self, obstacle: FieldObstacle, point: Optional[GeoPoint] = None) -> None:
def remove_obstacle_point(self, obstacle: FieldObstacle, point: GeoPoint | None = None) -> None:
if obstacle.points:
if point is not None:
index = obstacle.points.index(point)
Expand All @@ -190,7 +190,7 @@ def remove_obstacle_point(self, obstacle: FieldObstacle, point: Optional[GeoPoin
del obstacle.points[-1]
self.invalidate()

def add_row_point(self, field: Field, row: Row, point: Optional[GeoPoint] = None, new_point: Optional[GeoPoint] = None) -> None:
def add_row_point(self, field: Field, row: Row, point: GeoPoint | None = None, new_point: GeoPoint | None = None) -> None:
if new_point is None:
assert self.gnss.current is not None
positioning = self.gnss.current.location
Expand All @@ -208,7 +208,7 @@ def add_row_point(self, field: Field, row: Row, point: Optional[GeoPoint] = None
row.points.append(new_point)
self.invalidate()

def remove_row_point(self, row: Row, point: Optional[GeoPoint] = None) -> None:
def remove_row_point(self, row: Row, point: GeoPoint | None = None) -> None:
if row.points:
if point is not None:
index = row.points.index(point)
Expand Down

0 comments on commit eb8dd7e

Please sign in to comment.