Commit graph jw-python/src/python/jw/util/Options.py
Author SHA1 Message Date
c679505053
Options.__init__(): Annotate __allowed_keys as Any
mypy 2.4.0 infers the attribute from the None assignment in __init__() and
then flags the right operand of the and check in __parse__() as unreachable
code, failing make check.

The attribute is only ever assigned None, so annotate it as Any and keep
the runtime behaviour unchanged.

Assisted-by: unsloth/Qwen3.8-27B-GGUF:Q4_K_M with pi.dev v1.5.2
Signed-off-by: Jan Lindemann <jan@janware.com>
2026-11-13 15:09:33 +01:00
b192207bbd
Options.get(): Fix inverted by_index check
The by_index branch of Options.get() raises KeyError for every integer
index, because the first isinstance guard is inverted: it fires for exactly
the keys the branch is supposed to handle, so the range check and the
lookup in the list of parsed keys below it are dead code. A non-integer key
with by_index set slips past the guard and falls through to the regular key
lookup instead. A previous make-check fallout commit flipped the original
type(key) != int test into a positive isinstance test, and a later mypy fix
then added redundant isinstance guards to the unreachable branches,
cementing the broken flow.

Invert the guard back to not isinstance(key, int), so that a non-integer
key raises KeyError, an in-range integer index returns the key stored at
that position in the option string, and an out-of-range index returns the
default or raises KeyError. Drop the redundant isinstance guards from the
now-reachable branches.

TODO: The bug actually made "make -C test/parse_opts run" fail, but since
jw-python's nightly CI doesn't run that, this has gone unnoticed. The test
now passes, but should be replaced with a better test (executed by "make
test", and pytest-based).

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-09-18 09:44:26 +02:00
9323529187
mypy: Fix no_untyped_defs
Add type annotations to 30 files across jw.util, resolving all
191 'no-untyped-def' mypy errors in strict mode.

The changes cover Signals, CppState, Bunch, RedirectStdIO, StopWatch,
Process, Options, ArgsContainer, Object, multi_key_dict, ldap, Session,
rows, ShuntingYard, TableIoHandler, DataBase, Queries, Query, QueryResult,
and all db/schema files (Column, Table, ColumnSet, DataType, Schema,
SingleForeignKey, CompositeForeignKey), plus asyncio variants and
ev/base/Object and auth/dummy/Auth.

Additionally, unreachable code and type annotation conflicts were
resolved in StopWatch.py, Options.py, rows.py, and Table.py.

Assisted-by: unsloth/Qwen3.6-35B-A3B-GGUF:IQ4_NL with pi.dev v0.82.0
Signed-off-by: Jan Lindemann <jan@janware.com>
2026-08-12 23:10:13 +00:00
e3c64f2efb
jw.util: Add @override
Add @override qualifiers to overridden methods.

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-08-12 23:10:12 +00:00
e9845b5a1f
Makefile: Include py-topdir.mk
Include py-topdir.mk, which entails loads of fallout from make check.
Fix it.

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-06-12 04:55:47 +02:00
a2684dd601
jwutils: Move to jwutils -> jw.util
Move all implementation source code from the jwutils module to
jw.util. For compatibility with existing Python modules, keep a thin,
autogenerated compatibility shim under jwutils.

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-06-11 23:10:25 +00:00
Renamed from tools/python/jwutils/Options.py (Previous history)