Skip to content

Conversation

@nolar
Copy link
Owner

@nolar nolar commented Mar 27, 2025

An extended follow-up for:

Here, minimize the usage of Mapping & MutableMapping and reduce them to the built-in generic dict.

Excluded from the conversion:

  • Generic type declarations that implement the interface of Mapping/MutableMapping.
  • Live views into the underlying dicts, such as Body/Spec/Meta/Labels/Annotations.
  • All user-facing public API routines that accept dict-like values, such as object/label/metadata manipulation.
  • All user-facing public API types that are not promised to be dicts, though can be de-facto dicts.
    • Except for the webhook HTTP headers & SSL peer info, which are now promised to be dicts.

The Iterable / Iterator / Container / Collection / Sequence generics are NOT converted or narrowed down to their concrete types, even internally. While the conversion of mappings to dicts simplifies the codebase, the conversion of these generics would do the opposite — it will complicate the codebase. We need to know the bare minimum behaviour that we can use in a routine, and allow the callers of this routine to inject any possible containers they prefer on their side.

Such distinction is of little significance for the only two types of mappings: readonly vs. mutable — we can ignore it, we use dicts in all cases anyway. (Except for the "live views" on bodies for a bit of syntax sugar.)

nolar added 20 commits March 27, 2025 17:11
@nolar nolar added the refactoring Code cleanup without new features added label Mar 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactoring Code cleanup without new features added

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants