From: Alexandre Detiste <alexandre.detiste@gmail.com>
Date: Mon, 11 Aug 2025 13:54:10 +0200
Subject: drop dependency on "six"

(cherry picked from commit 3b14bbd02c24cf9d5bc2ecba41151de8c3424bf8)

Forwarded: https://github.com/cheshirekow/cmake_format/pull/353
---
 cmakelang/BUILD                     |   9 ---
 cmakelang/command_tests/BUILD       | 122 ------------------------------------
 cmakelang/command_tests/__init__.py |   4 +-
 cmakelang/config_util.py            |   4 +-
 cmakelang/contrib/BUILD             |  26 ++------
 cmakelang/format/BUILD              |  26 --------
 cmakelang/lex/BUILD                 |   8 ---
 cmakelang/lint/test/BUILD           |  13 ----
 cmakelang/parse/BUILD               |  12 ----
 cmakelang/pypi/setup.py             |   1 -
 cmakelang/test/BUILD                |  19 ------
 11 files changed, 6 insertions(+), 238 deletions(-)

diff --git a/cmakelang/BUILD b/cmakelang/BUILD
index 2d2ec59..6dfd8d8 100644
--- a/cmakelang/BUILD
+++ b/cmakelang/BUILD
@@ -35,15 +35,6 @@ py_library(
   ],
 )
 
-# -- Python 2 --
-
-py_test(
-  name = "markup_tests",
-  srcs = ["markup_tests.py"],
-  python_version = "PY2",
-  deps = [":cmakelang"],
-)
-
 # -- Python 3 --
 
 py_test(
diff --git a/cmakelang/command_tests/BUILD b/cmakelang/command_tests/BUILD
index beb5890..39bd912 100644
--- a/cmakelang/command_tests/BUILD
+++ b/cmakelang/command_tests/BUILD
@@ -24,128 +24,6 @@ py_library(
   ],
 )
 
-# -- Python 2 --
-
-py_test(
-  name = "add_custom_command_tests",
-  srcs = ["__main__.py"],
-  args = ["TestAddCustomCommand"],
-  main = "__main__.py",
-  python_version = "PY2",
-  deps = [
-    ":command_tests",
-    "//cmakelang",
-  ],
-)
-
-py_test(
-  name = "add_executable_tests",
-  srcs = ["__main__.py"],
-  args = ["TestAddExecutableCommand"],
-  main = "__main__.py",
-  python_version = "PY2",
-  deps = [
-    ":command_tests",
-    "//cmakelang",
-  ],
-)
-
-py_test(
-  name = "add_library_tests",
-  srcs = ["__main__.py"],
-  args = ["TestAddLibraryCommand"],
-  main = "__main__.py",
-  python_version = "PY2",
-  deps = [
-    ":command_tests",
-    "//cmakelang",
-  ],
-)
-
-py_test(
-  name = "conditional_tests",
-  srcs = ["__main__.py"],
-  args = ["TestConditional"],
-  main = "__main__.py",
-  python_version = "PY2",
-  deps = [
-    ":command_tests",
-    "//cmakelang",
-  ],
-)
-
-py_test(
-  name = "export_tests",
-  srcs = ["__main__.py"],
-  args = ["TestExport"],
-  main = "__main__.py",
-  python_version = "PY2",
-  deps = [
-    ":command_tests",
-    "//cmakelang",
-  ],
-)
-
-py_test(
-  name = "file_tests",
-  srcs = ["__main__.py"],
-  args = ["TestFile"],
-  main = "__main__.py",
-  python_version = "PY2",
-  deps = [
-    ":command_tests",
-    "//cmakelang",
-  ],
-)
-
-py_test(
-  name = "install_tests",
-  srcs = ["__main__.py"],
-  args = ["TestInstall"],
-  main = "__main__.py",
-  python_version = "PY2",
-  deps = [
-    ":command_tests",
-    "//cmakelang",
-  ],
-)
-
-py_test(
-  name = "misc_tests",
-  srcs = ["__main__.py"],
-  args = ["TestMiscFormatting"],
-  main = "__main__.py",
-  python_version = "PY2",
-  deps = [
-    ":command_tests",
-    "//cmakelang",
-    "//cmakelang/format:testdata",
-  ],
-)
-
-py_test(
-  name = "set_target_properties",
-  srcs = ["__main__.py"],
-  args = ["TestSetTargetProperties"],
-  main = "__main__.py",
-  python_version = "PY2",
-  deps = [
-    ":command_tests",
-    "//cmakelang",
-  ],
-)
-
-py_test(
-  name = "set_tests",
-  srcs = ["__main__.py"],
-  args = ["TestSet"],
-  main = "__main__.py",
-  python_version = "PY2",
-  deps = [
-    ":command_tests",
-    "//cmakelang",
-  ],
-)
 
 # -- Python 3 --
 
diff --git a/cmakelang/command_tests/__init__.py b/cmakelang/command_tests/__init__.py
index 4608b0a..ee785c5 100644
--- a/cmakelang/command_tests/__init__.py
+++ b/cmakelang/command_tests/__init__.py
@@ -12,8 +12,6 @@ import re
 import sys
 import unittest
 
-import six
-
 from cmakelang.format import __main__
 from cmakelang import configuration
 from cmakelang.format import formatter
@@ -339,7 +337,7 @@ def make_test_fun(test_name, test_body, test_meta, input_str):
   return test_fun
 
 
-class TestBase(six.with_metaclass(SidecarMeta, unittest.TestCase)):
+class TestBase(unittest.TestCase, metaclass=SidecarMeta):
   """
   Given a bunch of example usages of a particular command, ensure that they
   lex, parse, layout, and format the same as expected.
diff --git a/cmakelang/config_util.py b/cmakelang/config_util.py
index 8b8b419..4e78a1b 100644
--- a/cmakelang/config_util.py
+++ b/cmakelang/config_util.py
@@ -8,8 +8,6 @@ import pprint
 import sys
 import textwrap
 
-import six
-
 logger = logging.getLogger(__name__)
 
 
@@ -309,7 +307,7 @@ def warn_unused(kwargs):
         "\n  ".join(unused))
 
 
-class ConfigObject(six.with_metaclass(ConfigMeta)):
+class ConfigObject(metaclass=ConfigMeta):
   """
   Base class for encapsulationg options/parameters
   """
diff --git a/cmakelang/contrib/BUILD b/cmakelang/contrib/BUILD
index 0c5f523..bfa4e7f 100644
--- a/cmakelang/contrib/BUILD
+++ b/cmakelang/contrib/BUILD
@@ -11,28 +11,6 @@ py_library(
   ],
 )
 
-# -- Python 2 --
-
-py_test(
-  name = "validate_pullrequest",
-  srcs = ["validate_pullrequest.py"],
-  python_version = "PY2",
-  deps = [
-    ":contrib_tests",
-    "//cmakelang",
-  ],
-)
-
-py_test(
-  name = "validate_database",
-  srcs = ["validate_database.py"],
-  python_version = "PY2",
-  deps = [
-    ":contrib_tests",
-    "//cmakelang",
-  ],
-)
-
 # -- Python 3 --
 
 py_test(
@@ -55,5 +33,9 @@ py_test(
   deps = [
     ":contrib_tests",
     "//cmakelang",
+    requirement("cffi"),
+    requirement("cryptography"),
+    requirement("pgpy"),
+    requirement("pyasn1"),
   ],
 )
diff --git a/cmakelang/format/BUILD b/cmakelang/format/BUILD
index b76c242..2779a09 100644
--- a/cmakelang/format/BUILD
+++ b/cmakelang/format/BUILD
@@ -17,32 +17,6 @@ py_library(
   data = glob(["testdata/*"]),
 )
 
-# -- Python 2 --
-
-py_binary(
-  name = "cmake-format",
-  srcs = ["__main__.py"],
-  main = "__main__.py",
-  deps = [":format"],
-)
-
-py_test(
-  name = "invocation_tests",
-  srcs = ["invocation_tests.py"],
-  python_version = "PY2",
-  deps = [
-    ":testdata",
-    "//cmakelang",
-  ],
-)
-
-py_test(
-  name = "layout_tests",
-  srcs = ["layout_tests.py"],
-  python_version = "PY2",
-  deps = ["//cmakelang"],
-)
-
 # -- Python 3 --
 
 py_test(
diff --git a/cmakelang/lex/BUILD b/cmakelang/lex/BUILD
index 871479d..92815d5 100644
--- a/cmakelang/lex/BUILD
+++ b/cmakelang/lex/BUILD
@@ -9,14 +9,6 @@ py_library(
   deps = ["//cmakelang:common"],
 )
 
-# -- Python 2 --
-py_test(
-  name = "tests",
-  srcs = ["tests.py"],
-  python_version = "PY2",
-  deps = ["//cmakelang"],
-)
-
 # -- Python 3 --
 
 py_test(
diff --git a/cmakelang/lint/test/BUILD b/cmakelang/lint/test/BUILD
index e109cb2..f9431a6 100644
--- a/cmakelang/lint/test/BUILD
+++ b/cmakelang/lint/test/BUILD
@@ -16,19 +16,6 @@ py_library(
   data = glob(["*.cmake"]),
 )
 
-# -- Python 2 --
-
-py_test(
-  name = "lint_test",
-  srcs = ["__main__.py"],
-  main = "__main__.py",
-  python_version = "PY2",
-  deps = [
-    ":test",
-    "//cmakelang/lint",
-  ],
-)
-
 # -- Python 3 --
 
 py_test(
diff --git a/cmakelang/parse/BUILD b/cmakelang/parse/BUILD
index a65ce07..43acba1 100644
--- a/cmakelang/parse/BUILD
+++ b/cmakelang/parse/BUILD
@@ -34,18 +34,6 @@ py_library(
     "util.py",
     "variables.py",
   ],
-  deps = [
-    "//cmakelang:common",
-  ],
-)
-
-# -- Python 2 --
-
-py_test(
-  name = "tests",
-  srcs = ["tests.py"],
-  python_version = "PY2",
-  deps = ["//cmakelang"],
 )
 
 # -- Python 3 --
diff --git a/cmakelang/pypi/setup.py b/cmakelang/pypi/setup.py
index d6f1ff2..6d2567d 100644
--- a/cmakelang/pypi/setup.py
+++ b/cmakelang/pypi/setup.py
@@ -61,7 +61,6 @@ setup(
         "YAML": ["pyyaml>=5.3"],
         "html-gen": ["jinja2==2.10.3"]
     },
-    install_requires=["six>=1.13.0"]
 )
 
 setup(
diff --git a/cmakelang/test/BUILD b/cmakelang/test/BUILD
index fa27096..cef75fb 100644
--- a/cmakelang/test/BUILD
+++ b/cmakelang/test/BUILD
@@ -10,25 +10,6 @@ py_library(
   ],
 )
 
-# -- Python 2 --
-
-py_test(
-  name = "version_number_test",
-  srcs = ["version_number_test.py"],
-  python_version = "PY2",
-  deps = [":test"],
-)
-
-py_test(
-  name = "command_db_test",
-  srcs = ["command_db_test.py"],
-  python_version = "PY2",
-  deps = [
-    ":test",
-    "//cmakelang",
-  ],
-)
-
 # -- Python 3 --
 
 py_test(
