Skip to content

Commit

Permalink
fix: 3.9 Union syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
herve.le-bars committed Mar 28, 2024
1 parent 2addfef commit fc93bb3
Show file tree
Hide file tree
Showing 10 changed files with 64 additions and 64 deletions.
2 changes: 1 addition & 1 deletion src/bloom/domain/excursion.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@


class Excursion(BaseModel):
id: int | None = None
id: Union[int , None] = None
vessel_id: int
departure_port_id: Union[int, None] = None
departure_at: Union[datetime, None] = None
Expand Down
18 changes: 9 additions & 9 deletions src/bloom/domain/segment.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,20 @@


class Excursion(BaseModel):
id: int | None = None
id: Union[ int , None ] = None
excursion_id: int
timestamp_start: Union[datetime, None] = None
timestamp_end: Union[datetime, None] = None
segment_duration: Union[timedelta, None] = None
start_position_id: Union[int, None] = None
end_position_id: Union[int, None] = None
heading: Union[float | None] = None
distance: Union[float | None] = None
average_speed: Union[float | None] = None
type: Union[str | None] = None
in_amp_zone: Union[bool | None] = None
in_territorial_waters: Union[bool | None] = None
in_costal_waters: Union[bool | None] = None
last_vessel_segment: Union[bool | None] = None
heading: Union[float , None] = None
distance: Union[float , None] = None
average_speed: Union[float , None] = None
type: Union[str , None] = None
in_amp_zone: Union[bool , None] = None
in_territorial_waters: Union[bool , None] = None
in_costal_waters: Union[bool , None] = None
last_vessel_segment: Union[bool , None] = None
created_at: Union[datetime, None] = None
updated_at: Union[datetime, None] = None
60 changes: 30 additions & 30 deletions src/bloom/domain/spire_ais_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,37 +8,37 @@


class SpireAisData(BaseModel):
id: Union[int | None] = None # noqa: UP007
id: Union[int , None] = None # noqa: UP007
spire_update_statement: datetime
vessel_ais_class: Union[str | None] = None # noqa: UP007
vessel_flag: Union[str | None] = None # noqa: UP007
vessel_name: Union[str | None] = None # noqa: UP007
vessel_callsign: Union[str | None] = None # noqa: UP007
vessel_timestamp: Union[datetime | None] = None # noqa: UP007
vessel_update_timestamp: Union[datetime | None] = None # noqa: UP007
vessel_ship_type: Union[str | None] = None # noqa: UP007
vessel_sub_ship_type: Union[str | None] = None # noqa: UP007
vessel_mmsi: Union[int | None] = None # noqa: UP007
vessel_imo: Union[int | None] = None # noqa: UP007
vessel_width: Union[int | None] = None # noqa: UP007
vessel_length: Union[int | None] = None # noqa: UP007
position_accuracy: Union[str | None] = None # noqa: UP007
position_collection_type: Union[str | None] = None # noqa: UP007
position_course: Union[float | None] = None # noqa: UP007
position_heading: Union[float | None] = None # noqa: UP007
position_latitude: Union[float | None] = None # noqa: UP007
position_longitude: Union[float | None] = None # noqa: UP007
position_maneuver: Union[str | None] = None # noqa: UP007
position_navigational_status: Union[str | None] = None # noqa: UP007
position_rot: Union[float | None] = None # noqa: UP007
position_speed: Union[float | None] = None # noqa: UP007
position_timestamp: Union[datetime | None] = None # noqa: UP007
position_update_timestamp: Union[datetime | None] = None # noqa: UP007
voyage_destination: Union[str | None] = None # noqa: UP007
voyage_draught: Union[float | None] = None # noqa: UP007
voyage_eta: Union[datetime | None] = None # noqa: UP007
voyage_timestamp: Union[datetime | None] = None # noqa: UP007
voyage_update_timestamp: Union[datetime | None] = None # noqa: UP007
vessel_ais_class: Union[str , None] = None # noqa: UP007
vessel_flag: Union[str , None] = None # noqa: UP007
vessel_name: Union[str , None] = None # noqa: UP007
vessel_callsign: Union[str , None] = None # noqa: UP007
vessel_timestamp: Union[datetime , None] = None # noqa: UP007
vessel_update_timestamp: Union[datetime , None] = None # noqa: UP007
vessel_ship_type: Union[str , None] = None # noqa: UP007
vessel_sub_ship_type: Union[str , None] = None # noqa: UP007
vessel_mmsi: Union[int , None] = None # noqa: UP007
vessel_imo: Union[int , None] = None # noqa: UP007
vessel_width: Union[int , None] = None # noqa: UP007
vessel_length: Union[int , None] = None # noqa: UP007
position_accuracy: Union[str , None] = None # noqa: UP007
position_collection_type: Union[str , None] = None # noqa: UP007
position_course: Union[float , None] = None # noqa: UP007
position_heading: Union[float , None] = None # noqa: UP007
position_latitude: Union[float , None] = None # noqa: UP007
position_longitude: Union[float , None] = None # noqa: UP007
position_maneuver: Union[str , None] = None # noqa: UP007
position_navigational_status: Union[str , None] = None # noqa: UP007
position_rot: Union[float , None] = None # noqa: UP007
position_speed: Union[float , None] = None # noqa: UP007
position_timestamp: Union[datetime , None] = None # noqa: UP007
position_update_timestamp: Union[datetime , None] = None # noqa: UP007
voyage_destination: Union[str , None] = None # noqa: UP007
voyage_draught: Union[float , None] = None # noqa: UP007
voyage_eta: Union[datetime , None] = None # noqa: UP007
voyage_timestamp: Union[datetime , None] = None # noqa: UP007
voyage_update_timestamp: Union[datetime , None] = None # noqa: UP007
created_at: Union[datetime, None] = None # noqa: UP007

def map_from_spire(spire_update_timestamp: datetime, vessel: dict[str, Any]): # noqa: ANN201
Expand Down
24 changes: 12 additions & 12 deletions src/bloom/domain/vessel_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@


class VesselData(BaseModel):
id: int | None = None
id: Union[ int , None ] = None
timestamp: datetime
ais_class: str | None
flag: str | None
name: str | None
callsign: str | None
timestamp: datetime | None
ship_type: str | None
sub_ship_type: str | None
mmsi: int | None
imo: int | None
width: int | None
length: int | None
ais_class: Union[str , None]
flag: Union[str , None]
name: Union[str , None]
callsign: Union[str , None]
timestamp: Union[datetime , None]
ship_type: Union[str , None]
sub_ship_type: Union[str , None]
mmsi: Union[int , None]
imo: Union[int , None]
width: Union[int , None]
length: Union[int , None]
vessel_id: int
created_at: Union[datetime, None] = None
14 changes: 7 additions & 7 deletions src/bloom/domain/vessel_position.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@
class VesselPosition(BaseModel):
model_config = ConfigDict(arbitrary_types_allowed=True)

id: int | None = None
id: Union[int , None] = None
timestamp: datetime
accuracy: Union[str, None] = None
collection_type: Union[str, None] = None
course: Union[float, None] = None
heading: Union[float, None] = None
position: Union[Point, None] = None
latitude: Union[float | None] = None
longitude: Union[float | None] = None
maneuver: Union[str | None] = None
navigational_status: Union[str | None] = None
rot: Union[float | None] = None
speed: Union[float | None] = None
latitude: Union[float , None] = None
longitude: Union[float , None] = None
maneuver: Union[str , None] = None
navigational_status: Union[str , None] = None
rot: Union[float , None] = None
speed: Union[float , None] = None
vessel_id: int
created_at: Union[datetime, None] = None
2 changes: 1 addition & 1 deletion src/bloom/domain/vessel_voyage.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@


class VesselVoyage(BaseModel):
id: int | None = None
id: Union[ int , None ] = None
timestamp: datetime
destination: str | None
draught: float | None
Expand Down
2 changes: 1 addition & 1 deletion src/bloom/domain/white_zone.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@


class WhiteZone(BaseModel):
id: int | None = None
id: Union[ int | None ] = None
geometry: Union[Geometry, None] = None
created_at: Union[datetime, None] = None
updated_at: Union[datetime, None] = None
2 changes: 1 addition & 1 deletion src/bloom/domain/zone.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

class Zone(BaseModel):
model_config = ConfigDict(arbitrary_types_allowed=True)
id: int | None = None
id: Union[int , None] = None
category: str
sub_category: Union[str, None] = None
name: str
Expand Down
2 changes: 1 addition & 1 deletion src/bloom/infra/repositories/repository_excursion.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def __init__(
) -> Callable[..., AbstractContextManager]:
self.session_factory = session_factory

def get_vessel_current_excursion(self, session: Session, vessel_id: int) -> Union[Excursion | None]:
def get_vessel_current_excursion(self, session: Session, vessel_id: int) -> Union[Excursion , None]:
"""Recheche l'excursion en cours d'un bateau, c'est-à-dire l'excursion qui n'a pas de date d'arrivée"""
sql = select(sql_model.Excursion).where(sql_model.Excursion.vessel_id == vessel_id).where(
sql_model.Excursion.arrival_at.isnot(None))
Expand Down
2 changes: 1 addition & 1 deletion src/bloom/infra/repositories/repository_port.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def batch_create_port(self, session: Session, ports: list[Port]) -> list[Port]:
session.add_all(orm_list)
return [PortRepository.map_to_domain(orm) for orm in orm_list]

def find_port_by_position_in_port_buffer(self, session: Session, position: Point) -> Union[Port | None]:
def find_port_by_position_in_port_buffer(self, session: Session, position: Point) -> Union[Port, None]:
stmt = select(sql_model.Port).where(
func.ST_contains(sql_model.Port.geometry_buffer, from_shape(position, srid=settings.srid)) == True)
port = session.execute(stmt).scalar()
Expand Down

0 comments on commit fc93bb3

Please sign in to comment.