Skip to content

Convert to Python 3.9: convert most internal mappings to dicts#1166

Merged
nolar merged 21 commits into
mainfrom
convert-to-python39-narrow-down-dicts
Mar 21, 2026
Merged

Convert to Python 3.9: convert most internal mappings to dicts#1166
nolar merged 21 commits into
mainfrom
convert-to-python39-narrow-down-dicts

Conversation

@nolar

@nolar nolar commented Mar 27, 2025

Copy link
Copy Markdown
Owner

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 nolar added the refactoring Code cleanup without new features added label Mar 27, 2025
@nolar nolar force-pushed the convert-to-python39-narrow-down-dicts branch 2 times, most recently from 2d51a3f to 339767a Compare March 21, 2026 13:31
nolar added 21 commits March 21, 2026 14:49
Signed-off-by: Sergey Vasilyev <nolar@nolar.info>
… filters

Signed-off-by: Sergey Vasilyev <nolar@nolar.info>
Signed-off-by: Sergey Vasilyev <nolar@nolar.info>
Signed-off-by: Sergey Vasilyev <nolar@nolar.info>
Signed-off-by: Sergey Vasilyev <nolar@nolar.info>
Signed-off-by: Sergey Vasilyev <nolar@nolar.info>
…ults

Signed-off-by: Sergey Vasilyev <nolar@nolar.info>
Signed-off-by: Sergey Vasilyev <nolar@nolar.info>
…r classes

Signed-off-by: Sergey Vasilyev <nolar@nolar.info>
…red)

Signed-off-by: Sergey Vasilyev <nolar@nolar.info>
…t (initial & updated)

Signed-off-by: Sergey Vasilyev <nolar@nolar.info>
…ssion)

Signed-off-by: Sergey Vasilyev <nolar@nolar.info>
…ing)

Signed-off-by: Sergey Vasilyev <nolar@nolar.info>
…abels & annotations)

Signed-off-by: Sergey Vasilyev <nolar@nolar.info>
…rogression)

Signed-off-by: Sergey Vasilyev <nolar@nolar.info>
… tests)

Signed-off-by: Sergey Vasilyev <nolar@nolar.info>
…x the signatures)

Signed-off-by: Sergey Vasilyev <nolar@nolar.info>
Signed-off-by: Sergey Vasilyev <nolar@nolar.info>
…dy, or the essence

Signed-off-by: Sergey Vasilyev <nolar@nolar.info>
Signed-off-by: Sergey Vasilyev <nolar@nolar.info>
… ever

Signed-off-by: Sergey Vasilyev <nolar@nolar.info>
@nolar nolar force-pushed the convert-to-python39-narrow-down-dicts branch from 339767a to 29abccb Compare March 21, 2026 13:55
@nolar nolar merged commit 60802ed into main Mar 21, 2026
25 checks passed
@nolar nolar deleted the convert-to-python39-narrow-down-dicts branch March 21, 2026 14:32
@nolar nolar changed the title Convert to Python 3.9: convert most mappings to dicts Convert to Python 3.9: convert most internal mappings to dicts Mar 23, 2026
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.

1 participant