Skip to content

Commit

Permalink
Drop support for Python 2.7
Browse files Browse the repository at this point in the history
  • Loading branch information
pquentin committed Mar 1, 2024
1 parent db9d018 commit e0c54f9
Show file tree
Hide file tree
Showing 28 changed files with 75 additions and 247 deletions.
21 changes: 2 additions & 19 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,32 +13,22 @@ jobs:
strategy:
matrix:
python-version: [
"2.7",
"3.5",
"3.6",
"3.7",
"3.8",
"3.9",
"3.10",
"3.11",
"pypy-2.7",
"pypy-3.8",
]
os: [ubuntu-latest, windows-latest, macos-latest]
exclude:
- python-version: "2.7"
os: "ubuntu-latest"
- python-version: "2.7"
os: "windows-latest"
- python-version: "2.7"
os: "macos-latest"
- python-version: "3.5"
os: "ubuntu-latest"
- python-version: "3.6"
os: "ubuntu-latest"
include:
- python-version: "2.7"
os: "ubuntu-20.04"
- python-version: "3.5"
os: "ubuntu-20.04"
- python-version: "3.6"
Expand All @@ -48,19 +38,12 @@ jobs:
TOXENV: py
steps:
- uses: actions/checkout@v3
- if: ${{ matrix.python-version == '2.7' }}
run: |
sudo apt-get install python-is-python2
curl -sSL https://bootstrap.pypa.io/pip/2.7/get-pip.py -o get-pip.py
python get-pip.py
name: Set up Python ${{ matrix.python-version }} on ${{ matrix.os }}
- if: ${{ matrix.python-version != '2.7' }}
name: Set up Python ${{ matrix.python-version }} on ${{ matrix.os }}
- name: Set up Python ${{ matrix.python-version }} on ${{ matrix.os }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: python -m pip install -U tox six
run: python -m pip install -U tox
- name: Install zic (Windows)
run: |
curl https://get.enterprisedb.com/postgresql/postgresql-9.5.21-2-windows-x64-binaries.zip --output $env:GITHUB_WORKSPACE\postgresql9.5.21.zip
Expand Down
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,10 @@ pip install -r requirements-dev.txt

## Testing

The best way to test `dateutil` is to run `tox`. By default, `tox` will test against all supported versions of Python installed on your system. To limit the number of tests, run a specific subset of environments. For example, to run only on Python 2.7 and Python 3.6:
The best way to test `dateutil` is to run `tox`. By default, `tox` will test against all supported versions of Python installed on your system. To limit the number of tests, run a specific subset of environments. For example, to run only on Python 3.6 and Python 3.12:

```bash
tox -e py27,py36
tox -e py36,py12
```

You can also pass arguments to `pytest` through `tox` by placing them after `--`:
Expand Down
1 change: 0 additions & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ install:

# This frequently fails with network errors, so we'll retry it up to 5 times
# with a 1 minute rate limit.
- "%PYTHON% -m pip install six"
- "ci_tools/retry.bat %PYTHON% updatezinfo.py"
# This environment variable tells the test suite it's OK to mess with the time zone.
- set DATEUTIL_MAY_CHANGE_TZ=1
Expand Down
10 changes: 1 addition & 9 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ pool:

strategy:
matrix:
Python27:
python.version: '2.7'
Python34:
python.version: '3.4'
Python35:
Expand All @@ -26,14 +24,8 @@ strategy:
python.version: '3.6'
POOL_IMAGE: vs2017-win2016
installzic: 'windows'
PyPy:
python.version: 'pypy2'
PyPy3:
python.version: 'pypy3'
WindowsPyPy2:
python.version: 'pypy2'
POOL_IMAGE: vs2017-win2016
installzic: 'windows'
WindowsPyPy3:
python.version: 'pypy3'
POOL_IMAGE: vs2017-win2016
Expand All @@ -49,7 +41,7 @@ steps:
versionSpec: $(python.version)

- bash: |
python -m pip install -U six && python -m pip install -U 'tox < 3.8.0'
python -m pip install -U 'tox < 3.8.0'
if [[ $PYTHON_VERSION == "3.3" ]]; then pip install 'virtualenv<16.0'; fi
if [[ $PYTHON_VERSION == "3.3" ]]; then pip install 'setuptools<40.0'; fi
displayName: Ensure prereqs
Expand Down
1 change: 1 addition & 0 deletions changelog.d/1344.deprecation.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Dropped support for Python 2.7. Fixed by @pquentin.
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@

# -- Options for autodoc -------------------------------------------------

autodoc_mock_imports = ['ctypes.wintypes', 'six.moves.winreg']
autodoc_mock_imports = ['ctypes.wintypes']

# Need to mock this out specifically to avoid errors
import ctypes
Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ known_first_party = ["dateutil"]
known_third_party=[
"pytest",
"hypothesis",
"six",
"freezegun",
"mock",
]
Expand Down
1 change: 0 additions & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
six
pytest >= 3.0; python_version != '3.3'
pytest-cov >= 2.0.0
freezegun ; python_version != '3.3'
Expand Down
1 change: 0 additions & 1 deletion requirements/3.3/constraints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,5 @@ py==1.4.34
pytest==3.2.5
pytest-cov==2.5.1
setuptools==39.2.0
six==1.12.0
tox==2.9.1
virtualenv==15.2.0
5 changes: 1 addition & 4 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ classifiers =
License :: OSI Approved :: BSD License
License :: OSI Approved :: Apache Software License
Programming Language :: Python
Programming Language :: Python :: 2
Programming Language :: Python :: 2.7
Programming Language :: Python :: 3
Programming Language :: Python :: 3.3
Programming Language :: Python :: 3.4
Expand All @@ -39,10 +37,9 @@ classifiers =
[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.*
python_requires = >=3.3
packages = find:

[options.packages.find]
Expand Down
18 changes: 6 additions & 12 deletions src/dateutil/parser/_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -63,7 +60,7 @@ def __init__(self, instream):
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 '
Expand Down Expand Up @@ -193,9 +190,6 @@ def __next__(self):

return token

def next(self):
return self.__next__() # Python 2.x support

@classmethod
def split(cls, s):
return list(cls(s))
Expand Down Expand Up @@ -648,7 +642,7 @@ def parse(self, timestr, default=None,
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)
Expand Down Expand Up @@ -878,7 +872,7 @@ def _parse_numeric_token(self, tokens, idx, info, ymd, res, fuzzy):
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)

Expand Down Expand Up @@ -1147,7 +1141,7 @@ def _to_decimal(self, val):
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

Expand All @@ -1165,9 +1159,9 @@ def _build_tzinfo(self, tzinfos, tzname, tzoffset):
# 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, "
Expand Down
5 changes: 2 additions & 3 deletions src/dateutil/parser/isoparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
from functools import wraps

import re
import six

__all__ = ["isoparse", "isoparser"]

Expand All @@ -26,13 +25,13 @@ def func(self, str_in, *args, **kwargs):
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)

Expand Down
5 changes: 1 addition & 4 deletions src/dateutil/relativedelta.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import operator
from math import copysign

from six import integer_types
from warnings import warn

from ._common import weekday
Expand Down Expand Up @@ -200,7 +199,7 @@ def __init__(self, dt1=None, dt2=None,
"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
Expand Down Expand Up @@ -489,8 +488,6 @@ def __bool__(self):
self.minute is None and
self.second is None and
self.microsecond is None)
# Compatibility with Python 2.x
__nonzero__ = __bool__

def __mul__(self, other):
try:
Expand Down

0 comments on commit e0c54f9

Please sign in to comment.