From eb8dd7eaef067bd438cd01f250e9b6618f1a7ced Mon Sep 17 00:00:00 2001 From: SeaTechRC <153106523+SeaTechRC@users.noreply.github.com> Date: Thu, 26 Sep 2024 10:09:39 +0200 Subject: [PATCH] Changed Optional[] type annotations to more modern annotations for field_provider.py --- field_friend/automations/field_provider.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/field_friend/automations/field_provider.py b/field_friend/automations/field_provider.py index 17d6b5bb..53a669da 100644 --- a/field_friend/automations/field_provider.py +++ b/field_friend/automations/field_provider.py @@ -1,6 +1,6 @@ import logging import uuid -from typing import Any, Optional +from typing import Any import rosys from geographiclib.geodesic import Geodesic @@ -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: @@ -155,7 +155,7 @@ 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] @@ -163,7 +163,7 @@ def remove_field_point(self, field: Field, point: Optional[GeoPoint] = None) -> 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 @@ -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) @@ -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 @@ -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)