From 06c4261af7368fdf57e3b3dfdce2cfef6b659f29 Mon Sep 17 00:00:00 2001 From: Josip Sokcevic Date: Fri, 17 Nov 2023 01:27:42 +0000 Subject: [PATCH] tests: Use collections.abc.MutableSet collections.MutableSet is deprecated and removed in py3.11 R=jojwang@google.com Change-Id: Id09f6f4f64fd59ef66659e7369562f59b8aaa232 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5039630 Auto-Submit: Josip Sokcevic Commit-Queue: Joanna Wang Reviewed-by: Joanna Wang --- testing_support/git_test_utils.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/testing_support/git_test_utils.py b/testing_support/git_test_utils.py index a6aa4426d..6586f1ab8 100644 --- a/testing_support/git_test_utils.py +++ b/testing_support/git_test_utils.py @@ -29,7 +29,7 @@ def git_hash_data(data, typ='blob'): return hashlib.sha1(b'blob %d\0%s' % (len(data), data)).hexdigest() -class OrderedSet(collections.MutableSet): +class OrderedSet(collections.abc.MutableSet): # from http://code.activestate.com/recipes/576694/ def __init__(self, iterable=None): self.end = end = [] @@ -73,20 +73,20 @@ class OrderedSet(collections.MutableSet): yield curr[0] curr = curr[1] - def add(self, key): - if key not in self.data: + def add(self, value): + if value not in self.data: end = self.end curr = end[1] - curr[2] = end[1] = self.data[key] = [key, curr, end] + curr[2] = end[1] = self.data[value] = [value, curr, end] def difference_update(self, *others): for other in others: for i in other: self.discard(i) - def discard(self, key): - if key in self.data: - key, prev, nxt = self.data.pop(key) + def discard(self, value): + if value in self.data: + value, prev, nxt = self.data.pop(value) prev[2] = nxt nxt[1] = prev