From fd32d59e67ba97b6d47eeff9d76267bc1a20a03e Mon Sep 17 00:00:00 2001 From: Takashi Kajinami Date: Mon, 5 Jan 2026 23:58:20 +0900 Subject: [PATCH] Remove checks for Python 2/3 compatibility Python 2 support was removed long ago. Change-Id: I3f601a20791f5679baac96e9ef463d5602b1af7f Signed-off-by: Takashi Kajinami --- HACKING.rst | 3 --- heat/hacking/checks.py | 26 -------------------------- heat/tests/test_hacking.py | 33 +++++---------------------------- tox.ini | 3 --- 4 files changed, 5 insertions(+), 60 deletions(-) diff --git a/HACKING.rst b/HACKING.rst index fdda44eb2f..5fa616236d 100644 --- a/HACKING.rst +++ b/HACKING.rst @@ -9,9 +9,6 @@ Heat Specific Commandments -------------------------- - [HE301] Use LOG.warning() rather than LOG.warn(). -- [HE302] Python 3: do not use dict.iteritems. -- [HE303] Python 3: do not use dict.iterkeys. -- [HE304] Python 3: do not use dict.itervalues. Creating unit tests ------------------- diff --git a/heat/hacking/checks.py b/heat/hacking/checks.py index dcce567d73..2fab8ebd71 100644 --- a/heat/hacking/checks.py +++ b/heat/hacking/checks.py @@ -13,8 +13,6 @@ # License for the specific language governing permissions and limitations # under the License. -import re - from hacking import core @@ -43,27 +41,3 @@ def no_log_warn(logical_line): """ if logical_line.startswith('LOG.warn('): yield (0, 'HE301 Use LOG.warning() rather than LOG.warn()') - - -@core.flake8ext -def check_python3_no_iteritems(logical_line): - msg = ("HE302: Use dict.items() instead of dict.iteritems().") - - if re.search(r".*\.iteritems\(\)", logical_line): - yield (0, msg) - - -@core.flake8ext -def check_python3_no_iterkeys(logical_line): - msg = ("HE303: Use dict.keys() instead of dict.iterkeys().") - - if re.search(r".*\.iterkeys\(\)", logical_line): - yield (0, msg) - - -@core.flake8ext -def check_python3_no_itervalues(logical_line): - msg = ("HE304: Use dict.values() instead of dict.itervalues().") - - if re.search(r".*\.itervalues\(\)", logical_line): - yield (0, msg) diff --git a/heat/tests/test_hacking.py b/heat/tests/test_hacking.py index 5863b57990..4ab1d981a9 100644 --- a/heat/tests/test_hacking.py +++ b/heat/tests/test_hacking.py @@ -17,32 +17,9 @@ from heat.tests import common class HackingTestCase(common.HeatTestCase): - def test_dict_iteritems(self): - self.assertEqual(1, len(list(checks.check_python3_no_iteritems( - "obj.iteritems()")))) + def test_log_warn(self): + self.assertEqual(1, len(list(checks.no_log_warn( + "LOG.warn('bad')")))) - self.assertEqual(0, len(list(checks.check_python3_no_iteritems( - "obj.items()")))) - - self.assertEqual(0, len(list(checks.check_python3_no_iteritems( - "obj.items()")))) - - def test_dict_iterkeys(self): - self.assertEqual(1, len(list(checks.check_python3_no_iterkeys( - "obj.iterkeys()")))) - - self.assertEqual(0, len(list(checks.check_python3_no_iterkeys( - "obj.keys()")))) - - self.assertEqual(0, len(list(checks.check_python3_no_iterkeys( - "obj.keys()")))) - - def test_dict_itervalues(self): - self.assertEqual(1, len(list(checks.check_python3_no_itervalues( - "obj.itervalues()")))) - - self.assertEqual(0, len(list(checks.check_python3_no_itervalues( - "obj.values()")))) - - self.assertEqual(0, len(list(checks.check_python3_no_itervalues( - "obj.values()")))) + self.assertEqual(0, len(list(checks.no_log_warn( + "LOG.warning('bad')")))) diff --git a/tox.ini b/tox.ini index 1fee482a91..7faea812c8 100644 --- a/tox.ini +++ b/tox.ini @@ -99,9 +99,6 @@ import_exceptions = heat.common.i18n [flake8:local-plugins] extension = HE301 = checks:no_log_warn - HE302 = checks:check_python3_no_iteritems - HE303 = checks:check_python3_no_iterkeys - HE304 = checks:check_python3_no_itervalues paths = ./heat/hacking [testenv:debug]