From 50195ec8d1052d2b7a80f47a3709ebc4e74d6764 Mon Sep 17 00:00:00 2001 From: Brett Holman Date: Mon, 14 Feb 2022 12:24:00 -0700 Subject: use PEP 589 syntax for TypeDict (#1253) Use PEP 589 syntax for TypeDict annotation. Also fixes previously broken typing MetaSchema typing implementation. --- cloudinit/importer.py | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) (limited to 'cloudinit/importer.py') diff --git a/cloudinit/importer.py b/cloudinit/importer.py index f84ff4da..2bc210dd 100644 --- a/cloudinit/importer.py +++ b/cloudinit/importer.py @@ -12,21 +12,19 @@ import sys import typing # annotations add value for development, but don't break old versions -# pyver: 3.5 -> 3.8 +# pyver: 3.6 -> 3.8 # pylint: disable=E1101 -if sys.version_info >= (3, 8) and hasattr(typing, "TypeDict"): - MetaSchema = typing.TypedDict( - "MetaSchema", - { - "name": str, - "id": str, - "title": str, - "description": str, - "distros": typing.List[str], - "examples": typing.List[str], - "frequency": str, - }, - ) +if sys.version_info >= (3, 8): + + class MetaSchema(typing.TypedDict): + name: str + id: str + title: str + description: str + distros: typing.List[str] + examples: typing.List[str] + frequency: str + else: MetaSchema = dict # pylint: enable=E1101 -- cgit v1.2.3