• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Chia-Network / chia-blockchain / 23763249263

30 Mar 2026 07:21PM UTC coverage: 91.165% (-0.06%) from 91.225%
23763249263

push

github

web-flow
mypy: remove exclusion for chia.wallet.key_val_store (#20618)

### Purpose:

Remove `chia.wallet.key_val_store` from the mypy strict-mode exclusion
list by adding full type annotations. Also fixes a pre-existing bug in
`WalletBlockchain.create()` where DB-persisted `SUB_SLOT_ITERS` and
`DIFFICULTY` values were silently discarded. This does not introduce a
breaking change.

### Current Behavior:

- `chia.wallet.key_val_store` is excluded from mypy strict checking. The
`KeyValStore` methods use `Any` for `object_type` and `obj` parameters,
and `create`, `set_object`, and `remove_object` lack return type
annotations.
- `WalletBlockchain.create()` loads `SUB_SLOT_ITERS` and `DIFFICULTY`
from the key-value store, but unconditionally overwrites them with
`constants.SUB_SLOT_ITERS_STARTING` and `constants.DIFFICULTY_STARTING`
a few lines later, making the DB reads dead stores.

### New Behavior:

- Define a `_Serializable` Protocol capturing the
`from_bytes`/`stream_to_bytes` interface used by all stored types
(`Streamable` subclasses, `uint32`, `uint64`, etc.).
- `get_object` is now generic: `(key: str, object_type: type[_T]) -> _T
| None` where `_T` is bound to `_Serializable`.
- `set_object` annotates `obj` as `_Serializable` instead of `Any`, with
`-> None`.
- `create` returns `Self`; `remove_object` returns `None`.
- Fix downstream `assignment` errors in `wallet_blockchain.py` where
`get_object` now correctly returns `T | None` — uses temporary variables
with `None` defaults.
- Remove the unconditional overwrites of `_sub_slot_iters` and
`_difficulty` in `WalletBlockchain.create()`, so DB-persisted values are
preserved when available, falling back to starting constants only when
the store returns `None`.
- Remove `chia.wallet.key_val_store` from `mypy-exclusions.txt`.

### Testing Notes:

- `pre-commit run mypy --all-files` passes (936 source files checked,
zero errors).
- `ruff check` and `ruff format --check` pass on all changed files.
- `test_wallet_... (continued)

10475 of 11664 branches covered (89.81%)

Branch coverage included in aggregate %.

39 of 39 new or added lines in 3 files covered. (100.0%)

80 existing lines in 28 files now uncovered.

106421 of 116560 relevant lines covered (91.3%)

1.83 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

86.75
/chia/full_node/full_node_api.py


Source Not Available

STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc