Skip to content

fix(registry): use TypedDict when python version >= 3.8, otherwise a Dict

Simon Chabot requested to merge topic/default/typing-typeddict into branch/default
  • TypedDict is provided by the typing module for python >= 3.8
  • TypedDict is provided by the typing_extensions module for typing_extensions >= 3.7.4

but this module is not available as debian buster package.

  • mypy does not support condition types defined like that:
if CONDITION:
    type = Dict
else:
    type = TypedDict

and therefore it's not possible to conditionally declare the type.

but… it does support checks with python version or system platform (cf: https://mypy.readthedocs.io/en/stable/common_issues.html#python-version-and-system-platform-checks).

Let's import TypedDict from typing when it's available (python >= 3.8), and use it. Otherwise, let's use a simple dict.

related #9

Edited by Simon Chabot

Merge request reports

Loading