Unify the way the imports work #9

Merged
alexander merged 21 commits from unify-imports into develop 2026-11-30 20:30:54 +01:00
9 changed files with 29 additions and 29 deletions
Showing only changes of commit e30b3efbe8 - Show all commits

Use the sa alias for sqlalchemy everywhere

`sa` is the common alias, also in SQLAlchemy's own documentation
Alexander Hess 2026-11-30 14:17:49 +01:00
Signed by: alexander
GPG key ID: B46EDB4DFC26805D

View file

@ -3,7 +3,7 @@
import datetime as dt
import pytest
import sqlalchemy as sqla
import sqlalchemy as sa
from sqlalchemy import exc as sa_exc
from tests import config as test_config
@ -44,7 +44,7 @@ class TestConstraints:
db_session.commit()
# Must delete without ORM as otherwise an UPDATE statement is emitted.
stmt = sqla.delete(db.ReplaySimulation).where(
stmt = sa.delete(db.ReplaySimulation).where(
db.ReplaySimulation.id == replayed_order.simulation.id,
)
@ -60,7 +60,7 @@ class TestConstraints:
db_session.commit()
# Must delete without ORM as otherwise an UPDATE statement is emitted.
stmt = sqla.delete(db.Order).where(db.Order.id == replayed_order.actual.id)
stmt = sa.delete(db.Order).where(db.Order.id == replayed_order.actual.id)
with pytest.raises(sa_exc.IntegrityError, match="fk_replayed_orders_to_orders"):
db_session.execute(stmt)
@ -80,7 +80,7 @@ class TestConstraints:
db_session.commit()
# Must delete without ORM as otherwise an UPDATE statement is emitted.
stmt = sqla.delete(db.Courier).where(db.Courier.id == replayed_order.courier.id)
stmt = sa.delete(db.Courier).where(db.Courier.id == replayed_order.courier.id)
with pytest.raises(
sa_exc.IntegrityError,

View file

@ -1,7 +1,7 @@
"""Test the ORM's `Address` model."""
import pytest
import sqlalchemy as sqla
import sqlalchemy as sa
from sqlalchemy import exc as sa_exc
from velofy import db
@ -57,7 +57,7 @@ class TestConstraints:
db_session.commit()
# Must delete without ORM as otherwise an UPDATE statement is emitted.
stmt = sqla.delete(db.City).where(db.City.id == address.city.id)
stmt = sa.delete(db.City).where(db.City.id == address.city.id)
with pytest.raises(
sa_exc.IntegrityError,

View file

@ -4,7 +4,7 @@ import json
import googlemaps
import pytest
import sqlalchemy as sqla
import sqlalchemy as sa
from geopy import distance
from sqlalchemy import exc as sa_exc
@ -73,7 +73,7 @@ class TestConstraints:
db_session.commit()
# Must delete without ORM as otherwise an UPDATE statement is emitted.
stmt = sqla.delete(db.Address).where(db.Address.id == path.first_address.id)
stmt = sa.delete(db.Address).where(db.Address.id == path.first_address.id)
with pytest.raises(
sa_exc.IntegrityError,
@ -87,7 +87,7 @@ class TestConstraints:
db_session.commit()
# Must delete without ORM as otherwise an UPDATE statement is emitted.
stmt = sqla.delete(db.Address).where(db.Address.id == path.second_address.id)
stmt = sa.delete(db.Address).where(db.Address.id == path.second_address.id)
with pytest.raises(
sa_exc.IntegrityError,
@ -103,7 +103,7 @@ class TestConstraints:
# Must insert without ORM as otherwise SQLAlchemy figures out
# that something is wrong before any query is sent to the database.
stmt = sqla.insert(db.Path).values(
stmt = sa.insert(db.Path).values(
first_address_id=address.id,
second_address_id=another_address.id,
city_id=999,
@ -123,7 +123,7 @@ class TestConstraints:
# Must insert without ORM as otherwise SQLAlchemy figures out
# that something is wrong before any query is sent to the database.
stmt = sqla.insert(db.Path).values(
stmt = sa.insert(db.Path).values(
first_address_id=path.first_address.id,
second_address_id=path.second_address.id,
city_id=path.city_id,

View file

@ -10,7 +10,7 @@ Implementation notes:
"""
import pytest
import sqlalchemy as sqla
import sqlalchemy as sa
from sqlalchemy import exc as sa_exc
from velofy import db
@ -56,7 +56,7 @@ class TestConstraints:
db_session.commit()
# Must delete without ORM as otherwise an UPDATE statement is emitted.
stmt = sqla.delete(db.Address).where(db.Address.id == assoc.address.id)
stmt = sa.delete(db.Address).where(db.Address.id == assoc.address.id)
with pytest.raises(
sa_exc.IntegrityError,
@ -72,7 +72,7 @@ class TestConstraints:
# Must insert without ORM as otherwise SQLAlchemy figures out
# that something is wrong before any query is sent to the database.
stmt = sqla.insert(db.AddressPixelAssociation).values(
stmt = sa.insert(db.AddressPixelAssociation).values(
address_id=address.id,
city_id=999,
grid_id=pixel.grid.id,
@ -93,7 +93,7 @@ class TestConstraints:
# Must insert without ORM as otherwise SQLAlchemy figures out
# that something is wrong before any query is sent to the database.
stmt = sqla.insert(db.AddressPixelAssociation).values(
stmt = sa.insert(db.AddressPixelAssociation).values(
address_id=address.id,
city_id=address.city.id,
grid_id=999,
@ -112,7 +112,7 @@ class TestConstraints:
db_session.commit()
# Must delete without ORM as otherwise an UPDATE statement is emitted.
stmt = sqla.delete(db.Pixel).where(db.Pixel.id == assoc.pixel.id)
stmt = sa.delete(db.Pixel).where(db.Pixel.id == assoc.pixel.id)
with pytest.raises(
sa_exc.IntegrityError,

View file

@ -4,7 +4,7 @@ import datetime as dt
import pandas as pd
import pytest
import sqlalchemy as sqla
import sqlalchemy as sa
from sqlalchemy import exc as sa_exc
from tests import config as test_config
@ -76,7 +76,7 @@ class TestConstraints:
db_session.commit()
# Must delete without ORM as otherwise an UPDATE statement is emitted.
stmt = sqla.delete(db.Pixel).where(db.Pixel.id == forecast.pixel.id)
stmt = sa.delete(db.Pixel).where(db.Pixel.id == forecast.pixel.id)
with pytest.raises(
sa_exc.IntegrityError,

View file

@ -1,7 +1,7 @@
"""Test the ORM's `Grid` model."""
import pytest
import sqlalchemy as sqla
import sqlalchemy as sa
from sqlalchemy import exc as sa_exc
from velofy import db
@ -41,7 +41,7 @@ class TestConstraints:
db_session.commit()
# Must delete without ORM as otherwise an UPDATE statement is emitted.
stmt = sqla.delete(db.City).where(db.City.id == grid.city.id)
stmt = sa.delete(db.City).where(db.City.id == grid.city.id)
with pytest.raises(
sa_exc.IntegrityError,

View file

@ -4,7 +4,7 @@ import datetime as dt
import random
import pytest
import sqlalchemy as sqla
import sqlalchemy as sa
from sqlalchemy import exc as sa_exc
from tests import config as test_config
@ -58,7 +58,7 @@ class TestConstraints:
db_session.commit()
# Must delete without ORM as otherwise an UPDATE statement is emitted.
stmt = sqla.delete(db.Customer).where(db.Customer.id == order.customer.id)
stmt = sa.delete(db.Customer).where(db.Customer.id == order.customer.id)
with pytest.raises(sa_exc.IntegrityError, match="fk_orders_to_customers"):
db_session.execute(stmt)
@ -69,7 +69,7 @@ class TestConstraints:
db_session.commit()
# Must delete without ORM as otherwise an UPDATE statement is emitted.
stmt = sqla.delete(db.Courier).where(db.Courier.id == order.courier.id)
stmt = sa.delete(db.Courier).where(db.Courier.id == order.courier.id)
with pytest.raises(sa_exc.IntegrityError, match="fk_orders_to_couriers"):
db_session.execute(stmt)
@ -80,7 +80,7 @@ class TestConstraints:
db_session.commit()
# Must delete without ORM as otherwise an UPDATE statement is emitted.
stmt = sqla.delete(db.Restaurant).where(db.Restaurant.id == order.restaurant.id)
stmt = sa.delete(db.Restaurant).where(db.Restaurant.id == order.restaurant.id)
with pytest.raises(sa_exc.IntegrityError, match="fk_orders_to_restaurants"):
db_session.execute(stmt)
@ -112,7 +112,7 @@ class TestConstraints:
db_session.commit()
# Must delete without ORM as otherwise an UPDATE statement is emitted.
stmt = sqla.delete(db.Address).where(db.Address.id == order.delivery_address.id)
stmt = sa.delete(db.Address).where(db.Address.id == order.delivery_address.id)
with pytest.raises(sa_exc.IntegrityError, match="fk_orders_to_addresses"):
db_session.execute(stmt)

View file

@ -1,7 +1,7 @@
"""Test the ORM's `Pixel` model."""
import pytest
import sqlalchemy as sqla
import sqlalchemy as sa
from sqlalchemy import exc as sa_exc
from velofy import db
@ -41,7 +41,7 @@ class TestConstraints:
db_session.commit()
# Must delete without ORM as otherwise an UPDATE statement is emitted.
stmt = sqla.delete(db.Grid).where(db.Grid.id == pixel.grid.id)
stmt = sa.delete(db.Grid).where(db.Grid.id == pixel.grid.id)
with pytest.raises(
sa_exc.IntegrityError,

View file

@ -1,7 +1,7 @@
"""Test the ORM's `Restaurant` model."""
import pytest
import sqlalchemy as sqla
import sqlalchemy as sa
from sqlalchemy import exc as sa_exc
from velofy import db
@ -41,7 +41,7 @@ class TestConstraints:
db_session.commit()
# Must delete without ORM as otherwise an UPDATE statement is emitted.
stmt = sqla.delete(db.Address).where(db.Address.id == restaurant.address.id)
stmt = sa.delete(db.Address).where(db.Address.id == restaurant.address.id)
with pytest.raises(
sa_exc.IntegrityError,