Skip to content

typing(config): remove 4 type:ignore in coerce_and_validate#188

Merged
memtomem merged 2 commits intomainfrom
typing/config-coerce-validate-101
Apr 16, 2026
Merged

typing(config): remove 4 type:ignore in coerce_and_validate#188
memtomem merged 2 commits intomainfrom
typing/config-coerce-validate-101

Conversation

@memtomem
Copy link
Copy Markdown
Owner

Summary

  • Widen `coerced` annotation from `object` to
    `bool | int | float | str | list[object]` — the actual union the
    variable inhabits at runtime.
  • Add `isinstance` guards before `int(value)` / `float(value)`
    calls so mypy can verify the overload resolution.
  • Use `cast` for the unreachable `else` fallback (no known
    `FIELD_CONSTRAINTS` type reaches it).
  • Narrow min/max constraint values with `isinstance` to make `<` /
    `>` operators type-safe.

Closes #101

- Widen coerced annotation from object to the actual union
- Add isinstance guards before int()/float() calls to narrow value
- Use cast for unreachable else fallback
- Narrow min/max constraint values with isinstance for < / > operators
@memtomem memtomem merged commit e04b25e into main Apr 16, 2026
5 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 16, 2026
@memtomem memtomem deleted the typing/config-coerce-validate-101 branch April 16, 2026 15:17
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

config: resolve '# type: ignore[arg-type|operator]' in _coerce_and_validate

2 participants