8000 Convert to Python 3.9: convert most mappings to dicts by nolar · Pull Request #1166 · nolar/kopf · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 20 commits into
base: main
Choose a base branch
from

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
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>
…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 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.

1 participant
0