Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop Python 2 #220

Merged
merged 15 commits into from Apr 1, 2020
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Expand Up @@ -3,7 +3,6 @@
TODO:
* [ ] Unit tests and/or doctests in docstrings
* [ ] ``tox -e py38`` passes locally
* [ ] ``tox -e py27`` passes locally
* [ ] Docstrings and API docs for any new/modified user-facing classes and functions
* [ ] Changes documented in docs/release.rst
* [ ] ``tox -e docs`` passes locally
Expand Down
3 changes: 0 additions & 3 deletions .travis.yml
Expand Up @@ -12,9 +12,6 @@ addons:

matrix:
include:
- os: linux
language: python
python: 2.7
- os: linux
language: python
python: 3.5
Expand Down
4 changes: 0 additions & 4 deletions appveyor.yml
Expand Up @@ -12,10 +12,6 @@ environment:

matrix:

- PYTHON: "C:\\Python27-x64"
PYTHON_VERSION: "2.7"
DISTUTILS_USE_SDK: "1"

- PYTHON: "C:\\Python35-x64"
PYTHON_VERSION: "3.5"

Expand Down
15 changes: 1 addition & 14 deletions docs/conf.py
Expand Up @@ -16,16 +16,7 @@

import sys
import os


PY2 = sys.version_info[0] == 2


if PY2: # pragma: py3 no cover
from mock import Mock as MagicMock
else: # pragma: py2 no cover
from unittest.mock import Mock as MagicMock

from unittest.mock import Mock as MagicMock

class Mock(MagicMock):
@classmethod
Expand All @@ -34,10 +25,6 @@ def __getattr__(cls, name):


MOCK_MODULES = ['msgpack']
if PY2:
MOCK_MODULES.append('lzma')


sys.modules.update((mod_name, Mock()) for mod_name in MOCK_MODULES)


Expand Down
4 changes: 2 additions & 2 deletions docs/contributing.rst
Expand Up @@ -145,9 +145,9 @@ To also run the doctests within docstrings, run::
Tests can be run under different Python versions using tox. E.g. (assuming you have the
corresponding Python interpreters installed on your system)::

$ tox -e py27,py35,py36,py37,py38
$ tox -e py35,py36,py37,py38

NumCodecs currently supports Python 2.7 and Python 3.5-3.8, so the above command must
NumCodecs currently supports Python 3.5-3.8, so the above command must
succeed before code can be accepted into the main code base. Note that only the py38
tox environment runs the doctests, i.e., doctests only need to succeed under Python 3.8.

Expand Down
6 changes: 6 additions & 0 deletions docs/release.rst
@@ -1,6 +1,12 @@
Release notes
=============

Upcoming Release
----------------

* Drop support for Python 2.
By :user:`James Bourbeau <jrbourbeau>`, :issue:`220`.


.. _release_0.6.4:

Expand Down
2 changes: 0 additions & 2 deletions numcodecs/__init__.py
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# flake8: noqa
"""Numcodecs is a Python package providing buffer compression and
transformation codecs for use in data storage and communication
Expand All @@ -18,7 +17,6 @@

"""

from __future__ import absolute_import, print_function, division
import multiprocessing
import atexit

Expand Down
21 changes: 7 additions & 14 deletions numcodecs/abc.py
@@ -1,11 +1,9 @@
# -*- coding: utf-8 -*-
"""This module defines the :class:`Codec` base class, a common interface for
all codec classes.

Codec classes must implement :func:`Codec.encode` and :func:`Codec.decode`
methods. Inputs to and outputs from these methods may be any Python object
exporting a contiguous buffer via the new-style Python protocol
or :class:`array.array` under Python 2.
exporting a contiguous buffer via the new-style Python protocol.

Codec classes must implement a :func:`Codec.get_config` method,
which must return a dictionary holding all configuration parameters
Expand All @@ -29,10 +27,9 @@
other and vice versa.

"""
from __future__ import absolute_import, print_function, division


class Codec(object):
class Codec:
"""Codec abstract base class."""

# override in sub-class
Expand All @@ -46,13 +43,13 @@ def encode(self, buf): # pragma: no cover
----------
buf : buffer-like
Data to be encoded. May be any object supporting the new-style
buffer protocol or `array.array` under Python 2.
buffer protocol.

Returns
-------
enc : buffer-like
Encoded data. May be any object supporting the new-style buffer
protocol or `array.array` under Python 2.
protocol.

"""
# override in sub-class
Expand All @@ -65,7 +62,7 @@ def decode(self, buf, out=None): # pragma: no cover
----------
buf : buffer-like
Encoded data. May be any object supporting the new-style buffer
protocol or `array.array` under Python 2.
protocol.
out : buffer-like, optional
Writeable buffer to store decoded data. N.B. if provided, this buffer must
be exactly the right size to store the decoded data.
Expand All @@ -74,7 +71,7 @@ def decode(self, buf, out=None): # pragma: no cover
-------
dec : buffer-like
Decoded data. May be any object supporting the new-style
buffer protocol or `array.array` under Python 2.
buffer protocol.

"""
# override in sub-class
Expand Down Expand Up @@ -117,10 +114,6 @@ def __eq__(self, other):
except AttributeError:
return False

def __ne__(self, other):
# only needed for PY2
return not self == other

def __repr__(self):

# override in sub-class if need special representation
Expand All @@ -129,7 +122,7 @@ def __repr__(self):
# parameters and valid keyword arguments to constructor function

r = '%s(' % type(self).__name__
params = ['%s=%r' % (k, getattr(self, k))
params = ['{}={!r}'.format(k, getattr(self, k))
for k in sorted(self.__dict__)
if not k.startswith('_')]
r += ', '.join(params) + ')'
Expand Down
5 changes: 1 addition & 4 deletions numcodecs/astype.py
@@ -1,6 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import, print_function, division

import numpy as np

from .abc import Codec
Expand Down Expand Up @@ -79,7 +76,7 @@ def get_config(self):

def __repr__(self):
return (
'%s(encode_dtype=%r, decode_dtype=%r)' % (
'{}(encode_dtype={!r}, decode_dtype={!r})'.format(
type(self).__name__,
self.encode_dtype.str,
self.decode_dtype.str
Expand Down