mirror of
https://gitlab.alpinelinux.org/alpine/aports.git
synced 2026-02-14 12:21:47 +01:00
The patch was suggest in https://github.com/dateutil/dateutil/issues/1202#issuecomment-3664715426, and lifted from debian: https://sources.debian.org/src/python-dateutil/2.9.0-4/debian/patches/remove-six.patch Python2 is a thing from the past, and it's time to let it go, even if it's only explicit compatibility with it. This commit is part of #17822
516 lines
16 KiB
Diff
516 lines
16 KiB
Diff
Forwarded: no... waiting on a new release
|
|
|
|
--- a/setup.cfg
|
|
+++ b/setup.cfg
|
|
@@ -39,7 +39,6 @@
|
|
[options]
|
|
zip_safe = True
|
|
setup_requires = setuptools_scm
|
|
-install_requires = six >= 1.5
|
|
package_dir =
|
|
=src
|
|
python_requires = >=2.7, !=3.0.*, !=3.1.*, !=3.2.*
|
|
--- a/src/dateutil/relativedelta.py
|
|
+++ b/src/dateutil/relativedelta.py
|
|
@@ -5,7 +5,6 @@
|
|
import operator
|
|
from math import copysign
|
|
|
|
-from six import integer_types
|
|
from warnings import warn
|
|
|
|
from ._common import weekday
|
|
@@ -200,7 +199,7 @@
|
|
"This is not a well-defined condition and will raise " +
|
|
"errors in future versions.", DeprecationWarning)
|
|
|
|
- if isinstance(weekday, integer_types):
|
|
+ if isinstance(weekday, int):
|
|
self.weekday = weekdays[weekday]
|
|
else:
|
|
self.weekday = weekday
|
|
--- a/tests/property/test_tz_prop.py
|
|
+++ b/tests/property/test_tz_prop.py
|
|
@@ -1,7 +1,6 @@
|
|
from datetime import datetime, timedelta
|
|
|
|
import pytest
|
|
-import six
|
|
from hypothesis import assume, given
|
|
from hypothesis import strategies as st
|
|
|
|
@@ -25,10 +24,7 @@
|
|
return
|
|
|
|
dt_act = dt.astimezone(tz.gettz(gettz_arg))
|
|
- if six.PY2:
|
|
- dt_exp = dt.astimezone(tz.tzlocal())
|
|
- else:
|
|
- dt_exp = dt.astimezone()
|
|
+ dt_exp = dt.astimezone()
|
|
|
|
assert dt_act == dt_exp
|
|
assert dt_act.tzname() == dt_exp.tzname()
|
|
--- a/tests/test_imports.py
|
|
+++ b/tests/test_imports.py
|
|
@@ -1,22 +1,10 @@
|
|
import sys
|
|
import unittest
|
|
import pytest
|
|
-import six
|
|
|
|
MODULE_TYPE = type(sys)
|
|
|
|
|
|
-# Tests live in datetutil/test which cause a RuntimeWarning for Python2 builds.
|
|
-# But since we expect lazy imports tests to fail for Python < 3.7 we'll ignore those
|
|
-# warnings with this filter.
|
|
-
|
|
-if six.PY2:
|
|
- filter_import_warning = pytest.mark.filterwarnings("ignore::RuntimeWarning")
|
|
-else:
|
|
-
|
|
- def filter_import_warning(f):
|
|
- return f
|
|
-
|
|
|
|
@pytest.fixture(scope="function")
|
|
def clean_import():
|
|
@@ -46,7 +34,6 @@
|
|
sys.modules[mod_name] = mod
|
|
|
|
|
|
-@filter_import_warning
|
|
@pytest.mark.parametrize(
|
|
"module",
|
|
["easter", "parser", "relativedelta", "rrule", "tz", "utils", "zoneinfo"],
|
|
--- a/tests/test_isoparser.py
|
|
+++ b/tests/test_isoparser.py
|
|
@@ -9,7 +9,6 @@
|
|
from dateutil.parser import isoparser, isoparse
|
|
|
|
import pytest
|
|
-import six
|
|
|
|
|
|
def _generate_tzoffsets(limited):
|
|
@@ -297,7 +296,7 @@
|
|
|
|
|
|
# This only fails on Python 3
|
|
-@pytest.mark.xfail(not six.PY2, reason="Fails on Python 3 only")
|
|
+@pytest.mark.xfail(reason="Fails on Python 3 only")
|
|
def test_isoparser_byte_sep():
|
|
dt = datetime(2017, 12, 6, 12, 30, 45)
|
|
dt_str = dt.isoformat(sep=str('T'))
|
|
@@ -347,9 +346,7 @@
|
|
date(2016, 2, 1)
|
|
]
|
|
|
|
- if not six.PY2:
|
|
- # strftime does not support dates before 1900 in Python 2
|
|
- dates_no_day.append(date(1000, 11, 1))
|
|
+ dates_no_day.append(date(1000, 11, 1))
|
|
|
|
# Only one supported format for dates with no day
|
|
o = zip(dates_no_day, it.repeat('%Y-%m'))
|
|
@@ -371,7 +368,7 @@
|
|
@pytest.mark.parametrize('as_bytes', [True, False])
|
|
def test_parse_isodate(d, dt_fmt, as_bytes):
|
|
d_str = d.strftime(dt_fmt)
|
|
- if isinstance(d_str, six.text_type) and as_bytes:
|
|
+ if isinstance(d_str, str) and as_bytes:
|
|
d_str = d_str.encode('ascii')
|
|
elif isinstance(d_str, bytes) and not as_bytes:
|
|
d_str = d_str.decode('ascii')
|
|
@@ -400,10 +397,7 @@
|
|
isoparser().parse_isodate('2014-0423')
|
|
|
|
# ensure the error message does not contain b' prefixes
|
|
- if six.PY2:
|
|
- expected_error = "String contains unknown ISO components: u'2014-0423'"
|
|
- else:
|
|
- expected_error = "String contains unknown ISO components: '2014-0423'"
|
|
+ expected_error = "String contains unknown ISO components: '2014-0423'"
|
|
assert expected_error == str(excinfo.value)
|
|
|
|
|
|
@@ -458,7 +452,7 @@
|
|
@pytest.mark.parametrize('as_bytes', [True, False])
|
|
def test_isotime(time_val, time_fmt, as_bytes):
|
|
tstr = time_val.strftime(time_fmt)
|
|
- if isinstance(tstr, six.text_type) and as_bytes:
|
|
+ if isinstance(tstr, str) and as_bytes:
|
|
tstr = tstr.encode('ascii')
|
|
elif isinstance(tstr, bytes) and not as_bytes:
|
|
tstr = tstr.decode('ascii')
|
|
--- a/tests/test_parser.py
|
|
+++ b/tests/test_parser.py
|
|
@@ -14,7 +14,6 @@
|
|
|
|
from ._common import TZEnvContext
|
|
|
|
-from six import assertRaisesRegex, PY2
|
|
from io import StringIO
|
|
|
|
import pytest
|
|
@@ -462,13 +461,6 @@
|
|
datetime(2003, 9, 25, 10, 36, 28,
|
|
tzinfo=self.brsttz))
|
|
|
|
- def testDateCommandFormatWithLong(self):
|
|
- if PY2:
|
|
- self.assertEqual(parse("Thu Sep 25 10:36:28 BRST 2003",
|
|
- tzinfos={"BRST": long(-10800)}),
|
|
- datetime(2003, 9, 25, 10, 36, 28,
|
|
- tzinfo=self.brsttz))
|
|
-
|
|
def testISOFormatStrip2(self):
|
|
self.assertEqual(parse("2003-09-25T10:49:41+03:00"),
|
|
datetime(2003, 9, 25, 10, 49, 41,
|
|
@@ -570,11 +562,11 @@
|
|
parse('shouldfail')
|
|
|
|
def testCorrectErrorOnFuzzyWithTokens(self):
|
|
- assertRaisesRegex(self, ParserError, 'Unknown string format',
|
|
+ self.assertRaisesRegex(ParserError, 'Unknown string format',
|
|
parse, '04/04/32/423', fuzzy_with_tokens=True)
|
|
- assertRaisesRegex(self, ParserError, 'Unknown string format',
|
|
+ self.assertRaisesRegex(ParserError, 'Unknown string format',
|
|
parse, '04/04/04 +32423', fuzzy_with_tokens=True)
|
|
- assertRaisesRegex(self, ParserError, 'Unknown string format',
|
|
+ self.assertRaisesRegex(ParserError, 'Unknown string format',
|
|
parse, '04/04/0d4', fuzzy_with_tokens=True)
|
|
|
|
def testIncreasingCTime(self):
|
|
--- a/tests/test_rrule.py
|
|
+++ b/tests/test_rrule.py
|
|
@@ -3,7 +3,6 @@
|
|
|
|
from datetime import datetime, date
|
|
import unittest
|
|
-from six import PY2
|
|
|
|
from dateutil import tz
|
|
from dateutil.rrule import (
|
|
@@ -2282,27 +2281,6 @@
|
|
datetime(2010, 3, 22, 13, 1),
|
|
datetime(2010, 3, 22, 14, 1)])
|
|
|
|
- def testLongIntegers(self):
|
|
- if PY2: # There are no longs in python3
|
|
- self.assertEqual(list(rrule(MINUTELY,
|
|
- count=long(2),
|
|
- interval=long(2),
|
|
- bymonth=long(2),
|
|
- byweekday=long(3),
|
|
- byhour=long(6),
|
|
- byminute=long(6),
|
|
- bysecond=long(6),
|
|
- dtstart=datetime(1997, 9, 2, 9, 0))),
|
|
- [datetime(1998, 2, 5, 6, 6, 6),
|
|
- datetime(1998, 2, 12, 6, 6, 6)])
|
|
- self.assertEqual(list(rrule(YEARLY,
|
|
- count=long(2),
|
|
- bymonthday=long(5),
|
|
- byweekno=long(2),
|
|
- dtstart=datetime(1997, 9, 2, 9, 0))),
|
|
- [datetime(1998, 1, 5, 9, 0),
|
|
- datetime(2004, 1, 5, 9, 0)])
|
|
-
|
|
def testHourlyBadRRule(self):
|
|
"""
|
|
When `byhour` is specified with `freq=HOURLY`, there are certain
|
|
@@ -4577,24 +4555,6 @@
|
|
wkst=SU,
|
|
dtstart=datetime(1997, 9, 2, 9, 0)))
|
|
|
|
- def testToStrLongIntegers(self):
|
|
- if PY2: # There are no longs in python3
|
|
- self._rrulestr_reverse_test(rrule(MINUTELY,
|
|
- count=long(2),
|
|
- interval=long(2),
|
|
- bymonth=long(2),
|
|
- byweekday=long(3),
|
|
- byhour=long(6),
|
|
- byminute=long(6),
|
|
- bysecond=long(6),
|
|
- dtstart=datetime(1997, 9, 2, 9, 0)))
|
|
-
|
|
- self._rrulestr_reverse_test(rrule(YEARLY,
|
|
- count=long(2),
|
|
- bymonthday=long(5),
|
|
- byweekno=long(2),
|
|
- dtstart=datetime(1997, 9, 2, 9, 0)))
|
|
-
|
|
def testReplaceIfSet(self):
|
|
rr = rrule(YEARLY,
|
|
count=1,
|
|
--- a/tests/test_tz.py
|
|
+++ b/tests/test_tz.py
|
|
@@ -7,7 +7,6 @@
|
|
from datetime import datetime, timedelta
|
|
from datetime import time as dt_time
|
|
from datetime import tzinfo
|
|
-from six import PY2
|
|
from io import BytesIO, StringIO
|
|
import unittest
|
|
|
|
@@ -1114,11 +1113,6 @@
|
|
b"America/New_York",
|
|
".*should be str, not bytes.*",
|
|
id="bytes on Python 3",
|
|
- marks=[
|
|
- pytest.mark.skipif(
|
|
- PY2, reason="bytes arguments accepted in Python 2"
|
|
- )
|
|
- ],
|
|
),
|
|
pytest.param(
|
|
object(),
|
|
--- a/updatezinfo.py
|
|
+++ b/updatezinfo.py
|
|
@@ -4,8 +4,8 @@
|
|
import json
|
|
import io
|
|
|
|
-from six.moves.urllib import request
|
|
-from six.moves.urllib import error as urllib_error
|
|
+from urllib import request
|
|
+from urllib import error as urllib_error
|
|
|
|
try:
|
|
import dateutil
|
|
--- a/src/dateutil/rrule.py
|
|
+++ b/src/dateutil/rrule.py
|
|
@@ -15,9 +15,9 @@
|
|
# For warning about deprecation of until and count
|
|
from warnings import warn
|
|
|
|
-from six import advance_iterator, integer_types
|
|
-
|
|
-from six.moves import _thread, range
|
|
+import _thread
|
|
+advance_iterator = next
|
|
+integer_types = (int,)
|
|
|
|
from ._common import weekday as weekdaybase
|
|
|
|
--- a/src/dateutil/parser/_parser.py
|
|
+++ b/src/dateutil/parser/_parser.py
|
|
@@ -39,9 +39,6 @@
|
|
from calendar import monthrange
|
|
from io import StringIO
|
|
|
|
-import six
|
|
-from six import integer_types, text_type
|
|
-
|
|
from decimal import Decimal
|
|
|
|
from warnings import warn
|
|
@@ -63,7 +60,7 @@
|
|
if isinstance(instream, (bytes, bytearray)):
|
|
instream = instream.decode()
|
|
|
|
- if isinstance(instream, text_type):
|
|
+ if isinstance(instream, str):
|
|
instream = StringIO(instream)
|
|
elif getattr(instream, 'read', None) is None:
|
|
raise TypeError('Parser must be a string or character stream, not '
|
|
@@ -648,7 +645,7 @@
|
|
try:
|
|
ret = self._build_naive(res, default)
|
|
except ValueError as e:
|
|
- six.raise_from(ParserError(str(e) + ": %s", timestr), e)
|
|
+ raise ParserError(str(e) + ": %s", timestr) from e
|
|
|
|
if not ignoretz:
|
|
ret = self._build_tzaware(ret, res, tzinfos)
|
|
@@ -878,7 +875,7 @@
|
|
try:
|
|
value = self._to_decimal(value_repr)
|
|
except Exception as e:
|
|
- six.raise_from(ValueError('Unknown numeric token'), e)
|
|
+ raise ValueError('Unknown numeric token') from e
|
|
|
|
len_li = len(value_repr)
|
|
|
|
@@ -1147,7 +1144,7 @@
|
|
raise ValueError("Converted decimal value is infinite or NaN")
|
|
except Exception as e:
|
|
msg = "Could not convert %s to decimal" % val
|
|
- six.raise_from(ValueError(msg), e)
|
|
+ raise ValueError(msg) from e
|
|
else:
|
|
return decimal_value
|
|
|
|
@@ -1165,9 +1162,9 @@
|
|
# eg tzinfos = {'BRST' : None}
|
|
if isinstance(tzdata, datetime.tzinfo) or tzdata is None:
|
|
tzinfo = tzdata
|
|
- elif isinstance(tzdata, text_type):
|
|
+ elif isinstance(tzdata, str):
|
|
tzinfo = tz.tzstr(tzdata)
|
|
- elif isinstance(tzdata, integer_types):
|
|
+ elif isinstance(tzdata, int):
|
|
tzinfo = tz.tzoffset(tzname, tzdata)
|
|
else:
|
|
raise TypeError("Offset must be tzinfo subclass, tz string, "
|
|
--- a/src/dateutil/parser/isoparser.py
|
|
+++ b/src/dateutil/parser/isoparser.py
|
|
@@ -14,7 +14,6 @@
|
|
from functools import wraps
|
|
|
|
import re
|
|
-import six
|
|
|
|
__all__ = ["isoparse", "isoparser"]
|
|
|
|
@@ -26,13 +25,13 @@
|
|
str_in = getattr(str_in, 'read', lambda: str_in)()
|
|
|
|
# If it's unicode, turn it into bytes, since ISO-8601 only covers ASCII
|
|
- if isinstance(str_in, six.text_type):
|
|
+ if isinstance(str_in, str):
|
|
# ASCII is the same in UTF-8
|
|
try:
|
|
str_in = str_in.encode('ascii')
|
|
except UnicodeEncodeError as e:
|
|
msg = 'ISO-8601 strings should contain only ASCII characters'
|
|
- six.raise_from(ValueError(msg), e)
|
|
+ raise ValueError(msg) from e
|
|
|
|
return f(self, str_in, *args, **kwargs)
|
|
|
|
--- a/src/dateutil/tz/tz.py
|
|
+++ b/src/dateutil/tz/tz.py
|
|
@@ -16,9 +16,8 @@
|
|
import weakref
|
|
from collections import OrderedDict
|
|
|
|
-import six
|
|
-from six import string_types
|
|
-from six.moves import _thread
|
|
+import _thread
|
|
+
|
|
from ._common import tzname_in_python2, _tzinfo
|
|
from ._common import tzrangebase, enfold
|
|
from ._common import _validate_fromutc_inputs
|
|
@@ -38,8 +37,7 @@
|
|
EPOCHORDINAL = EPOCH.toordinal()
|
|
|
|
|
|
-@six.add_metaclass(_TzSingleton)
|
|
-class tzutc(datetime.tzinfo):
|
|
+class tzutc(datetime.tzinfo, metaclass=_TzSingleton):
|
|
"""
|
|
This is a tzinfo object that represents the UTC time zone.
|
|
|
|
@@ -129,8 +127,7 @@
|
|
UTC = tzutc()
|
|
|
|
|
|
-@six.add_metaclass(_TzOffsetFactory)
|
|
-class tzoffset(datetime.tzinfo):
|
|
+class tzoffset(datetime.tzinfo, metaclass=_TzOffsetFactory):
|
|
"""
|
|
A simple class for representing a fixed offset from UTC.
|
|
|
|
@@ -459,7 +456,7 @@
|
|
super(tzfile, self).__init__()
|
|
|
|
file_opened_here = False
|
|
- if isinstance(fileobj, string_types):
|
|
+ if isinstance(fileobj, str):
|
|
self._filename = fileobj
|
|
fileobj = open(fileobj, 'rb')
|
|
file_opened_here = True
|
|
@@ -1033,8 +1030,7 @@
|
|
return self._dst_base_offset_
|
|
|
|
|
|
-@six.add_metaclass(_TzStrFactory)
|
|
-class tzstr(tzrange):
|
|
+class tzstr(tzrange, metaclass=_TzStrFactory):
|
|
"""
|
|
``tzstr`` objects are time zone objects specified by a time-zone string as
|
|
it would be passed to a ``TZ`` variable on POSIX-style systems (see
|
|
@@ -1265,7 +1261,7 @@
|
|
global rrule
|
|
from dateutil import rrule
|
|
|
|
- if isinstance(fileobj, string_types):
|
|
+ if isinstance(fileobj, str):
|
|
self._s = fileobj
|
|
# ical should be encoded in UTF-8 with CRLF
|
|
fileobj = open(fileobj, 'r')
|
|
@@ -1621,7 +1617,7 @@
|
|
except TypeError as e:
|
|
if isinstance(name, bytes):
|
|
new_msg = "gettz argument should be str, not bytes"
|
|
- six.raise_from(TypeError(new_msg), e)
|
|
+ raise TypeError(new_msg) from e
|
|
else:
|
|
raise
|
|
if os.path.isabs(name):
|
|
--- a/src/dateutil/tz/_common.py
|
|
+++ b/src/dateutil/tz/_common.py
|
|
@@ -1,5 +1,3 @@
|
|
-from six import PY2
|
|
-
|
|
from functools import wraps
|
|
|
|
from datetime import datetime, timedelta, tzinfo
|
|
@@ -16,18 +14,7 @@
|
|
tzname() API changed in Python 3. It used to return bytes, but was changed
|
|
to unicode strings
|
|
"""
|
|
- if PY2:
|
|
- @wraps(namefunc)
|
|
- def adjust_encoding(*args, **kwargs):
|
|
- name = namefunc(*args, **kwargs)
|
|
- if name is not None:
|
|
- name = name.encode()
|
|
-
|
|
- return name
|
|
-
|
|
- return adjust_encoding
|
|
- else:
|
|
- return namefunc
|
|
+ return namefunc
|
|
|
|
|
|
# The following is adapted from Alexander Belopolsky's tz library
|
|
@@ -309,7 +296,6 @@
|
|
else:
|
|
return ZERO
|
|
|
|
- @tzname_in_python2
|
|
def tzname(self, dt):
|
|
if self._isdst(dt):
|
|
return self._dst_abbr
|
|
--- a/src/dateutil/tz/_factories.py
|
|
+++ b/src/dateutil/tz/_factories.py
|
|
@@ -2,7 +2,7 @@
|
|
import weakref
|
|
from collections import OrderedDict
|
|
|
|
-from six.moves import _thread
|
|
+import _thread
|
|
|
|
|
|
class _TzSingleton(type):
|
|
--- a/src/dateutil/tz/win.py
|
|
+++ b/src/dateutil/tz/win.py
|
|
@@ -10,8 +10,8 @@
|
|
import datetime
|
|
import struct
|
|
|
|
-from six.moves import winreg
|
|
-from six import text_type
|
|
+import winreg
|
|
+text_type = str
|
|
|
|
try:
|
|
import ctypes
|