Skip to content

Commit f396e22

Browse files
author
Yalin Li
authored
[ACR] Fix pytest collect issue (Azure#28085)
1 parent ecbb639 commit f396e22

File tree

10 files changed

+74
-84
lines changed

10 files changed

+74
-84
lines changed

sdk/containerregistry/azure-containerregistry/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ with ContainerRegistryClient(endpoint, DefaultAzureCredential(), audience="https
128128
for manifest in client.list_manifest_properties(repository, order_by=ArtifactManifestOrder.LAST_UPDATED_ON_DESCENDING):
129129
manifest_count += 1
130130
if manifest_count > 3:
131-
print("Deleting {}:{}".format(repository, manifest.digest))
131+
print(f"Deleting {repository}:{manifest.digest}")
132132
client.delete_manifest(repository, manifest.digest)
133133
```
134134

sdk/containerregistry/azure-containerregistry/azure/containerregistry/_container_registry_client.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,7 @@ def __init__(
7979
if api_version and api_version not in SUPPORTED_API_VERSIONS:
8080
supported_versions = "\n".join(SUPPORTED_API_VERSIONS)
8181
raise ValueError(
82-
"Unsupported API version '{}'. Please select from:\n{}".format(
83-
api_version, supported_versions
84-
)
82+
f"Unsupported API version '{api_version}'. Please select from:\n{supported_versions}"
8583
)
8684
audience = kwargs.pop("audience", None)
8785
if not audience:

sdk/containerregistry/azure-containerregistry/azure/containerregistry/_models.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -136,12 +136,7 @@ def tags(self):
136136
@property
137137
def fully_qualified_reference(self):
138138
# type: () -> str
139-
return "{}/{}{}{}".format(
140-
_host_only(self._registry),
141-
self._repository_name,
142-
":" if _is_tag(self._digest) else "@",
143-
_strip_alg(self._digest)
144-
)
139+
return f"{_host_only(self._registry)}/{self._repository_name}{':' if _is_tag(self._digest) else '@'}{_strip_alg(self._digest)}" # pylint: disable=line-too-long
145140

146141
def _to_generated(self):
147142
# type: () -> ManifestWriteableProperties

sdk/containerregistry/azure-containerregistry/azure/containerregistry/_user_agent.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66

77
from ._version import VERSION
88

9-
USER_AGENT = "azure-containerregistry/{}".format(VERSION)
9+
USER_AGENT = f"azure-containerregistry/{VERSION}"

sdk/containerregistry/azure-containerregistry/samples/sample_delete_images.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def delete_images(self):
4444
repository, order_by=ArtifactManifestOrder.LAST_UPDATED_ON_DESCENDING):
4545
manifest_count += 1
4646
if manifest_count > 3:
47-
print("Deleting {}:{}".format(repository, manifest.digest))
47+
print(f"Deleting {repository}:{manifest.digest}")
4848
client.delete_manifest(repository, manifest.digest)
4949

5050

sdk/containerregistry/azure-containerregistry/samples/sample_delete_tags.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def delete_tags(self):
4545
for tag in client.list_tag_properties(repository, order_by=ArtifactTagOrder.LAST_UPDATED_ON_DESCENDING):
4646
tag_count += 1
4747
if tag_count > 3:
48-
print("Deleting {}:{}".format(repository, tag.name))
48+
print(f"Deleting {repository}:{tag.name}")
4949
client.delete_tag(repository, tag.name)
5050

5151

sdk/containerregistry/azure-containerregistry/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
name=PACKAGE_NAME,
2626
version=version,
2727
include_package_data=True,
28-
description="Microsoft Azure {} Client Library for Python".format(PACKAGE_PPRINT_NAME),
28+
description=f"Microsoft Azure {PACKAGE_PPRINT_NAME} Client Library for Python",
2929
# ensure that these are updated to reflect the package owners' information
3030
long_description=long_description,
3131
long_description_content_type="text/markdown",

sdk/containerregistry/azure-containerregistry/tests/test_container_registry_client.py

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,9 @@ def test_get_repository_properties(self, containerregistry_endpoint):
9696
def test_update_repository_properties(self, containerregistry_endpoint):
9797
repository = self.get_resource_name("repo")
9898
tag_identifier = self.get_resource_name("tag")
99-
self.import_image(containerregistry_endpoint, HELLO_WORLD, ["{}:{}".format(repository, tag_identifier)])
99+
self.import_image(containerregistry_endpoint, HELLO_WORLD, [f"{repository}:{tag_identifier}"])
100100
with self.create_registry_client(containerregistry_endpoint) as client:
101101
properties = client.get_repository_properties(repository)
102-
103102
properties.can_delete = False
104103
properties.can_read = False
105104
properties.can_list = False
@@ -128,7 +127,7 @@ def test_update_repository_properties(self, containerregistry_endpoint):
128127
def test_update_repository_properties_kwargs(self, containerregistry_endpoint):
129128
repo = self.get_resource_name("repo")
130129
tag = self.get_resource_name("tag")
131-
self.import_image(containerregistry_endpoint, HELLO_WORLD, ["{}:{}".format(repo, tag)])
130+
self.import_image(containerregistry_endpoint, HELLO_WORLD, [f"{repo}:{tag}"])
132131

133132
with self.create_registry_client(containerregistry_endpoint) as client:
134133
properties = client.get_repository_properties(repo)
@@ -255,7 +254,7 @@ def test_list_registry_artifacts_ascending(self, containerregistry_endpoint):
255254
def test_get_manifest_properties(self, containerregistry_endpoint):
256255
repo = self.get_resource_name("repo")
257256
tag = self.get_resource_name("tag")
258-
self.import_image(containerregistry_endpoint, HELLO_WORLD, ["{}:{}".format(repo, tag)])
257+
self.import_image(containerregistry_endpoint, HELLO_WORLD, [f"{repo}:{tag}"])
259258

260259
with self.create_registry_client(containerregistry_endpoint) as client:
261260
properties = client.get_manifest_properties(repo, tag)
@@ -269,7 +268,7 @@ def test_get_manifest_properties(self, containerregistry_endpoint):
269268
def test_get_manifest_properties_does_not_exist(self, containerregistry_endpoint):
270269
repo = self.get_resource_name("repo")
271270
tag = self.get_resource_name("tag")
272-
self.import_image(containerregistry_endpoint, HELLO_WORLD, ["{}:{}".format(repo, tag)])
271+
self.import_image(containerregistry_endpoint, HELLO_WORLD, [f"{repo}:{tag}"])
273272

274273
with self.create_registry_client(containerregistry_endpoint) as client:
275274
manifest = client.get_manifest_properties(repo, tag)
@@ -286,7 +285,7 @@ def test_get_manifest_properties_does_not_exist(self, containerregistry_endpoint
286285
def test_update_manifest_properties(self, containerregistry_endpoint):
287286
repo = self.get_resource_name("repo")
288287
tag = self.get_resource_name("tag")
289-
self.import_image(containerregistry_endpoint, HELLO_WORLD, ["{}:{}".format(repo, tag)])
288+
self.import_image(containerregistry_endpoint, HELLO_WORLD, [f"{repo}:{tag}"])
290289

291290
with self.create_registry_client(containerregistry_endpoint) as client:
292291
properties = client.get_manifest_properties(repo, tag)
@@ -319,7 +318,7 @@ def test_update_manifest_properties(self, containerregistry_endpoint):
319318
def test_update_manifest_properties_kwargs(self, containerregistry_endpoint):
320319
repo = self.get_resource_name("repo")
321320
tag = self.get_resource_name("tag")
322-
self.import_image(containerregistry_endpoint, HELLO_WORLD, ["{}:{}".format(repo, tag)])
321+
self.import_image(containerregistry_endpoint, HELLO_WORLD, [f"{repo}:{tag}"])
323322

324323
with self.create_registry_client(containerregistry_endpoint) as client:
325324
properties = client.get_manifest_properties(repo, tag)
@@ -349,7 +348,7 @@ def test_update_manifest_properties_kwargs(self, containerregistry_endpoint):
349348
def test_get_tag_properties(self, containerregistry_endpoint):
350349
repo = self.get_resource_name("repo")
351350
tag = self.get_resource_name("tag")
352-
self.import_image(containerregistry_endpoint, HELLO_WORLD, ["{}:{}".format(repo, tag)])
351+
self.import_image(containerregistry_endpoint, HELLO_WORLD, [f"{repo}:{tag}"])
353352

354353
with self.create_registry_client(containerregistry_endpoint) as client:
355354
properties = client.get_tag_properties(repo, tag)
@@ -369,7 +368,7 @@ def test_get_tag_properties_does_not_exist(self, containerregistry_endpoint):
369368
def test_update_tag_properties(self, containerregistry_endpoint):
370369
repo = self.get_resource_name("repo")
371370
tag = self.get_resource_name("tag")
372-
self.import_image(containerregistry_endpoint, HELLO_WORLD, ["{}:{}".format(repo, tag)])
371+
self.import_image(containerregistry_endpoint, HELLO_WORLD, [f"{repo}:{tag}"])
373372

374373
with self.create_registry_client(containerregistry_endpoint) as client:
375374
properties = client.get_tag_properties(repo, tag)
@@ -401,7 +400,7 @@ def test_update_tag_properties(self, containerregistry_endpoint):
401400
def test_update_tag_properties_kwargs(self, containerregistry_endpoint):
402401
repo = self.get_resource_name("repo")
403402
tag = self.get_resource_name("tag")
404-
self.import_image(containerregistry_endpoint, HELLO_WORLD, ["{}:{}".format(repo, tag)])
403+
self.import_image(containerregistry_endpoint, HELLO_WORLD, [f"{repo}:{tag}"])
405404

406405
with self.create_registry_client(containerregistry_endpoint) as client:
407406
properties = client.get_tag_properties(repo, tag)
@@ -431,13 +430,13 @@ def test_update_tag_properties_kwargs(self, containerregistry_endpoint):
431430
def test_list_tag_properties(self, containerregistry_endpoint):
432431
repo = self.get_resource_name("repo")
433432
tag = self.get_resource_name("tag")
434-
tags = ["{}:{}".format(repo, tag + str(i)) for i in range(4)]
433+
tags = [f"{repo}:{tag + str(i)}" for i in range(4)]
435434
self.import_image(containerregistry_endpoint, HELLO_WORLD, tags)
436435

437436
with self.create_registry_client(containerregistry_endpoint) as client:
438437
count = 0
439438
for tag in client.list_tag_properties(repo):
440-
assert "{}:{}".format(repo, tag.name) in tags
439+
assert f"{repo}:{tag.name}" in tags
441440
count += 1
442441
assert count == 4
443442

@@ -446,14 +445,14 @@ def test_list_tag_properties(self, containerregistry_endpoint):
446445
def test_list_tag_properties_order_descending(self, containerregistry_endpoint):
447446
repo = self.get_resource_name("repo")
448447
tag = self.get_resource_name("tag")
449-
tags = ["{}:{}".format(repo, tag + str(i)) for i in range(4)]
448+
tags = [f"{repo}:{tag + str(i)}" for i in range(4)]
450449
self.import_image(containerregistry_endpoint, HELLO_WORLD, tags)
451450

452451
with self.create_registry_client(containerregistry_endpoint) as client:
453452
prev_last_updated_on = None
454453
count = 0
455454
for tag in client.list_tag_properties(repo, order_by=ArtifactTagOrder.LAST_UPDATED_ON_DESCENDING):
456-
assert "{}:{}".format(repo, tag.name) in tags
455+
assert f"{repo}:{tag.name}" in tags
457456
if prev_last_updated_on:
458457
assert tag.last_updated_on < prev_last_updated_on
459458
prev_last_updated_on = tag.last_updated_on
@@ -463,7 +462,7 @@ def test_list_tag_properties_order_descending(self, containerregistry_endpoint):
463462
prev_last_updated_on = None
464463
count = 0
465464
for tag in client.list_tag_properties(repo, order_by="timedesc"):
466-
assert "{}:{}".format(repo, tag.name) in tags
465+
assert f"{repo}:{tag.name}" in tags
467466
if prev_last_updated_on:
468467
assert tag.last_updated_on < prev_last_updated_on
469468
prev_last_updated_on = tag.last_updated_on
@@ -475,14 +474,14 @@ def test_list_tag_properties_order_descending(self, containerregistry_endpoint):
475474
def test_list_tag_properties_order_ascending(self, containerregistry_endpoint):
476475
repo = self.get_resource_name("repo")
477476
tag = self.get_resource_name("tag")
478-
tags = ["{}:{}".format(repo, tag + str(i)) for i in range(4)]
477+
tags = [f"{repo}:{tag + str(i)}" for i in range(4)]
479478
self.import_image(containerregistry_endpoint, HELLO_WORLD, tags)
480479

481480
with self.create_registry_client(containerregistry_endpoint) as client:
482481
prev_last_updated_on = None
483482
count = 0
484483
for tag in client.list_tag_properties(repo, order_by=ArtifactTagOrder.LAST_UPDATED_ON_ASCENDING):
485-
assert "{}:{}".format(repo, tag.name) in tags
484+
assert f"{repo}:{tag.name}" in tags
486485
if prev_last_updated_on:
487486
assert tag.last_updated_on > prev_last_updated_on
488487
prev_last_updated_on = tag.last_updated_on
@@ -492,7 +491,7 @@ def test_list_tag_properties_order_ascending(self, containerregistry_endpoint):
492491
prev_last_updated_on = None
493492
count = 0
494493
for tag in client.list_tag_properties(repo, order_by="timeasc"):
495-
assert "{}:{}".format(repo, tag.name) in tags
494+
assert f"{repo}:{tag.name}" in tags
496495
if prev_last_updated_on:
497496
assert tag.last_updated_on > prev_last_updated_on
498497
prev_last_updated_on = tag.last_updated_on
@@ -504,15 +503,15 @@ def test_list_tag_properties_order_ascending(self, containerregistry_endpoint):
504503
def test_delete_tag(self, containerregistry_endpoint):
505504
repo = self.get_resource_name("repo")
506505
tag = self.get_resource_name("tag")
507-
tags = ["{}:{}".format(repo, tag + str(i)) for i in range(4)]
506+
tags = [f"{repo}:{tag + str(i)}" for i in range(4)]
508507
self.import_image(containerregistry_endpoint, HELLO_WORLD, tags)
509508

510509
with self.create_registry_client(containerregistry_endpoint) as client:
511510
client.delete_tag(repo, tag + str(0))
512511

513512
count = 0
514513
for tag in client.list_tag_properties(repo):
515-
assert "{}:{}".format(repo, tag.name) in tags[1:]
514+
assert f"{repo}:{tag.name}" in tags[1:]
516515
count += 1
517516
assert count == 3
518517

@@ -527,7 +526,7 @@ def test_delete_tag_does_not_exist(self, containerregistry_endpoint):
527526
def test_delete_manifest(self, containerregistry_endpoint):
528527
repo = self.get_resource_name("repo")
529528
tag = self.get_resource_name("tag")
530-
self.import_image(containerregistry_endpoint, HELLO_WORLD, ["{}:{}".format(repo, tag)])
529+
self.import_image(containerregistry_endpoint, HELLO_WORLD, [f"{repo}:{tag}"])
531530

532531
with self.create_registry_client(containerregistry_endpoint) as client:
533532
client.delete_manifest(repo, tag)
@@ -542,7 +541,7 @@ def test_delete_manifest(self, containerregistry_endpoint):
542541
def test_delete_manifest_does_not_exist(self, containerregistry_endpoint):
543542
repo = self.get_resource_name("repo")
544543
tag = self.get_resource_name("tag")
545-
self.import_image(containerregistry_endpoint, HELLO_WORLD, ["{}:{}".format(repo, tag)])
544+
self.import_image(containerregistry_endpoint, HELLO_WORLD, [f"{repo}:{tag}"])
546545

547546
with self.create_registry_client(containerregistry_endpoint) as client:
548547
manifest = client.get_manifest_properties(repo, tag)

0 commit comments

Comments
 (0)