Skip to content

GitLab

  • Menu
Projects Groups Snippets
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
  • logilab-common logilab-common
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 7
    • Issues 7
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 3
    • Merge requests 3
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • open-source
  • logilab-commonlogilab-common
  • Merge requests
  • !35

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

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged Simon Chabot requested to merge topic/default/typing-typeddict into branch/default Jan 05, 2021
  • Overview 0
  • Commits 2
  • Pipelines 4
  • Changes 2
  • 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 Jan 05, 2021 by Simon Chabot
Assignee
Assign to
Reviewer
Request review from
Time tracking
Source branch: topic/default/typing-typeddict