projects/aports·blob master · refs

515 lines · 15.8 KiB

1Forwarded: no... waiting on a new release
2
3--- a/setup.cfg
4+++ b/setup.cfg
5@@ -39,7 +39,6 @@
6 [options]
7 zip_safe = True
8 setup_requires = setuptools_scm
9-install_requires = six >= 1.5
10 package_dir =
11 =src
12 python_requires = >=2.7, !=3.0.*, !=3.1.*, !=3.2.*
13--- a/src/dateutil/relativedelta.py
14+++ b/src/dateutil/relativedelta.py
15@@ -5,7 +5,6 @@
16 import operator
17 from math import copysign
18
19-from six import integer_types
20 from warnings import warn
21
22 from ._common import weekday
23@@ -200,7 +199,7 @@
24 "This is not a well-defined condition and will raise " +
25 "errors in future versions.", DeprecationWarning)
26
27- if isinstance(weekday, integer_types):
28+ if isinstance(weekday, int):
29 self.weekday = weekdays[weekday]
30 else:
31 self.weekday = weekday
32--- a/tests/property/test_tz_prop.py
33+++ b/tests/property/test_tz_prop.py
34@@ -1,7 +1,6 @@
35 from datetime import datetime, timedelta
36
37 import pytest
38-import six
39 from hypothesis import assume, given
40 from hypothesis import strategies as st
41
42@@ -25,10 +24,7 @@
43 return
44
45 dt_act = dt.astimezone(tz.gettz(gettz_arg))
46- if six.PY2:
47- dt_exp = dt.astimezone(tz.tzlocal())
48- else:
49- dt_exp = dt.astimezone()
50+ dt_exp = dt.astimezone()
51
52 assert dt_act == dt_exp
53 assert dt_act.tzname() == dt_exp.tzname()
54--- a/tests/test_imports.py
55+++ b/tests/test_imports.py
56@@ -1,22 +1,10 @@
57 import sys
58 import unittest
59 import pytest
60-import six
61
62 MODULE_TYPE = type(sys)
63
64
65-# Tests live in datetutil/test which cause a RuntimeWarning for Python2 builds.
66-# But since we expect lazy imports tests to fail for Python < 3.7 we'll ignore those
67-# warnings with this filter.
68-
69-if six.PY2:
70- filter_import_warning = pytest.mark.filterwarnings("ignore::RuntimeWarning")
71-else:
72-
73- def filter_import_warning(f):
74- return f
75-
76
77 @pytest.fixture(scope="function")
78 def clean_import():
79@@ -46,7 +34,6 @@
80 sys.modules[mod_name] = mod
81
82
83-@filter_import_warning
84 @pytest.mark.parametrize(
85 "module",
86 ["easter", "parser", "relativedelta", "rrule", "tz", "utils", "zoneinfo"],
87--- a/tests/test_isoparser.py
88+++ b/tests/test_isoparser.py
89@@ -9,7 +9,6 @@
90 from dateutil.parser import isoparser, isoparse
91
92 import pytest
93-import six
94
95
96 def _generate_tzoffsets(limited):
97@@ -297,7 +296,7 @@
98
99
100 # This only fails on Python 3
101-@pytest.mark.xfail(not six.PY2, reason="Fails on Python 3 only")
102+@pytest.mark.xfail(reason="Fails on Python 3 only")
103 def test_isoparser_byte_sep():
104 dt = datetime(2017, 12, 6, 12, 30, 45)
105 dt_str = dt.isoformat(sep=str('T'))
106@@ -347,9 +346,7 @@
107 date(2016, 2, 1)
108 ]
109
110- if not six.PY2:
111- # strftime does not support dates before 1900 in Python 2
112- dates_no_day.append(date(1000, 11, 1))
113+ dates_no_day.append(date(1000, 11, 1))
114
115 # Only one supported format for dates with no day
116 o = zip(dates_no_day, it.repeat('%Y-%m'))
117@@ -371,7 +368,7 @@
118 @pytest.mark.parametrize('as_bytes', [True, False])
119 def test_parse_isodate(d, dt_fmt, as_bytes):
120 d_str = d.strftime(dt_fmt)
121- if isinstance(d_str, six.text_type) and as_bytes:
122+ if isinstance(d_str, str) and as_bytes:
123 d_str = d_str.encode('ascii')
124 elif isinstance(d_str, bytes) and not as_bytes:
125 d_str = d_str.decode('ascii')
126@@ -400,10 +397,7 @@
127 isoparser().parse_isodate('2014-0423')
128
129 # ensure the error message does not contain b' prefixes
130- if six.PY2:
131- expected_error = "String contains unknown ISO components: u'2014-0423'"
132- else:
133- expected_error = "String contains unknown ISO components: '2014-0423'"
134+ expected_error = "String contains unknown ISO components: '2014-0423'"
135 assert expected_error == str(excinfo.value)
136
137
138@@ -458,7 +452,7 @@
139 @pytest.mark.parametrize('as_bytes', [True, False])
140 def test_isotime(time_val, time_fmt, as_bytes):
141 tstr = time_val.strftime(time_fmt)
142- if isinstance(tstr, six.text_type) and as_bytes:
143+ if isinstance(tstr, str) and as_bytes:
144 tstr = tstr.encode('ascii')
145 elif isinstance(tstr, bytes) and not as_bytes:
146 tstr = tstr.decode('ascii')
147--- a/tests/test_parser.py
148+++ b/tests/test_parser.py
149@@ -14,7 +14,6 @@
150
151 from ._common import TZEnvContext
152
153-from six import assertRaisesRegex, PY2
154 from io import StringIO
155
156 import pytest
157@@ -462,13 +461,6 @@
158 datetime(2003, 9, 25, 10, 36, 28,
159 tzinfo=self.brsttz))
160
161- def testDateCommandFormatWithLong(self):
162- if PY2:
163- self.assertEqual(parse("Thu Sep 25 10:36:28 BRST 2003",
164- tzinfos={"BRST": long(-10800)}),
165- datetime(2003, 9, 25, 10, 36, 28,
166- tzinfo=self.brsttz))
167-
168 def testISOFormatStrip2(self):
169 self.assertEqual(parse("2003-09-25T10:49:41+03:00"),
170 datetime(2003, 9, 25, 10, 49, 41,
171@@ -570,11 +562,11 @@
172 parse('shouldfail')
173
174 def testCorrectErrorOnFuzzyWithTokens(self):
175- assertRaisesRegex(self, ParserError, 'Unknown string format',
176+ self.assertRaisesRegex(ParserError, 'Unknown string format',
177 parse, '04/04/32/423', fuzzy_with_tokens=True)
178- assertRaisesRegex(self, ParserError, 'Unknown string format',
179+ self.assertRaisesRegex(ParserError, 'Unknown string format',
180 parse, '04/04/04 +32423', fuzzy_with_tokens=True)
181- assertRaisesRegex(self, ParserError, 'Unknown string format',
182+ self.assertRaisesRegex(ParserError, 'Unknown string format',
183 parse, '04/04/0d4', fuzzy_with_tokens=True)
184
185 def testIncreasingCTime(self):
186--- a/tests/test_rrule.py
187+++ b/tests/test_rrule.py
188@@ -3,7 +3,6 @@
189
190 from datetime import datetime, date
191 import unittest
192-from six import PY2
193
194 from dateutil import tz
195 from dateutil.rrule import (
196@@ -2282,27 +2281,6 @@
197 datetime(2010, 3, 22, 13, 1),
198 datetime(2010, 3, 22, 14, 1)])
199
200- def testLongIntegers(self):
201- if PY2: # There are no longs in python3
202- self.assertEqual(list(rrule(MINUTELY,
203- count=long(2),
204- interval=long(2),
205- bymonth=long(2),
206- byweekday=long(3),
207- byhour=long(6),
208- byminute=long(6),
209- bysecond=long(6),
210- dtstart=datetime(1997, 9, 2, 9, 0))),
211- [datetime(1998, 2, 5, 6, 6, 6),
212- datetime(1998, 2, 12, 6, 6, 6)])
213- self.assertEqual(list(rrule(YEARLY,
214- count=long(2),
215- bymonthday=long(5),
216- byweekno=long(2),
217- dtstart=datetime(1997, 9, 2, 9, 0))),
218- [datetime(1998, 1, 5, 9, 0),
219- datetime(2004, 1, 5, 9, 0)])
220-
221 def testHourlyBadRRule(self):
222 """
223 When `byhour` is specified with `freq=HOURLY`, there are certain
224@@ -4577,24 +4555,6 @@
225 wkst=SU,
226 dtstart=datetime(1997, 9, 2, 9, 0)))
227
228- def testToStrLongIntegers(self):
229- if PY2: # There are no longs in python3
230- self._rrulestr_reverse_test(rrule(MINUTELY,
231- count=long(2),
232- interval=long(2),
233- bymonth=long(2),
234- byweekday=long(3),
235- byhour=long(6),
236- byminute=long(6),
237- bysecond=long(6),
238- dtstart=datetime(1997, 9, 2, 9, 0)))
239-
240- self._rrulestr_reverse_test(rrule(YEARLY,
241- count=long(2),
242- bymonthday=long(5),
243- byweekno=long(2),
244- dtstart=datetime(1997, 9, 2, 9, 0)))
245-
246 def testReplaceIfSet(self):
247 rr = rrule(YEARLY,
248 count=1,
249--- a/tests/test_tz.py
250+++ b/tests/test_tz.py
251@@ -7,7 +7,6 @@
252 from datetime import datetime, timedelta
253 from datetime import time as dt_time
254 from datetime import tzinfo
255-from six import PY2
256 from io import BytesIO, StringIO
257 import unittest
258
259@@ -1114,11 +1113,6 @@
260 b"America/New_York",
261 ".*should be str, not bytes.*",
262 id="bytes on Python 3",
263- marks=[
264- pytest.mark.skipif(
265- PY2, reason="bytes arguments accepted in Python 2"
266- )
267- ],
268 ),
269 pytest.param(
270 object(),
271--- a/updatezinfo.py
272+++ b/updatezinfo.py
273@@ -4,8 +4,8 @@
274 import json
275 import io
276
277-from six.moves.urllib import request
278-from six.moves.urllib import error as urllib_error
279+from urllib import request
280+from urllib import error as urllib_error
281
282 try:
283 import dateutil
284--- a/src/dateutil/rrule.py
285+++ b/src/dateutil/rrule.py
286@@ -15,9 +15,9 @@
287 # For warning about deprecation of until and count
288 from warnings import warn
289
290-from six import advance_iterator, integer_types
291-
292-from six.moves import _thread, range
293+import _thread
294+advance_iterator = next
295+integer_types = (int,)
296
297 from ._common import weekday as weekdaybase
298
299--- a/src/dateutil/parser/_parser.py
300+++ b/src/dateutil/parser/_parser.py
301@@ -39,9 +39,6 @@
302 from calendar import monthrange
303 from io import StringIO
304
305-import six
306-from six import integer_types, text_type
307-
308 from decimal import Decimal
309
310 from warnings import warn
311@@ -63,7 +60,7 @@
312 if isinstance(instream, (bytes, bytearray)):
313 instream = instream.decode()
314
315- if isinstance(instream, text_type):
316+ if isinstance(instream, str):
317 instream = StringIO(instream)
318 elif getattr(instream, 'read', None) is None:
319 raise TypeError('Parser must be a string or character stream, not '
320@@ -648,7 +645,7 @@
321 try:
322 ret = self._build_naive(res, default)
323 except ValueError as e:
324- six.raise_from(ParserError(str(e) + ": %s", timestr), e)
325+ raise ParserError(str(e) + ": %s", timestr) from e
326
327 if not ignoretz:
328 ret = self._build_tzaware(ret, res, tzinfos)
329@@ -878,7 +875,7 @@
330 try:
331 value = self._to_decimal(value_repr)
332 except Exception as e:
333- six.raise_from(ValueError('Unknown numeric token'), e)
334+ raise ValueError('Unknown numeric token') from e
335
336 len_li = len(value_repr)
337
338@@ -1147,7 +1144,7 @@
339 raise ValueError("Converted decimal value is infinite or NaN")
340 except Exception as e:
341 msg = "Could not convert %s to decimal" % val
342- six.raise_from(ValueError(msg), e)
343+ raise ValueError(msg) from e
344 else:
345 return decimal_value
346
347@@ -1165,9 +1162,9 @@
348 # eg tzinfos = {'BRST' : None}
349 if isinstance(tzdata, datetime.tzinfo) or tzdata is None:
350 tzinfo = tzdata
351- elif isinstance(tzdata, text_type):
352+ elif isinstance(tzdata, str):
353 tzinfo = tz.tzstr(tzdata)
354- elif isinstance(tzdata, integer_types):
355+ elif isinstance(tzdata, int):
356 tzinfo = tz.tzoffset(tzname, tzdata)
357 else:
358 raise TypeError("Offset must be tzinfo subclass, tz string, "
359--- a/src/dateutil/parser/isoparser.py
360+++ b/src/dateutil/parser/isoparser.py
361@@ -14,7 +14,6 @@
362 from functools import wraps
363
364 import re
365-import six
366
367 __all__ = ["isoparse", "isoparser"]
368
369@@ -26,13 +25,13 @@
370 str_in = getattr(str_in, 'read', lambda: str_in)()
371
372 # If it's unicode, turn it into bytes, since ISO-8601 only covers ASCII
373- if isinstance(str_in, six.text_type):
374+ if isinstance(str_in, str):
375 # ASCII is the same in UTF-8
376 try:
377 str_in = str_in.encode('ascii')
378 except UnicodeEncodeError as e:
379 msg = 'ISO-8601 strings should contain only ASCII characters'
380- six.raise_from(ValueError(msg), e)
381+ raise ValueError(msg) from e
382
383 return f(self, str_in, *args, **kwargs)
384
385--- a/src/dateutil/tz/tz.py
386+++ b/src/dateutil/tz/tz.py
387@@ -16,9 +16,8 @@
388 import weakref
389 from collections import OrderedDict
390
391-import six
392-from six import string_types
393-from six.moves import _thread
394+import _thread
395+
396 from ._common import tzname_in_python2, _tzinfo
397 from ._common import tzrangebase, enfold
398 from ._common import _validate_fromutc_inputs
399@@ -38,8 +37,7 @@
400 EPOCHORDINAL = EPOCH.toordinal()
401
402
403-@six.add_metaclass(_TzSingleton)
404-class tzutc(datetime.tzinfo):
405+class tzutc(datetime.tzinfo, metaclass=_TzSingleton):
406 """
407 This is a tzinfo object that represents the UTC time zone.
408
409@@ -129,8 +127,7 @@
410 UTC = tzutc()
411
412
413-@six.add_metaclass(_TzOffsetFactory)
414-class tzoffset(datetime.tzinfo):
415+class tzoffset(datetime.tzinfo, metaclass=_TzOffsetFactory):
416 """
417 A simple class for representing a fixed offset from UTC.
418
419@@ -459,7 +456,7 @@
420 super(tzfile, self).__init__()
421
422 file_opened_here = False
423- if isinstance(fileobj, string_types):
424+ if isinstance(fileobj, str):
425 self._filename = fileobj
426 fileobj = open(fileobj, 'rb')
427 file_opened_here = True
428@@ -1033,8 +1030,7 @@
429 return self._dst_base_offset_
430
431
432-@six.add_metaclass(_TzStrFactory)
433-class tzstr(tzrange):
434+class tzstr(tzrange, metaclass=_TzStrFactory):
435 """
436 ``tzstr`` objects are time zone objects specified by a time-zone string as
437 it would be passed to a ``TZ`` variable on POSIX-style systems (see
438@@ -1265,7 +1261,7 @@
439 global rrule
440 from dateutil import rrule
441
442- if isinstance(fileobj, string_types):
443+ if isinstance(fileobj, str):
444 self._s = fileobj
445 # ical should be encoded in UTF-8 with CRLF
446 fileobj = open(fileobj, 'r')
447@@ -1621,7 +1617,7 @@
448 except TypeError as e:
449 if isinstance(name, bytes):
450 new_msg = "gettz argument should be str, not bytes"
451- six.raise_from(TypeError(new_msg), e)
452+ raise TypeError(new_msg) from e
453 else:
454 raise
455 if os.path.isabs(name):
456--- a/src/dateutil/tz/_common.py
457+++ b/src/dateutil/tz/_common.py
458@@ -1,5 +1,3 @@
459-from six import PY2
460-
461 from functools import wraps
462
463 from datetime import datetime, timedelta, tzinfo
464@@ -16,18 +14,7 @@
465 tzname() API changed in Python 3. It used to return bytes, but was changed
466 to unicode strings
467 """
468- if PY2:
469- @wraps(namefunc)
470- def adjust_encoding(*args, **kwargs):
471- name = namefunc(*args, **kwargs)
472- if name is not None:
473- name = name.encode()
474-
475- return name
476-
477- return adjust_encoding
478- else:
479- return namefunc
480+ return namefunc
481
482
483 # The following is adapted from Alexander Belopolsky's tz library
484@@ -309,7 +296,6 @@
485 else:
486 return ZERO
487
488- @tzname_in_python2
489 def tzname(self, dt):
490 if self._isdst(dt):
491 return self._dst_abbr
492--- a/src/dateutil/tz/_factories.py
493+++ b/src/dateutil/tz/_factories.py
494@@ -2,7 +2,7 @@
495 import weakref
496 from collections import OrderedDict
497
498-from six.moves import _thread
499+import _thread
500
501
502 class _TzSingleton(type):
503--- a/src/dateutil/tz/win.py
504+++ b/src/dateutil/tz/win.py
505@@ -10,8 +10,8 @@
506 import datetime
507 import struct
508
509-from six.moves import winreg
510-from six import text_type
511+import winreg
512+text_type = str
513
514 try:
515 import ctypes