Skip to content

Investigate and redesign typing in resolve_one_of (temporary fix in place) #1110

@Laure-di

Description

@Laure-di

Description:

A temporary fix has been applied to use from future import annotations to resolve an import and typing issue affecting the function resolve_one_of.

Context:

In the function:

https://github.com/scaleway/scaleway-sdk-python/blob/main/scaleway-core/scaleway_core/utils/resolve_one_of.py#L21

We encountered issues with the typing module, particularly with aliases like SupportsKeysAndGetItem, which appear to behave inconsistently or are potentially deprecated in some Python versions.
Related documentation:
🔗 https://docs.python.org/3/library/typing.html#deprecated-aliases

Problem:

Python’s typing module has deprecated or altered behavior for certain constructs.
This affects the return type annotation and possibly others that rely on complex generic types.
The fix using future.annotations is temporary and avoids immediate runtime or type-checking issues, but isn't a long-term solution.

Next Steps:

Audit the use of typing across the project for deprecated or unstable patterns.
Ensure that returned dictionary-like structures have a clean, sustainable, and type-safe definition.
Evaluate whether custom Protocols or TypedDict should be used instead of generic built-ins like SupportsKeysAndGetItem.
Replace temporary imports once a long-term design is adopted.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions