Remove assert statements from production code

This commit is contained in:
Julian Stirling 2025-09-18 11:39:02 +01:00
parent 6d8cb299aa
commit ef89b536fc
3 changed files with 7 additions and 8 deletions

View file

@ -14,7 +14,8 @@ with open(os.path.join("webapp", "package.json"), "r", encoding="utf-8") as json
py_ver = pyproject_data["project"]["version"] py_ver = pyproject_data["project"]["version"]
js_ver = webapp_data["version"] js_ver = webapp_data["version"]
assert py_ver == js_ver, ( # Allow an assert here as this is a CI script, not production code.
assert py_ver == js_ver, ( # noqa S101
"The python and javascript version numbers should match.\n" "The python and javascript version numbers should match.\n"
f"Python version: {py_ver}\n" f"Python version: {py_ver}\n"
f"Javascript version: {js_ver}\n" f"Javascript version: {js_ver}\n"

View file

@ -126,6 +126,7 @@ select = [
"N", # PEP8 naming "N", # PEP8 naming
"D", # Docstring checks "D", # Docstring checks
"ERA001", # Commented out code! "ERA001", # Commented out code!
"S101",# No asserts!
"ANN", "ANN",
] ]
@ -139,14 +140,10 @@ ignore = [
] ]
[tool.ruff.lint.per-file-ignores] [tool.ruff.lint.per-file-ignores]
# Tests are currently not fully docstring-ed, we'll ignore this for now. "{tests,integration-tests,hardware-specific-tests}/**" = [
"tests/*" = [
"B018", # Complaining about useless attribute access in tests, but we need them to check errors are raised
"ANN", # Tests are not typehinted for fixtures etc
]
"hardware-specific-tests/*" = [
"B018", # Complaining about useless attribute access in tests, but we need them to check errors are raised "B018", # Complaining about useless attribute access in tests, but we need them to check errors are raised
"ANN", # Tests are not typehinted for fixtures etc "ANN", # Tests are not typehinted for fixtures etc
"S101", # Allow asserts in tests
] ]
[tool.ruff.lint.pydocstyle] [tool.ruff.lint.pydocstyle]

View file

@ -38,7 +38,8 @@ def set_static_lst(
adaptive tweaking by the algorithm. adaptive tweaking by the algorithm.
""" """
for table in luminance, cr, cb: for table in luminance, cr, cb:
assert np.array(table).shape == (12, 16), "Lens shading tables must be 12x16!" if np.array(table).shape != (12, 16):
raise ValueError("Lens shading tables must be 12x16!")
alsc = Picamera2.find_tuning_algo(tuning, "rpi.alsc") alsc = Picamera2.find_tuning_algo(tuning, "rpi.alsc")
alsc["n_iter"] = 0 # disable the adaptive part alsc["n_iter"] = 0 # disable the adaptive part
alsc["luminance_strength"] = 1.0 alsc["luminance_strength"] = 1.0