summaryrefslogtreecommitdiff
path: root/cloudinit/templater.py
diff options
context:
space:
mode:
authorAlberto Contreras <alberto.contreras@canonical.com>2023-03-14 10:36:36 +0100
committerGitHub <noreply@github.com>2023-03-14 10:36:36 +0100
commit8a0feb1ec04b211f9444e0eeaf473b670db475bd (patch)
treefd7d1a596b5dcd8a9a5b9077004459735218a263 /cloudinit/templater.py
parent2e697bb0e7f251385e9c227629b78d59e4cfea8b (diff)
downloadcloud-init-git-8a0feb1ec04b211f9444e0eeaf473b670db475bd.tar.gz
chore: fix style tip (#2071)
- remove too broad exceptions - ignore dynamic base types in templater
Diffstat (limited to 'cloudinit/templater.py')
-rw-r--r--cloudinit/templater.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/cloudinit/templater.py b/cloudinit/templater.py
index 8f98bb5d..ed6b9063 100644
--- a/cloudinit/templater.py
+++ b/cloudinit/templater.py
@@ -15,14 +15,17 @@
import collections
import re
import sys
-from typing import Type
+from typing import Any
from cloudinit import log as logging
from cloudinit import type_utils as tu
from cloudinit import util
from cloudinit.atomic_helper import write_file
-JUndefined: Type
+# After bionic EOL, mypy==1.0.0 will be able to type-analyse dynamic
+# base types, substitute this by:
+# JUndefined: typing.Type
+JUndefined: Any
try:
from jinja2 import DebugUndefined as _DebugUndefined
from jinja2 import Template as JTemplate
@@ -41,7 +44,7 @@ MISSING_JINJA_PREFIX = "CI_MISSING_JINJA_VAR/"
# Mypy, and the PEP 484 ecosystem in general, does not support creating
# classes with dynamic base types: https://stackoverflow.com/a/59636248
-class UndefinedJinjaVariable(JUndefined): # type: ignore
+class UndefinedJinjaVariable(JUndefined):
"""Class used to represent any undefined jinja template variable."""
def __str__(self):