1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186
|
From: Alexandre Detiste <tchet@debian.org>
Date: Mon, 19 Jan 2026 20:38:33 +0000
Subject: Remove-Six
---
requirements.txt | 1 -
stone/backends/obj_c_types.py | 3 +-
stone/backends/python_rsrc/stone_serializers.py | 45 ++-----------------------
stone/backends/python_rsrc/stone_validators.py | 6 ----
stone/backends/swift_types.py | 3 +-
test/test_python_gen.py | 3 +-
6 files changed, 6 insertions(+), 55 deletions(-)
diff --git a/requirements.txt b/requirements.txt
index d2431b5..ad70922 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,4 +1,3 @@
ply>= 3.4
-six>= 1.12.0
packaging>=21.0
Jinja2>= 3.0.3
diff --git a/stone/backends/obj_c_types.py b/stone/backends/obj_c_types.py
index ae48514..b9999ec 100644
--- a/stone/backends/obj_c_types.py
+++ b/stone/backends/obj_c_types.py
@@ -2,7 +2,6 @@ import json
import os
import shutil
-import six
from stone.backends.obj_c import (
base_file_comment,
@@ -915,7 +914,7 @@ class ObjCTypesBackend(ObjCBaseBackend):
if data_type.min_length else 'nil'),
('maxLength', '@({})'.format(data_type.max_length)
if data_type.max_length else 'nil'),
- ('pattern', '@"{}"'.format(six.ensure_str(pattern))
+ ('pattern', '@"{}"'.format(pattern.decode())
if pattern else 'nil'),
]))
diff --git a/stone/backends/python_rsrc/stone_serializers.py b/stone/backends/python_rsrc/stone_serializers.py
index 7eac850..68dc54c 100644
--- a/stone/backends/python_rsrc/stone_serializers.py
+++ b/stone/backends/python_rsrc/stone_serializers.py
@@ -20,7 +20,6 @@ import json
import re
import time
-import six
from stone.backends.python_rsrc import (
stone_base as bb,
@@ -658,7 +657,7 @@ class PythonPrimitiveToStoneDecoder:
else:
raise bv.ValidationError("expected string or object, got %s" %
bv.generic_type_name(obj))
- return data_type.definition(six.ensure_str(tag), val)
+ return data_type.definition(tag, val)
def decode_union_dict(self, data_type, obj):
if '.tag' not in obj:
@@ -785,7 +784,7 @@ class PythonPrimitiveToStoneDecoder:
else:
raise bv.ValidationError("expected string or object, got %s" %
bv.generic_type_name(obj))
- return data_type.definition(six.ensure_str(tag), val)
+ return data_type.definition(tag, val)
def decode_struct_tree(self, data_type, obj):
"""
@@ -1003,45 +1002,7 @@ def _findall(text, substr):
# Every 28 years the calendar repeats, except through century leap years
# where it's 6 years. But only if you're using the Gregorian calendar. ;)
def _strftime(dt, fmt):
- try:
- return dt.strftime(fmt)
- except ValueError:
- if not six.PY2 or dt.year > 1900:
- raise
-
- if _ILLEGAL_S.search(fmt):
- raise TypeError("This strftime implementation does not handle %s")
-
- year = dt.year
-
- # For every non-leap year century, advance by 6 years to get into the
- # 28-year repeat cycle
- delta = 2000 - year
- off = 6 * (delta // 100 + delta // 400)
- year = year + off
-
- # Move to around the year 2000
- year = year + ((2000 - year) // 28) * 28
- timetuple = dt.timetuple()
- s1 = time.strftime(fmt, (year,) + timetuple[1:])
- sites1 = _findall(s1, str(year))
-
- s2 = time.strftime(fmt, (year + 28,) + timetuple[1:])
- sites2 = _findall(s2, str(year + 28))
-
- sites = []
-
- for site in sites1:
- if site in sites2:
- sites.append(site)
-
- s = s1
- syear = '%4d' % (dt.year,)
-
- for site in sites:
- s = s[:site] + syear + s[site + 4:]
-
- return s
+ return dt.strftime(fmt)
try:
diff --git a/stone/backends/python_rsrc/stone_validators.py b/stone/backends/python_rsrc/stone_validators.py
index dc553ee..e74eddb 100644
--- a/stone/backends/python_rsrc/stone_validators.py
+++ b/stone/backends/python_rsrc/stone_validators.py
@@ -14,7 +14,6 @@ import numbers
import re
from abc import ABCMeta, abstractmethod
-import six
_MYPY = False
if _MYPY:
@@ -334,11 +333,6 @@ class String(Primitive):
if not isinstance(val, str):
raise ValidationError("'%s' expected to be a string, got %s"
% (get_value_string(val), generic_type_name(val)))
- if not six.PY3 and isinstance(val, str):
- try:
- val = val.decode('utf-8')
- except UnicodeDecodeError:
- raise ValidationError("'%s' was not valid utf-8")
if self.max_length is not None and len(val) > self.max_length:
raise ValidationError("'%s' must be at most %d characters, got %d"
diff --git a/stone/backends/swift_types.py b/stone/backends/swift_types.py
index f07851c..33b9d9c 100644
--- a/stone/backends/swift_types.py
+++ b/stone/backends/swift_types.py
@@ -2,7 +2,6 @@ import json
import os
import shutil
-import six
import jinja2
import textwrap
@@ -304,7 +303,7 @@ class SwiftTypesBackend(SwiftBaseBackend):
self._func_args([
("minLength", data_type.min_length),
("maxLength", data_type.max_length),
- ("pattern", '"{}"'.format(six.ensure_str(pat)) if pat else None),
+ ("pattern", '"{}"'.format(pat.decode()) if pat else None),
])
)
else:
diff --git a/test/test_python_gen.py b/test/test_python_gen.py
index 1e8dfa3..8683ca0 100755
--- a/test/test_python_gen.py
+++ b/test/test_python_gen.py
@@ -10,7 +10,6 @@ import subprocess
import sys
import unittest
-import six
import stone.backends.python_rsrc.stone_base as bb
import stone.backends.python_rsrc.stone_serializers as ss
@@ -655,7 +654,7 @@ class TestDropInModules(unittest.TestCase):
pass
assert bv.type_name_with_module(Foo) == "test.test_python_gen.Foo"
- assert bv.type_name_with_module(int) == "builtins.int" if six.PY3 else "__builtin__.int"
+ assert bv.type_name_with_module(int) == "builtins.int"
test_spec = """\
|