Add flake8-sfs
This commit is contained in:
parent
650765a9d3
commit
cb8f919b1f
18 changed files with 44 additions and 60 deletions
|
|
@ -33,17 +33,14 @@ def include_object(obj, _name, type_, _reflected, _compare_to):
|
||||||
|
|
||||||
engine = sa.create_engine(velofy_config.DATABASE_URI)
|
engine = sa.create_engine(velofy_config.DATABASE_URI)
|
||||||
|
|
||||||
|
test_schema = f"_{velofy_config.CLEAN_SCHEMA}" if os.getenv("TESTING") else ""
|
||||||
|
|
||||||
with engine.connect() as connection:
|
with engine.connect() as connection:
|
||||||
context.configure(
|
context.configure(
|
||||||
connection=connection,
|
connection=connection,
|
||||||
include_object=include_object,
|
include_object=include_object,
|
||||||
target_metadata=db.Base.metadata,
|
target_metadata=db.Base.metadata,
|
||||||
version_table="{alembic_table}{test_schema}".format(
|
version_table=f"{velofy_config.ALEMBIC_TABLE}{test_schema}",
|
||||||
alembic_table=velofy_config.ALEMBIC_TABLE,
|
|
||||||
test_schema=(
|
|
||||||
f"_{velofy_config.CLEAN_SCHEMA}" if os.getenv("TESTING") else ""
|
|
||||||
),
|
|
||||||
),
|
|
||||||
version_table_schema=velofy_config.ALEMBIC_TABLE_SCHEMA,
|
version_table_schema=velofy_config.ALEMBIC_TABLE_SCHEMA,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -299,7 +299,7 @@ def upgrade():
|
||||||
*(
|
*(
|
||||||
sa.CheckConstraint(
|
sa.CheckConstraint(
|
||||||
constraint,
|
constraint,
|
||||||
name="ordered_timestamps_{index}".format(index=index),
|
name=f"ordered_timestamps_{index}",
|
||||||
)
|
)
|
||||||
for index, constraint in enumerate(
|
for index, constraint in enumerate(
|
||||||
(
|
(
|
||||||
|
|
|
||||||
|
|
@ -193,6 +193,7 @@ def lint_code(session: Session) -> None:
|
||||||
"flake8-pyproject",
|
"flake8-pyproject",
|
||||||
"flake8-pytest-style",
|
"flake8-pytest-style",
|
||||||
"flake8-quotes",
|
"flake8-quotes",
|
||||||
|
"flake8-sfs",
|
||||||
"isort",
|
"isort",
|
||||||
# TODO: See comment on `mypy` below
|
# TODO: See comment on `mypy` below
|
||||||
# 'mypy',
|
# 'mypy',
|
||||||
|
|
|
||||||
|
|
@ -102,6 +102,7 @@ dev = [
|
||||||
"flake8-pyproject (>=1.2.4,<2.0.0)",
|
"flake8-pyproject (>=1.2.4,<2.0.0)",
|
||||||
"flake8-pytest-style (>=2.2.0,<3.0.0)",
|
"flake8-pytest-style (>=2.2.0,<3.0.0)",
|
||||||
"flake8-quotes (>=3.4.0,<4.0.0)",
|
"flake8-quotes (>=3.4.0,<4.0.0)",
|
||||||
|
"flake8-sfs (>=1.0.1,<2.0.0)",
|
||||||
"mypy (>=2.4.1,<3.0.0)",
|
"mypy (>=2.4.1,<3.0.0)",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
@ -222,6 +223,8 @@ select = [
|
||||||
"BLK1", "BLK9",
|
"BLK1", "BLK9",
|
||||||
# flake8-pytest-style => enforce a consistent style with pytest
|
# flake8-pytest-style => enforce a consistent style with pytest
|
||||||
"PT0",
|
"PT0",
|
||||||
|
# flake8-sfs => use f-strings as the only type of string formatting
|
||||||
|
"SFS",
|
||||||
]
|
]
|
||||||
|
|
||||||
# By default, flake8 ignores some errors.
|
# By default, flake8 ignores some errors.
|
||||||
|
|
@ -238,6 +241,8 @@ extend-ignore = [
|
||||||
"E203", "W503",
|
"E203", "W503",
|
||||||
# Let's not do `@pytest.mark.no_cover()` instead of `@pytest.mark.no_cover`.
|
# Let's not do `@pytest.mark.no_cover()` instead of `@pytest.mark.no_cover`.
|
||||||
"PT023",
|
"PT023",
|
||||||
|
# Allow f-strings as the only type of string formatting.
|
||||||
|
"SFS301",
|
||||||
]
|
]
|
||||||
|
|
||||||
per-file-ignores = [
|
per-file-ignores = [
|
||||||
|
|
|
||||||
|
|
@ -16,11 +16,9 @@ import warnings
|
||||||
|
|
||||||
def random_schema_name() -> str:
|
def random_schema_name() -> str:
|
||||||
"""Generate a random PostgreSQL schema name for testing."""
|
"""Generate a random PostgreSQL schema name for testing."""
|
||||||
return "temp_{name}".format(
|
letters = (random.choice(string.ascii_lowercase) for _ in range(10)) # noqa:S311
|
||||||
name="".join(
|
name = "".join(letters)
|
||||||
(random.choice(string.ascii_lowercase) for _ in range(10)), # noqa:S311
|
return f"temp_{name}"
|
||||||
),
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class Config:
|
class Config:
|
||||||
|
|
|
||||||
|
|
@ -82,11 +82,7 @@ class Address(meta.Base):
|
||||||
|
|
||||||
def __repr__(self) -> str:
|
def __repr__(self) -> str:
|
||||||
"""Non-literal text representation."""
|
"""Non-literal text representation."""
|
||||||
return "<{cls}({street} in {city})>".format(
|
return f"<{self.__class__.__name__}({self.street} in {self.city_name})>"
|
||||||
cls=self.__class__.__name__,
|
|
||||||
street=self.street,
|
|
||||||
city=self.city_name,
|
|
||||||
)
|
|
||||||
|
|
||||||
@hybrid.hybrid_property
|
@hybrid.hybrid_property
|
||||||
def is_primary(self) -> bool:
|
def is_primary(self) -> bool:
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ class City(meta.Base):
|
||||||
|
|
||||||
def __repr__(self) -> str:
|
def __repr__(self) -> str:
|
||||||
"""Non-literal text representation."""
|
"""Non-literal text representation."""
|
||||||
return "<{cls}({name})>".format(cls=self.__class__.__name__, name=self.name)
|
return f"<{self.__class__.__name__}({self.name})>"
|
||||||
|
|
||||||
@functools.cached_property
|
@functools.cached_property
|
||||||
def center(self) -> utils.Location:
|
def center(self) -> utils.Location:
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,4 @@ class Courier(meta.Base):
|
||||||
|
|
||||||
def __repr__(self) -> str:
|
def __repr__(self) -> str:
|
||||||
"""Non-literal text representation."""
|
"""Non-literal text representation."""
|
||||||
return "<{cls}(#{courier_id})>".format(
|
return f"<{self.__class__.__name__}(#{self.id})>"
|
||||||
cls=self.__class__.__name__,
|
|
||||||
courier_id=self.id,
|
|
||||||
)
|
|
||||||
|
|
|
||||||
|
|
@ -21,10 +21,7 @@ class Customer(meta.Base):
|
||||||
|
|
||||||
def __repr__(self) -> str:
|
def __repr__(self) -> str:
|
||||||
"""Non-literal text representation."""
|
"""Non-literal text representation."""
|
||||||
return "<{cls}(#{customer_id})>".format(
|
return f"<{self.__class__.__name__}(#{self.id})>"
|
||||||
cls=self.__class__.__name__,
|
|
||||||
customer_id=self.id,
|
|
||||||
)
|
|
||||||
|
|
||||||
# Relationships
|
# Relationships
|
||||||
orders = orm.relationship("Order", back_populates="customer")
|
orders = orm.relationship("Order", back_populates="customer")
|
||||||
|
|
|
||||||
|
|
@ -142,13 +142,9 @@ class Forecast(meta.Base):
|
||||||
|
|
||||||
def __repr__(self) -> str:
|
def __repr__(self) -> str:
|
||||||
"""Non-literal text representation."""
|
"""Non-literal text representation."""
|
||||||
return "<{cls}: {prediction} for pixel ({n_x}|{n_y}) at {start_at}>".format(
|
cls = self.__class__.__name__
|
||||||
cls=self.__class__.__name__,
|
pixel = f"({self.pixel.n_x}|{self.pixel.n_y})"
|
||||||
prediction=self.prediction,
|
return f"<{cls}: {self.prediction} for pixel {pixel} at {self.start_at}>"
|
||||||
n_x=self.pixel.n_x,
|
|
||||||
n_y=self.pixel.n_y,
|
|
||||||
start_at=self.start_at,
|
|
||||||
)
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_dataframe(
|
def from_dataframe(
|
||||||
|
|
|
||||||
|
|
@ -51,10 +51,7 @@ class Grid(meta.Base):
|
||||||
|
|
||||||
def __repr__(self) -> str:
|
def __repr__(self) -> str:
|
||||||
"""Non-literal text representation."""
|
"""Non-literal text representation."""
|
||||||
return "<{cls}: {area} sqr. km>".format(
|
return f"<{self.__class__.__name__}: {self.pixel_area} sqr. km>"
|
||||||
cls=self.__class__.__name__,
|
|
||||||
area=self.pixel_area,
|
|
||||||
)
|
|
||||||
|
|
||||||
# Convenience properties
|
# Convenience properties
|
||||||
@property
|
@property
|
||||||
|
|
|
||||||
|
|
@ -266,7 +266,7 @@ class Order(meta.Base):
|
||||||
*(
|
*(
|
||||||
sa.CheckConstraint(
|
sa.CheckConstraint(
|
||||||
constraint,
|
constraint,
|
||||||
name="ordered_timestamps_{index}".format(index=index),
|
name=f"ordered_timestamps_{index}",
|
||||||
)
|
)
|
||||||
for index, constraint in enumerate(
|
for index, constraint in enumerate(
|
||||||
(
|
(
|
||||||
|
|
@ -550,10 +550,7 @@ class Order(meta.Base):
|
||||||
|
|
||||||
def __repr__(self) -> str:
|
def __repr__(self) -> str:
|
||||||
"""Non-literal text representation."""
|
"""Non-literal text representation."""
|
||||||
return "<{cls}(#{order_id})>".format(
|
return f"<{self.__class__.__name__}(#{self.id})>"
|
||||||
cls=self.__class__.__name__,
|
|
||||||
order_id=self.id,
|
|
||||||
)
|
|
||||||
|
|
||||||
def draw(self) -> folium.Map: # pragma: no cover
|
def draw(self) -> folium.Map: # pragma: no cover
|
||||||
"""Draw the `.waypoints` from `.pickup_address` to `.delivery_address`.
|
"""Draw the `.waypoints` from `.pickup_address` to `.delivery_address`.
|
||||||
|
|
|
||||||
|
|
@ -56,11 +56,7 @@ class Pixel(meta.Base):
|
||||||
|
|
||||||
def __repr__(self) -> str:
|
def __repr__(self) -> str:
|
||||||
"""Non-literal text representation."""
|
"""Non-literal text representation."""
|
||||||
return "<{cls}: ({x}|{y})>".format(
|
return f"<{self.__class__.__name__}: ({self.n_x}|{self.n_y})>"
|
||||||
cls=self.__class__.__name__,
|
|
||||||
x=self.n_x,
|
|
||||||
y=self.n_y,
|
|
||||||
)
|
|
||||||
|
|
||||||
# Convenience properties
|
# Convenience properties
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -266,7 +266,7 @@ class ReplayedOrder(meta.Base):
|
||||||
# and the non-simulated columns removed.
|
# and the non-simulated columns removed.
|
||||||
sa.CheckConstraint(
|
sa.CheckConstraint(
|
||||||
constraint,
|
constraint,
|
||||||
name="ordered_timestamps_{index}".format(index=index),
|
name=f"ordered_timestamps_{index}",
|
||||||
)
|
)
|
||||||
for index, constraint in enumerate(
|
for index, constraint in enumerate(
|
||||||
(
|
(
|
||||||
|
|
@ -338,10 +338,7 @@ class ReplayedOrder(meta.Base):
|
||||||
|
|
||||||
def __repr__(self) -> str:
|
def __repr__(self) -> str:
|
||||||
"""Non-literal text representation."""
|
"""Non-literal text representation."""
|
||||||
return "<{cls}(#{order_id})>".format(
|
return f"<{self.__class__.__name__}(#{self.actual.id})>"
|
||||||
cls=self.__class__.__name__,
|
|
||||||
order_id=self.actual.id,
|
|
||||||
)
|
|
||||||
|
|
||||||
# Convenience properties
|
# Convenience properties
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -40,9 +40,5 @@ class ReplaySimulation(meta.Base):
|
||||||
|
|
||||||
def __repr__(self) -> str:
|
def __repr__(self) -> str:
|
||||||
"""Non-literal text representation."""
|
"""Non-literal text representation."""
|
||||||
return "<{cls}({strategy} #{run} in {city})>".format(
|
cls = self.__class__.__name__
|
||||||
cls=self.__class__.__name__,
|
return f"<{cls}({self.strategy} #{self.run} in {self.city.name})>"
|
||||||
strategy=self.strategy,
|
|
||||||
run=self.run,
|
|
||||||
city=self.city.name,
|
|
||||||
)
|
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,7 @@ class Restaurant(meta.Base):
|
||||||
|
|
||||||
def __repr__(self) -> str:
|
def __repr__(self) -> str:
|
||||||
"""Non-literal text representation."""
|
"""Non-literal text representation."""
|
||||||
return "<{cls}({name})>".format(cls=self.__class__.__name__, name=self.name)
|
return f"<{self.__class__.__name__}({self.name})>"
|
||||||
|
|
||||||
def clear_map(self) -> Restaurant: # pragma: no cover
|
def clear_map(self) -> Restaurant: # pragma: no cover
|
||||||
"""Shortcut to the `.address.city.clear_map()` method.
|
"""Shortcut to the `.address.city.clear_map()` method.
|
||||||
|
|
|
||||||
|
|
@ -105,7 +105,7 @@ def stl( # noqa:C901
|
||||||
if nt % 2 == 0 or nt < default_nt:
|
if nt % 2 == 0 or nt < default_nt:
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
"`nt` must be odd and `>= (1.5 * frequency) / [1 - (1.5 / ns)]`, "
|
"`nt` must be odd and `>= (1.5 * frequency) / [1 - (1.5 / ns)]`, "
|
||||||
+ "which is {0}".format(default_nt),
|
+ f"which is {default_nt}",
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
nt = default_nt
|
nt = default_nt
|
||||||
|
|
|
||||||
14
uv.lock
generated
14
uv.lock
generated
|
|
@ -1030,6 +1030,18 @@ dependencies = [
|
||||||
]
|
]
|
||||||
sdist = { url = "https://files.pythonhosted.org/packages/dd/57/a173e3eb86072b7ee77650aca496b15d6886367d257f58ea9de5276e330a/flake8-quotes-3.4.0.tar.gz", hash = "sha256:aad8492fb710a2d3eabe68c5f86a1428de650c8484127e14c43d0504ba30276c", size = 14107, upload-time = "2024-02-10T21:58:22.357Z" }
|
sdist = { url = "https://files.pythonhosted.org/packages/dd/57/a173e3eb86072b7ee77650aca496b15d6886367d257f58ea9de5276e330a/flake8-quotes-3.4.0.tar.gz", hash = "sha256:aad8492fb710a2d3eabe68c5f86a1428de650c8484127e14c43d0504ba30276c", size = 14107, upload-time = "2024-02-10T21:58:22.357Z" }
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "flake8-sfs"
|
||||||
|
version = "1.0.1"
|
||||||
|
source = { registry = "https://pypi.org/simple" }
|
||||||
|
dependencies = [
|
||||||
|
{ name = "flake8" },
|
||||||
|
]
|
||||||
|
sdist = { url = "https://files.pythonhosted.org/packages/10/d0/f382713010bb429934fd03b9b0cc8726ef620719fec49c942e8fc41454e7/flake8_sfs-1.0.1.tar.gz", hash = "sha256:0cab211f805efe2b29a8480fda0d46a8cedba1d45b4dd71b9bd0675804097149", size = 6531, upload-time = "2025-09-21T09:31:42.454Z" }
|
||||||
|
wheels = [
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/d1/a8/dc3b3dbe52808d3f09504950d20963a3e19ab1bf6492790b70b8b2e32565/flake8_sfs-1.0.1-py3-none-any.whl", hash = "sha256:ef5f6b3e6d958894fe4c953ecf8e6156d9ab620c7e138f68af5c0f9bfdb4f6b4", size = 6651, upload-time = "2025-09-21T09:31:41.166Z" },
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "folium"
|
name = "folium"
|
||||||
version = "1.0.0"
|
version = "1.0.0"
|
||||||
|
|
@ -3680,6 +3692,7 @@ dev = [
|
||||||
{ name = "flake8-pyproject" },
|
{ name = "flake8-pyproject" },
|
||||||
{ name = "flake8-pytest-style" },
|
{ name = "flake8-pytest-style" },
|
||||||
{ name = "flake8-quotes" },
|
{ name = "flake8-quotes" },
|
||||||
|
{ name = "flake8-sfs" },
|
||||||
{ name = "isort" },
|
{ name = "isort" },
|
||||||
{ name = "mypy" },
|
{ name = "mypy" },
|
||||||
{ name = "nox" },
|
{ name = "nox" },
|
||||||
|
|
@ -3739,6 +3752,7 @@ dev = [
|
||||||
{ name = "flake8-pyproject", specifier = ">=1.2.4,<2.0.0" },
|
{ name = "flake8-pyproject", specifier = ">=1.2.4,<2.0.0" },
|
||||||
{ name = "flake8-pytest-style", specifier = ">=2.2.0,<3.0.0" },
|
{ name = "flake8-pytest-style", specifier = ">=2.2.0,<3.0.0" },
|
||||||
{ name = "flake8-quotes", specifier = ">=3.4.0,<4.0.0" },
|
{ name = "flake8-quotes", specifier = ">=3.4.0,<4.0.0" },
|
||||||
|
{ name = "flake8-sfs", specifier = ">=1.0.1,<2.0.0" },
|
||||||
{ name = "isort", specifier = ">=9.0.2,<10.0.0" },
|
{ name = "isort", specifier = ">=9.0.2,<10.0.0" },
|
||||||
{ name = "mypy", specifier = ">=2.4.1,<3.0.0" },
|
{ name = "mypy", specifier = ">=2.4.1,<3.0.0" },
|
||||||
{ name = "nox", specifier = ">=2026.10.20" },
|
{ name = "nox", specifier = ">=2026.10.20" },
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue