diff options
author | Brett Holman <bholman.devel@gmail.com> | 2022-02-14 12:24:00 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-14 13:24:00 -0600 |
commit | 50195ec8d1052d2b7a80f47a3709ebc4e74d6764 (patch) | |
tree | 4abf46c23a891199f5e13aff3071feaebeb36d38 /cloudinit | |
parent | 9ba3ca6ce5013207737e431f52735c7eda3a2fbb (diff) | |
download | vyos-cloud-init-50195ec8d1052d2b7a80f47a3709ebc4e74d6764.tar.gz vyos-cloud-init-50195ec8d1052d2b7a80f47a3709ebc4e74d6764.zip |
use PEP 589 syntax for TypeDict (#1253)
Use PEP 589 syntax for TypeDict annotation.
Also fixes previously broken typing MetaSchema typing implementation.
Diffstat (limited to 'cloudinit')
-rw-r--r-- | cloudinit/config/cc_apk_configure.py | 4 | ||||
-rw-r--r-- | cloudinit/config/cc_apt_configure.py | 4 | ||||
-rw-r--r-- | cloudinit/config/cc_apt_pipelining.py | 4 | ||||
-rw-r--r-- | cloudinit/config/cc_bootcmd.py | 4 | ||||
-rwxr-xr-x | cloudinit/config/cc_byobu.py | 4 | ||||
-rw-r--r-- | cloudinit/config/cc_ca_certs.py | 4 | ||||
-rw-r--r-- | cloudinit/config/cc_chef.py | 4 | ||||
-rw-r--r-- | cloudinit/config/cc_debug.py | 4 | ||||
-rw-r--r-- | cloudinit/config/cc_disable_ec2_metadata.py | 4 | ||||
-rw-r--r-- | cloudinit/config/cc_disk_setup.py | 4 | ||||
-rw-r--r-- | cloudinit/config/cc_install_hotplug.py | 8 | ||||
-rw-r--r-- | cloudinit/config/cc_keyboard.py | 8 | ||||
-rw-r--r-- | cloudinit/config/cc_locale.py | 8 | ||||
-rw-r--r-- | cloudinit/config/cc_ntp.py | 8 | ||||
-rw-r--r-- | cloudinit/config/cc_resizefs.py | 8 | ||||
-rw-r--r-- | cloudinit/config/cc_runcmd.py | 8 | ||||
-rw-r--r-- | cloudinit/config/cc_snap.py | 8 | ||||
-rw-r--r-- | cloudinit/config/cc_ubuntu_advantage.py | 8 | ||||
-rw-r--r-- | cloudinit/config/cc_ubuntu_drivers.py | 8 | ||||
-rw-r--r-- | cloudinit/config/cc_write_files.py | 8 | ||||
-rw-r--r-- | cloudinit/config/cc_zypper_add_repo.py | 4 | ||||
-rw-r--r-- | cloudinit/importer.py | 26 |
22 files changed, 94 insertions, 56 deletions
diff --git a/cloudinit/config/cc_apk_configure.py b/cloudinit/config/cc_apk_configure.py index 2cb2dad1..0952c971 100644 --- a/cloudinit/config/cc_apk_configure.py +++ b/cloudinit/config/cc_apk_configure.py @@ -10,7 +10,7 @@ from textwrap import dedent from cloudinit import log as logging from cloudinit import temp_utils, templater, util -from cloudinit.config.schema import get_meta_doc +from cloudinit.config.schema import MetaSchema, get_meta_doc from cloudinit.settings import PER_INSTANCE LOG = logging.getLogger(__name__) @@ -53,7 +53,7 @@ REPOSITORIES_TEMPLATE = """\ frequency = PER_INSTANCE distros = ["alpine"] -meta = { +meta: MetaSchema = { "id": "cc_apk_configure", "name": "APK Configure", "title": "Configure apk repositories file", diff --git a/cloudinit/config/cc_apt_configure.py b/cloudinit/config/cc_apt_configure.py index 7fe0e343..c558311a 100644 --- a/cloudinit/config/cc_apt_configure.py +++ b/cloudinit/config/cc_apt_configure.py @@ -17,7 +17,7 @@ from textwrap import dedent from cloudinit import gpg from cloudinit import log as logging from cloudinit import subp, templater, util -from cloudinit.config.schema import get_meta_doc +from cloudinit.config.schema import MetaSchema, get_meta_doc from cloudinit.settings import PER_INSTANCE LOG = logging.getLogger(__name__) @@ -32,7 +32,7 @@ CLOUD_INIT_GPG_DIR = "/etc/apt/cloud-init.gpg.d/" frequency = PER_INSTANCE distros = ["ubuntu", "debian"] -meta = { +meta: MetaSchema = { "id": "cc_apt_configure", "name": "Apt Configure", "title": "Configure apt for the user", diff --git a/cloudinit/config/cc_apt_pipelining.py b/cloudinit/config/cc_apt_pipelining.py index 34b6ac0e..901633d3 100644 --- a/cloudinit/config/cc_apt_pipelining.py +++ b/cloudinit/config/cc_apt_pipelining.py @@ -9,7 +9,7 @@ from textwrap import dedent from cloudinit import util -from cloudinit.config.schema import get_meta_doc +from cloudinit.config.schema import MetaSchema, get_meta_doc from cloudinit.settings import PER_INSTANCE frequency = PER_INSTANCE @@ -24,7 +24,7 @@ APT_PIPE_TPL = ( # A value of zero MUST be specified if the remote host does not properly linger # on TCP connections - otherwise data corruption will occur. -meta = { +meta: MetaSchema = { "id": "cc_apt_pipelining", "name": "Apt Pipelining", "title": "Configure apt pipelining", diff --git a/cloudinit/config/cc_bootcmd.py b/cloudinit/config/cc_bootcmd.py index 3a239376..bd14aede 100644 --- a/cloudinit/config/cc_bootcmd.py +++ b/cloudinit/config/cc_bootcmd.py @@ -13,14 +13,14 @@ import os from textwrap import dedent from cloudinit import subp, temp_utils, util -from cloudinit.config.schema import get_meta_doc +from cloudinit.config.schema import MetaSchema, get_meta_doc from cloudinit.settings import PER_ALWAYS frequency = PER_ALWAYS distros = ["all"] -meta = { +meta: MetaSchema = { "id": "cc_bootcmd", "name": "Bootcmd", "title": "Run arbitrary commands early in the boot process", diff --git a/cloudinit/config/cc_byobu.py b/cloudinit/config/cc_byobu.py index b96736a4..fbc20410 100755 --- a/cloudinit/config/cc_byobu.py +++ b/cloudinit/config/cc_byobu.py @@ -9,7 +9,7 @@ """Byobu: Enable/disable byobu system wide and for default user.""" from cloudinit import subp, util -from cloudinit.config.schema import get_meta_doc +from cloudinit.config.schema import MetaSchema, get_meta_doc from cloudinit.distros import ug_util from cloudinit.settings import PER_INSTANCE @@ -32,7 +32,7 @@ Valid configuration options for this module are: """ distros = ["ubuntu", "debian"] -meta = { +meta: MetaSchema = { "id": "cc_byobu", "name": "Byobu", "title": "Enable/disable byobu system wide and for default user", diff --git a/cloudinit/config/cc_ca_certs.py b/cloudinit/config/cc_ca_certs.py index c46d0fbe..6084cb4c 100644 --- a/cloudinit/config/cc_ca_certs.py +++ b/cloudinit/config/cc_ca_certs.py @@ -8,7 +8,7 @@ import os from textwrap import dedent from cloudinit import subp, util -from cloudinit.config.schema import get_meta_doc +from cloudinit.config.schema import MetaSchema, get_meta_doc from cloudinit.settings import PER_INSTANCE DEFAULT_CONFIG = { @@ -45,7 +45,7 @@ can be removed from the system with the configuration option """ distros = ["alpine", "debian", "ubuntu", "rhel"] -meta = { +meta: MetaSchema = { "id": "cc_ca_certs", "name": "CA Certificates", "title": "Add ca certificates", diff --git a/cloudinit/config/cc_chef.py b/cloudinit/config/cc_chef.py index aaf7eaf1..fdb3a6e3 100644 --- a/cloudinit/config/cc_chef.py +++ b/cloudinit/config/cc_chef.py @@ -14,7 +14,7 @@ import os from textwrap import dedent from cloudinit import subp, temp_utils, templater, url_helper, util -from cloudinit.config.schema import get_meta_doc +from cloudinit.config.schema import MetaSchema, get_meta_doc from cloudinit.settings import PER_ALWAYS RUBY_VERSION_DEFAULT = "1.8" @@ -92,7 +92,7 @@ CHEF_EXEC_DEF_ARGS = tuple(["-d", "-i", "1800", "-s", "20"]) frequency = PER_ALWAYS distros = ["all"] -meta = { +meta: MetaSchema = { "id": "cc_chef", "name": "Chef", "title": "module that configures, starts and installs chef", diff --git a/cloudinit/config/cc_debug.py b/cloudinit/config/cc_debug.py index 1a3c9346..c51818c3 100644 --- a/cloudinit/config/cc_debug.py +++ b/cloudinit/config/cc_debug.py @@ -9,7 +9,7 @@ from io import StringIO from textwrap import dedent from cloudinit import safeyaml, type_utils, util -from cloudinit.config.schema import get_meta_doc +from cloudinit.config.schema import MetaSchema, get_meta_doc from cloudinit.distros import ALL_DISTROS from cloudinit.settings import PER_INSTANCE @@ -24,7 +24,7 @@ location that this cloud-init has been configured with when running. Log configurations are not output. """ -meta = { +meta: MetaSchema = { "id": "cc_debug", "name": "Debug", "title": "Helper to debug cloud-init *internal* datastructures", diff --git a/cloudinit/config/cc_disable_ec2_metadata.py b/cloudinit/config/cc_disable_ec2_metadata.py index 6a5e7eda..88cc28e2 100644 --- a/cloudinit/config/cc_disable_ec2_metadata.py +++ b/cloudinit/config/cc_disable_ec2_metadata.py @@ -11,14 +11,14 @@ from textwrap import dedent from cloudinit import subp, util -from cloudinit.config.schema import get_meta_doc +from cloudinit.config.schema import MetaSchema, get_meta_doc from cloudinit.distros import ALL_DISTROS from cloudinit.settings import PER_ALWAYS REJECT_CMD_IF = ["route", "add", "-host", "169.254.169.254", "reject"] REJECT_CMD_IP = ["ip", "route", "add", "prohibit", "169.254.169.254"] -meta = { +meta: MetaSchema = { "id": "cc_disable_ec2_metadata", "name": "Disable EC2 Metadata", "title": "Disable AWS EC2 Metadata", diff --git a/cloudinit/config/cc_disk_setup.py b/cloudinit/config/cc_disk_setup.py index c59d00cd..ee05ea87 100644 --- a/cloudinit/config/cc_disk_setup.py +++ b/cloudinit/config/cc_disk_setup.py @@ -13,7 +13,7 @@ import shlex from textwrap import dedent from cloudinit import subp, util -from cloudinit.config.schema import get_meta_doc +from cloudinit.config.schema import MetaSchema, get_meta_doc from cloudinit.distros import ALL_DISTROS from cloudinit.settings import PER_INSTANCE @@ -50,7 +50,7 @@ the ``fs_setup`` directive. This config directive accepts a list of filesystem configs. """ -meta = { +meta: MetaSchema = { "id": "cc_disk_setup", "name": "Disk Setup", "title": "Configure partitions and filesystems", diff --git a/cloudinit/config/cc_install_hotplug.py b/cloudinit/config/cc_install_hotplug.py index 952d9f13..34c4557e 100644 --- a/cloudinit/config/cc_install_hotplug.py +++ b/cloudinit/config/cc_install_hotplug.py @@ -4,7 +4,11 @@ import os from textwrap import dedent from cloudinit import stages, subp, util -from cloudinit.config.schema import get_meta_doc, validate_cloudconfig_schema +from cloudinit.config.schema import ( + MetaSchema, + get_meta_doc, + validate_cloudconfig_schema, +) from cloudinit.distros import ALL_DISTROS from cloudinit.event import EventScope, EventType from cloudinit.settings import PER_INSTANCE @@ -12,7 +16,7 @@ from cloudinit.settings import PER_INSTANCE frequency = PER_INSTANCE distros = [ALL_DISTROS] -meta = { +meta: MetaSchema = { "id": "cc_install_hotplug", "name": "Install Hotplug", "title": "Install hotplug if supported and enabled", diff --git a/cloudinit/config/cc_keyboard.py b/cloudinit/config/cc_keyboard.py index 17eb9a54..98ef326a 100644 --- a/cloudinit/config/cc_keyboard.py +++ b/cloudinit/config/cc_keyboard.py @@ -10,7 +10,11 @@ from textwrap import dedent from cloudinit import distros from cloudinit import log as logging -from cloudinit.config.schema import get_meta_doc, validate_cloudconfig_schema +from cloudinit.config.schema import ( + MetaSchema, + get_meta_doc, + validate_cloudconfig_schema, +) from cloudinit.settings import PER_INSTANCE frequency = PER_INSTANCE @@ -22,7 +26,7 @@ distros = distros.Distro.expand_osfamily(osfamilies) DEFAULT_KEYBOARD_MODEL = "pc105" -meta = { +meta: MetaSchema = { "id": "cc_keyboard", "name": "Keyboard", "title": "Set keyboard layout", diff --git a/cloudinit/config/cc_locale.py b/cloudinit/config/cc_locale.py index 487f58f7..29f6a9b6 100644 --- a/cloudinit/config/cc_locale.py +++ b/cloudinit/config/cc_locale.py @@ -11,12 +11,16 @@ from textwrap import dedent from cloudinit import util -from cloudinit.config.schema import get_meta_doc, validate_cloudconfig_schema +from cloudinit.config.schema import ( + MetaSchema, + get_meta_doc, + validate_cloudconfig_schema, +) from cloudinit.settings import PER_INSTANCE frequency = PER_INSTANCE distros = ["all"] -meta = { +meta: MetaSchema = { "id": "cc_locale", "name": "Locale", "title": "Set system locale", diff --git a/cloudinit/config/cc_ntp.py b/cloudinit/config/cc_ntp.py index a31da9bb..25bba764 100644 --- a/cloudinit/config/cc_ntp.py +++ b/cloudinit/config/cc_ntp.py @@ -12,7 +12,11 @@ from textwrap import dedent from cloudinit import log as logging from cloudinit import subp, temp_utils, templater, type_utils, util -from cloudinit.config.schema import get_meta_doc, validate_cloudconfig_schema +from cloudinit.config.schema import ( + MetaSchema, + get_meta_doc, + validate_cloudconfig_schema, +) from cloudinit.settings import PER_INSTANCE LOG = logging.getLogger(__name__) @@ -148,7 +152,7 @@ DISTRO_CLIENT_CONFIG = { # configuration options before actually attempting to deploy with said # configuration. -meta = { +meta: MetaSchema = { "id": "cc_ntp", "name": "NTP", "title": "enable and configure ntp", diff --git a/cloudinit/config/cc_resizefs.py b/cloudinit/config/cc_resizefs.py index b009c392..19b923a8 100644 --- a/cloudinit/config/cc_resizefs.py +++ b/cloudinit/config/cc_resizefs.py @@ -14,7 +14,11 @@ import stat from textwrap import dedent from cloudinit import subp, util -from cloudinit.config.schema import get_meta_doc, validate_cloudconfig_schema +from cloudinit.config.schema import ( + MetaSchema, + get_meta_doc, + validate_cloudconfig_schema, +) from cloudinit.settings import PER_ALWAYS NOBLOCK = "noblock" @@ -22,7 +26,7 @@ NOBLOCK = "noblock" frequency = PER_ALWAYS distros = ["all"] -meta = { +meta: MetaSchema = { "id": "cc_resizefs", "name": "Resizefs", "title": "Resize filesystem", diff --git a/cloudinit/config/cc_runcmd.py b/cloudinit/config/cc_runcmd.py index 15cbaf1a..ef37a823 100644 --- a/cloudinit/config/cc_runcmd.py +++ b/cloudinit/config/cc_runcmd.py @@ -12,7 +12,11 @@ import os from textwrap import dedent from cloudinit import util -from cloudinit.config.schema import get_meta_doc, validate_cloudconfig_schema +from cloudinit.config.schema import ( + MetaSchema, + get_meta_doc, + validate_cloudconfig_schema, +) from cloudinit.distros import ALL_DISTROS from cloudinit.settings import PER_INSTANCE @@ -24,7 +28,7 @@ from cloudinit.settings import PER_INSTANCE distros = [ALL_DISTROS] -meta = { +meta: MetaSchema = { "id": "cc_runcmd", "name": "Runcmd", "title": "Run arbitrary commands", diff --git a/cloudinit/config/cc_snap.py b/cloudinit/config/cc_snap.py index 9c38046c..9f343df0 100644 --- a/cloudinit/config/cc_snap.py +++ b/cloudinit/config/cc_snap.py @@ -9,7 +9,11 @@ from textwrap import dedent from cloudinit import log as logging from cloudinit import subp, util -from cloudinit.config.schema import get_meta_doc, validate_cloudconfig_schema +from cloudinit.config.schema import ( + MetaSchema, + get_meta_doc, + validate_cloudconfig_schema, +) from cloudinit.settings import PER_INSTANCE from cloudinit.subp import prepend_base_command @@ -18,7 +22,7 @@ frequency = PER_INSTANCE LOG = logging.getLogger(__name__) -meta = { +meta: MetaSchema = { "id": "cc_snap", "name": "Snap", "title": "Install, configure and manage snapd and snap packages", diff --git a/cloudinit/config/cc_ubuntu_advantage.py b/cloudinit/config/cc_ubuntu_advantage.py index 9239f7de..e469bb22 100644 --- a/cloudinit/config/cc_ubuntu_advantage.py +++ b/cloudinit/config/cc_ubuntu_advantage.py @@ -6,14 +6,18 @@ from textwrap import dedent from cloudinit import log as logging from cloudinit import subp, util -from cloudinit.config.schema import get_meta_doc, validate_cloudconfig_schema +from cloudinit.config.schema import ( + MetaSchema, + get_meta_doc, + validate_cloudconfig_schema, +) from cloudinit.settings import PER_INSTANCE UA_URL = "https://ubuntu.com/advantage" distros = ["ubuntu"] -meta = { +meta: MetaSchema = { "id": "cc_ubuntu_advantage", "name": "Ubuntu Advantage", "title": "Configure Ubuntu Advantage support services", diff --git a/cloudinit/config/cc_ubuntu_drivers.py b/cloudinit/config/cc_ubuntu_drivers.py index 6c8494c8..44a3bdb4 100644 --- a/cloudinit/config/cc_ubuntu_drivers.py +++ b/cloudinit/config/cc_ubuntu_drivers.py @@ -7,14 +7,18 @@ from textwrap import dedent from cloudinit import log as logging from cloudinit import subp, temp_utils, type_utils, util -from cloudinit.config.schema import get_meta_doc, validate_cloudconfig_schema +from cloudinit.config.schema import ( + MetaSchema, + get_meta_doc, + validate_cloudconfig_schema, +) from cloudinit.settings import PER_INSTANCE LOG = logging.getLogger(__name__) frequency = PER_INSTANCE distros = ["ubuntu"] -meta = { +meta: MetaSchema = { "id": "cc_ubuntu_drivers", "name": "Ubuntu Drivers", "title": "Interact with third party drivers in Ubuntu.", diff --git a/cloudinit/config/cc_write_files.py b/cloudinit/config/cc_write_files.py index 2c580328..37dae392 100644 --- a/cloudinit/config/cc_write_files.py +++ b/cloudinit/config/cc_write_files.py @@ -12,7 +12,11 @@ from textwrap import dedent from cloudinit import log as logging from cloudinit import util -from cloudinit.config.schema import get_meta_doc, validate_cloudconfig_schema +from cloudinit.config.schema import ( + MetaSchema, + get_meta_doc, + validate_cloudconfig_schema, +) from cloudinit.settings import PER_INSTANCE frequency = PER_INSTANCE @@ -43,7 +47,7 @@ supported_encoding_types = [ "base64", ] -meta = { +meta: MetaSchema = { "id": "cc_write_files", "name": "Write Files", "title": "write arbitrary files", diff --git a/cloudinit/config/cc_zypper_add_repo.py b/cloudinit/config/cc_zypper_add_repo.py index 41605b97..be444cce 100644 --- a/cloudinit/config/cc_zypper_add_repo.py +++ b/cloudinit/config/cc_zypper_add_repo.py @@ -12,12 +12,12 @@ import configobj from cloudinit import log as logging from cloudinit import util -from cloudinit.config.schema import get_meta_doc +from cloudinit.config.schema import MetaSchema, get_meta_doc from cloudinit.settings import PER_ALWAYS distros = ["opensuse", "sles"] -meta = { +meta: MetaSchema = { "id": "cc_zypper_add_repo", "name": "ZypperAddRepo", "title": "Configure zypper behavior and add zypper repositories", 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 |