oliver-zehentleitner / maity
hub: limits: one range table and validator, one override reader, one unlimited conversion; drop ceilings.setter
tsk-9my6cqexh8ee Open
Audit round 3 (tsk-hgnbapyw7hnh), read at 588f911b. Kind: duplication / dead code.
What is wrong
- Ranges:
hub/src/maity_hub/limits.py:51-70(RANGES,_checker) andhub/src/maity_hub/limit_overrides.py:27-42(RANGES,_valid) repeat the same bounds (1-10000 account values, 1 MiB-1 PiB project storage) and the same int-not-bool check. - Override rows are read three ways:
ceilings.py:59-65(stored_override),limit_overrides.py:103-106(_rows), and thetargetexpression again atlimit_overrides.py:86. unlimitedto a number five times:limits.py:85,:108,:120;read_limits.py:134,:142;ceilings.py:69(_number, with atype: ignore[call-overload]).- Slow admin view:
limit_overrides.project_view(:132-137) callsceilings.ceilingper value, re-reading overrides it already holds;_by(:109-113) runs one handle query per field. - Dead:
ceilings.setter(ceilings.py:112-114) has no caller in hub/ or web/;routes/project_limits.py:172computes its own boolean.
Proposal: one range table and validator in limits.py imported by limit_overrides.py; one overrides(conn, project_id|human_id) reader; one cap_of(value) helper without type: ignore; build project_view from the rows already loaded; delete setter.
Effort / risk: M. Low risk.
Notes
Lotse · Nov 21, 2026, 01:58 UTC
Audit round 4 (tsk-hgnbapyw7hnh, read at 0a1b832e): #1986 added a fourth case of the same pattern.
limits.starred(hub/src/maity_hub/limits.py:102-106) is a copy oflimits.aliases(limits.py:95-99):store.effective(f"limits.{NAME}", env, store.stored(conn, "limits"))for one bounded cap. Onebounded(conn, hub, name)serves both.- The bounds 1-8 and 1-1000 are written in
config.py(parse_alias_limit,config.py:566-569;parse_bounded(env, "MAITY_MAX_STARRED_PER_HUMAN", 1, 1000),config.py:329) and again inlimits.RANGES(limits.py:57-62).parse_alias_limitis now a one-line wrapper with one caller (config.py:328).