Skip to content

Commit d928126

Browse files
committed
data.py: use dict not Dict
PEP585 implemented in python 3.9 allows to subscript `list` and `dict`, and doing so even with 3.8 is not flagged by checkers, so devs end up using it and get flagged by the CI. Since 3.7 `from __future__ import annotations` allows to defer evaluation of annotations, so any use of collection subscripting in an annotation gets not checked by the interpreter any more, and we can use the more comfortable syntax. Signed-off-by: Yann Dirson <[email protected]>
1 parent d09820f commit d928126

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

data.py-dist

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
# Configuration file, to be adapted to one's needs
22

3+
from __future__ import annotations
4+
35
import legacycrypt as crypt # type: ignore
46
import os
5-
from typing import Any, Dict, TYPE_CHECKING
7+
from typing import Any, TYPE_CHECKING
68

79
if TYPE_CHECKING:
810
from lib.typing import IsoImageDef
@@ -36,7 +38,7 @@ OBJECTS_NAME_PREFIX = None
3638
# skip_xo_config allows to not touch XO's configuration regarding the host
3739
# Else the default behaviour is to add the host to XO servers at the beginning
3840
# of the testing session and remove it at the end.
39-
HOSTS: Dict[str, Dict[str, Any]] = {
41+
HOSTS: dict[str, dict[str, Any]] = {
4042
# "10.0.0.1": {"user": "root", "password": ""},
4143
# "testhost1": {"user": "root", "password": "", 'skip_xo_config': True},
4244
}
@@ -106,7 +108,7 @@ OTHER_GUEST_TOOLS = {
106108
}
107109

108110
# Tools
109-
TOOLS: Dict[str, str] = {
111+
TOOLS: dict[str, str] = {
110112
# "iso-remaster": "/home/user/src/xcpng/xcp/scripts/iso-remaster/iso-remaster.sh",
111113
}
112114

@@ -126,7 +128,7 @@ ISO_IMAGES_CACHE = "/home/user/iso"
126128
# for local-only ISO with things like "locally-built/my.iso" or "xs/8.3.iso".
127129
# If 'net-only' is set to 'True' only source of type URL will be possible.
128130
# By default the parameter is set to False.
129-
ISO_IMAGES: Dict[str, "IsoImageDef"] = {
131+
ISO_IMAGES: dict[str, "IsoImageDef"] = {
130132
'83nightly': {'path': os.environ.get("XCPNG83_NIGHTLY",
131133
"http://unconfigured.iso"),
132134
'unsigned': True},
@@ -181,44 +183,44 @@ DEFAULT_SR = 'default'
181183
CACHE_IMPORTED_VM = False
182184

183185
# Default NFS device config:
184-
NFS_DEVICE_CONFIG: Dict[str, Dict[str, str]] = {
186+
NFS_DEVICE_CONFIG: dict[str, dict[str, str]] = {
185187
# 'server': '10.0.0.2', # URL/Hostname of NFS server
186188
# 'serverpath': '/path/to/shared/mount' # Path to shared mountpoint
187189
}
188190

189191
# Default NFS4+ only device config:
190-
NFS4_DEVICE_CONFIG: Dict[str, Dict[str, str]] = {
192+
NFS4_DEVICE_CONFIG: dict[str, dict[str, str]] = {
191193
# 'server': '10.0.0.2', # URL/Hostname of NFS server
192194
# 'serverpath': '/path_to_shared_mount' # Path to shared mountpoint
193195
# 'nfsversion': '4.1'
194196
}
195197

196198
# Default NFS ISO device config:
197-
NFS_ISO_DEVICE_CONFIG: Dict[str, Dict[str, str]] = {
199+
NFS_ISO_DEVICE_CONFIG: dict[str, dict[str, str]] = {
198200
# 'location': '10.0.0.2:/path/to/shared/mount' # URL/Hostname of NFS server and path to shared mountpoint
199201
}
200202

201203
# Default CIFS ISO device config:
202-
CIFS_ISO_DEVICE_CONFIG: Dict[str, Dict[str, str]] = {
204+
CIFS_ISO_DEVICE_CONFIG: dict[str, dict[str, str]] = {
203205
# 'location': r'\\10.0.0.2\<shared folder name>',
204206
# 'username': '<user>',
205207
# 'cifspassword': '<password>',
206208
# 'type': 'cifs',
207209
# 'vers': '<1.0> or <3.0>'
208210
}
209211

210-
CEPHFS_DEVICE_CONFIG: Dict[str, Dict[str, str]] = {
212+
CEPHFS_DEVICE_CONFIG: dict[str, dict[str, str]] = {
211213
# 'server': '10.0.0.2',
212214
# 'serverpath': '/vms'
213215
}
214216

215-
MOOSEFS_DEVICE_CONFIG: Dict[str, Dict[str, str]] = {
217+
MOOSEFS_DEVICE_CONFIG: dict[str, dict[str, str]] = {
216218
# 'masterhost': 'mfsmaster',
217219
# 'masterport': '9421',
218220
# 'rootpath': '/vms'
219221
}
220222

221-
LVMOISCSI_DEVICE_CONFIG: Dict[str, Dict[str, str]] = {
223+
LVMOISCSI_DEVICE_CONFIG: dict[str, dict[str, str]] = {
222224
# 'target': '192.168.1.1',
223225
# 'port': '3260',
224226
# 'targetIQN': 'target.example',
@@ -247,7 +249,7 @@ BASE_ANSWERFILES = dict(
247249
},
248250
)
249251

250-
IMAGE_EQUIVS: Dict[str, str] = {
252+
IMAGE_EQUIVS: dict[str, str] = {
251253
# 'install.test::Nested::install[bios-830-ext]-vm1-607cea0c825a4d578fa5fab56978627d8b2e28bb':
252254
# 'install.test::Nested::install[bios-830-ext]-vm1-addb4ead4da49856e1d2fb3ddf4e31027c6b693b',
253255
}

0 commit comments

Comments
 (0)