Enable SIM in flake8 and ruff
This commit is contained in:
parent
5dce8e6645
commit
007998372f
9 changed files with 33 additions and 36 deletions
|
|
@ -21,14 +21,11 @@ log_config.fileConfig(context.config.config_file_name)
|
|||
|
||||
def include_object(obj, _name, type_, _reflected, _compare_to):
|
||||
"""Only include the clean schema into --autogenerate migrations."""
|
||||
if (
|
||||
return not (
|
||||
type_ in {"table", "column"}
|
||||
and hasattr(obj, "schema") # => fix for rare edge case
|
||||
and obj.schema != pkg_config.CLEAN_SCHEMA
|
||||
):
|
||||
return False
|
||||
|
||||
return True
|
||||
)
|
||||
|
||||
|
||||
# Without a `pool`, the `connection` really closes after the migrations
|
||||
|
|
|
|||
|
|
@ -204,6 +204,7 @@ def lint_code(session: nox.Session) -> None:
|
|||
"flake8-pytest-style",
|
||||
"flake8-quotes",
|
||||
"flake8-sfs",
|
||||
"flake8-simplify",
|
||||
"flake8-todos",
|
||||
"flake8-unused-arguments",
|
||||
"isort",
|
||||
|
|
@ -641,9 +642,7 @@ def skip_install(session: nox.Session) -> bool:
|
|||
# Same logic to skip package installation as in core `nox`
|
||||
# See: https://github.com/wntrblm/nox/blob/2026.10.20/nox/sessions.py#L905
|
||||
venv = session._runner.venv
|
||||
if session._runner.global_config.no_install and venv._reused:
|
||||
return True
|
||||
return False
|
||||
return bool(session._runner.global_config.no_install and venv._reused)
|
||||
|
||||
|
||||
if MAIN_PYTHON not in SUPPORTED_PYTHONS:
|
||||
|
|
|
|||
|
|
@ -104,6 +104,7 @@ dev = [
|
|||
"flake8-pytest-style (>=2.2.0,<3.0.0)",
|
||||
"flake8-quotes (>=3.4.0,<4.0.0)",
|
||||
"flake8-sfs (>=1.0.1,<2.0.0)",
|
||||
"flake8-simplify (>=0.31.1,<0.32.0)",
|
||||
"flake8-todos (>=0.3.1,<0.4.0)",
|
||||
"flake8-unused-arguments (>=0.0.14,<0.1.0)",
|
||||
"mypy (>=2.4.1,<3.0.0)",
|
||||
|
|
@ -223,6 +224,8 @@ select = [
|
|||
"Q0",
|
||||
# flake8-sfs => use f-strings as the only type of string formatting
|
||||
"SFS",
|
||||
# flake8-simplify => Simpler code
|
||||
"SIM",
|
||||
# flake8-todos => unify TODOs
|
||||
"T00",
|
||||
# flake8-unused-arguments => declared function arguments must be used
|
||||
|
|
@ -256,6 +259,8 @@ extend-ignore = [
|
|||
"PT023",
|
||||
# Allow f-strings as the only type of string formatting.
|
||||
"SFS301",
|
||||
# `bool()` around a comparison can be deliberate (`ruff` omits this rule).
|
||||
"SIM901",
|
||||
# TODOs need neither an author nor an issue.
|
||||
"T002", "T003",
|
||||
]
|
||||
|
|
@ -477,6 +482,8 @@ select = [
|
|||
"Q",
|
||||
# flake8-bandit => common security issues
|
||||
"S",
|
||||
# flake8-simplify => Simpler code
|
||||
"SIM",
|
||||
# flake8-debugger => no debugger usage
|
||||
"T10",
|
||||
# flake8-todos => unify TODOs
|
||||
|
|
|
|||
|
|
@ -100,10 +100,7 @@ def make_comment(
|
|||
|
||||
is_latest = pinned_version == latest_version
|
||||
|
||||
if is_latest:
|
||||
comment = "up-to-date"
|
||||
else:
|
||||
comment = f"< {latest_version:<8}"
|
||||
comment = "up-to-date" if is_latest else f"< {latest_version:<8}"
|
||||
|
||||
if years_since_release > PKG_CONSIDERED_OLD:
|
||||
comment += f" {years_since_release} years ago"
|
||||
|
|
|
|||
|
|
@ -232,25 +232,13 @@ class Forecast(meta.Base):
|
|||
low95 = data.loc[timestamp_idx, "low95"]
|
||||
high95 = data.loc[timestamp_idx, "high95"]
|
||||
|
||||
if math.isnan(low80):
|
||||
low80 = None
|
||||
else:
|
||||
low80 = float(round(low80, 5))
|
||||
low80 = None if math.isnan(low80) else float(round(low80, 5))
|
||||
|
||||
if math.isnan(high80):
|
||||
high80 = None
|
||||
else:
|
||||
high80 = float(round(high80, 5))
|
||||
high80 = None if math.isnan(high80) else float(round(high80, 5))
|
||||
|
||||
if math.isnan(low95):
|
||||
low95 = None
|
||||
else:
|
||||
low95 = float(round(low95, 5))
|
||||
low95 = None if math.isnan(low95) else float(round(low95, 5))
|
||||
|
||||
if math.isnan(high95):
|
||||
high95 = None
|
||||
else:
|
||||
high95 = float(round(high95, 5))
|
||||
high95 = None if math.isnan(high95) else float(round(high95, 5))
|
||||
|
||||
forecasts.append(
|
||||
cls(
|
||||
|
|
|
|||
|
|
@ -177,10 +177,7 @@ class Pixel(meta.Base):
|
|||
info_text = f"Pixel({self.n_x}|{self.n_y})"
|
||||
|
||||
# Make the `Pixel`s look like a checkerboard.
|
||||
if (self.n_x + self.n_y) % 2:
|
||||
color = "#808000"
|
||||
else:
|
||||
color = "#ff8c00"
|
||||
color = "#808000" if (self.n_x + self.n_y) % 2 else "#ff8c00"
|
||||
|
||||
marker = folium.Rectangle(
|
||||
bounds=bounds,
|
||||
|
|
|
|||
|
|
@ -580,9 +580,7 @@ class OrderHistory:
|
|||
# For now, we only make forecasts with 7 and 8 weeks
|
||||
# as the training horizon (note:4f79e8fa).
|
||||
if train_horizon in {7, 8}:
|
||||
if add >= 25: # = "high demand"
|
||||
return models.HorizontalETSModel(order_history=self)
|
||||
elif add >= 10: # = "medium demand"
|
||||
if add >= 10: # = "high" or "medium demand"
|
||||
return models.HorizontalETSModel(order_history=self)
|
||||
elif add >= 2.5: # = "low demand"
|
||||
return models.HorizontalSMAModel(order_history=self)
|
||||
|
|
|
|||
|
|
@ -156,7 +156,7 @@ class TestProperties:
|
|||
result = location.zone_details
|
||||
|
||||
zone, band = result
|
||||
assert ZONE == f"{zone}{band}"
|
||||
assert f"{zone}{band}" == ZONE
|
||||
|
||||
|
||||
class TestRelateTo:
|
||||
|
|
|
|||
14
uv.lock
generated
14
uv.lock
generated
|
|
@ -1051,6 +1051,18 @@ 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]]
|
||||
name = "flake8-simplify"
|
||||
version = "0.31.1"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
dependencies = [
|
||||
{ name = "flake8" },
|
||||
]
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/57/3f/484e219a4ecc0242d36135ebe220470633dca035dcea9ce17ad72639db56/flake8_simplify-0.31.1.tar.gz", hash = "sha256:3830f39afed7dc76d6a6f4db006f5a460e1cb8ebe82e08c1d99c5f4e24fab26d", size = 19888, upload-time = "2026-10-06T14:52:31.849Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/11/58/0d4fd5b09de83c42e785b08c21b4bcd3e8f196284293a128037280475e40/flake8_simplify-0.31.1-py3-none-any.whl", hash = "sha256:642c1688a7308e00c6b2b2eb47b0cc66e6ee8440227b8540bab7d05e382279cc", size = 27446, upload-time = "2026-10-06T14:52:30.657Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "flake8-todos"
|
||||
version = "0.3.1"
|
||||
|
|
@ -3791,6 +3803,7 @@ dev = [
|
|||
{ name = "flake8-pytest-style" },
|
||||
{ name = "flake8-quotes" },
|
||||
{ name = "flake8-sfs" },
|
||||
{ name = "flake8-simplify" },
|
||||
{ name = "flake8-todos" },
|
||||
{ name = "flake8-unused-arguments" },
|
||||
{ name = "flynt" },
|
||||
|
|
@ -3857,6 +3870,7 @@ dev = [
|
|||
{ name = "flake8-pytest-style", specifier = ">=2.2.0,<3.0.0" },
|
||||
{ name = "flake8-quotes", specifier = ">=3.4.0,<4.0.0" },
|
||||
{ name = "flake8-sfs", specifier = ">=1.0.1,<2.0.0" },
|
||||
{ name = "flake8-simplify", specifier = ">=0.31.1,<0.32.0" },
|
||||
{ name = "flake8-todos", specifier = ">=0.3.1,<0.4.0" },
|
||||
{ name = "flake8-unused-arguments", specifier = ">=0.0.14,<0.1.0" },
|
||||
{ name = "flynt", specifier = ">=1.0.6,<2.0.0" },
|
||||
|
|
|
|||
Loading…
Reference in a new issue