Skip to content

Commit

Permalink
Removed potential mutable default argument issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
SeaTechRC committed Sep 26, 2024
1 parent 81581ef commit d3b0816
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions field_friend/automations/field_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ def invalidate(self) -> None:
self.request_backup()
self.FIELDS_CHANGED.emit()

def create_field(self, points: list[GeoPoint] = []) -> Field:
def create_field(self, points: list[GeoPoint] | None = None) -> Field:
if points is None:
points = []
new_id = str(uuid.uuid4())
field = Field(id=f'{new_id}', name=f'field_{len(self.fields)+1}', points=points)
self.fields.append(field)
Expand All @@ -70,7 +72,9 @@ def clear_fields(self) -> None:
self.FIELDS_CHANGED.emit()
self.invalidate()

def create_obstacle(self, field: Field, points: list[GeoPoint] = []) -> FieldObstacle:
def create_obstacle(self, field: Field, points: list[GeoPoint] | None = None) -> FieldObstacle:
if points is None:
points = []
obstacle = FieldObstacle(id=f'{str(uuid.uuid4())}', name=f'obstacle_{len(field.obstacles)+1}', points=points)
field.obstacles.append(obstacle)
self.invalidate()
Expand All @@ -80,7 +84,9 @@ def remove_obstacle(self, field: Field, obstacle: FieldObstacle) -> None:
field.obstacles.remove(obstacle)
self.invalidate()

def create_row(self, field: Field, points: list[GeoPoint] = []) -> Row:
def create_row(self, field: Field, points: list[GeoPoint] | None = None) -> Row:
if points is None:
points = []
row = Row(id=f'{str(uuid.uuid4())}', name=f'row_{len(field.rows)+1}', points=points)
field.rows.append(row)
self.invalidate()
Expand Down

0 comments on commit d3b0816

Please sign in to comment.