Skip to content

Commit ea8a4e4

Browse files
rthlarsoner
authored andcommitted
Drop Python 2.7 and 3.4 support
1 parent aa290a1 commit ea8a4e4

11 files changed

+34
-79
lines changed

.travis.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@ sudo: false
66
matrix:
77
include:
88
- python: 3.7
9+
- python: 3.6
10+
env: SPHINX_SPEC="==2.1.0" SPHINXOPTS=""
11+
- python: 3.5
912
env: SPHINX_SPEC="==1.6.5" SPHINXOPTS=""
10-
- python: 3.7
11-
- python: 2.7
1213
cache:
1314
directories:
1415
- $HOME/.cache/pip

README.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ docstrings formatted according to the NumPy documentation format.
1616
The extension also adds the code description directives
1717
``np:function``, ``np-c:function``, etc.
1818

19+
numpydoc requires Python 3.5+ and sphinx 1.6.5+.
20+
1921
For usage information, please refer to the `documentation
2022
<https://numpydoc.readthedocs.io/>`_.
2123

doc/install.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Installation
44
============
55

6-
The extension is available from:
6+
This extension requires Python 3.5+, sphinx 1.6.5+ and is available from:
77

88
* `numpydoc on PyPI <http://pypi.python.org/pypi/numpydoc>`_
99
* `numpydoc on GitHub <https://github.com/numpy/numpydoc/>`_

numpydoc/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from __future__ import division, absolute_import, print_function
2-
31
__version__ = '1.0.0.dev0'
42

53

numpydoc/docscrape.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,13 @@
11
"""Extract reference documentation from the NumPy source tree.
22
33
"""
4-
from __future__ import division, absolute_import, print_function
5-
64
import inspect
75
import textwrap
86
import re
97
import pydoc
108
from warnings import warn
119
from collections import namedtuple
12-
try:
13-
from collections.abc import Callable, Mapping
14-
except ImportError:
15-
from collections import Callable, Mapping
10+
from collections.abc import Callable, Mapping
1611
import copy
1712
import sys
1813

numpydoc/docscrape_sphinx.py

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
1-
from __future__ import division, absolute_import, print_function
2-
3-
import sys
41
import re
52
import inspect
63
import textwrap
74
import pydoc
8-
try:
9-
from collections.abc import Callable
10-
except ImportError:
11-
from collections import Callable
5+
from collections.abc import Callable
126
import os
137

148
from jinja2 import FileSystemLoader
@@ -19,11 +13,6 @@
1913
from .docscrape import NumpyDocString, FunctionDoc, ClassDoc
2014
from .xref import make_xref
2115

22-
if sys.version_info[0] >= 3:
23-
sixu = lambda s: s
24-
else:
25-
sixu = lambda s: unicode(s, 'unicode_escape')
26-
2716

2817
IMPORT_MATPLOTLIB_RE = r'\b(import +matplotlib|from +matplotlib +import)\b'
2918

@@ -290,12 +279,12 @@ def _str_member_list(self, name):
290279

291280
if others:
292281
maxlen_0 = max(3, max([len(p.name) + 4 for p in others]))
293-
hdr = sixu("=") * maxlen_0 + sixu(" ") + sixu("=") * 10
294-
fmt = sixu('%%%ds %%s ') % (maxlen_0,)
282+
hdr = "=" * maxlen_0 + " " + "=" * 10
283+
fmt = '%%%ds %%s ' % (maxlen_0,)
295284
out += ['', '', hdr]
296285
for param in others:
297286
name = "**" + param.name.strip() + "**"
298-
desc = sixu(" ").join(x.strip()
287+
desc = " ".join(x.strip()
299288
for x in param.desc).strip()
300289
if param.type:
301290
desc = "(%s) %s" % (param.type, desc)

numpydoc/numpydoc.py

Lines changed: 17 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,11 @@
1616
.. [1] https://github.com/numpy/numpydoc
1717
1818
"""
19-
from __future__ import division, absolute_import, print_function
20-
2119
from copy import deepcopy
22-
import sys
2320
import re
2421
import pydoc
2522
import inspect
26-
try:
27-
from collections.abc import Callable
28-
except ImportError:
29-
from collections import Callable
23+
from collections.abc import Callable
3024
import hashlib
3125
import itertools
3226

@@ -35,21 +29,15 @@
3529
from sphinx.addnodes import pending_xref, desc_content
3630
from sphinx.util import logging
3731

38-
if sphinx.__version__ < '1.0.1':
39-
raise RuntimeError("Sphinx 1.0.1 or newer is required")
32+
if sphinx.__version__ < '1.6.5':
33+
raise RuntimeError("Sphinx 1.6.5 or newer is required")
4034

4135
from .docscrape_sphinx import get_doc_object
4236
from .xref import DEFAULT_LINKS
4337
from . import __version__
4438

4539
logger = logging.getLogger(__name__)
4640

47-
if sys.version_info[0] >= 3:
48-
sixu = lambda s: s
49-
else:
50-
sixu = lambda s: unicode(s, 'unicode_escape')
51-
52-
5341
HASH_LEN = 12
5442

5543
def rename_references(app, what, name, obj, options, lines):
@@ -58,7 +46,7 @@ def rename_references(app, what, name, obj, options, lines):
5846
references = set()
5947
for line in lines:
6048
line = line.strip()
61-
m = re.match(sixu(r'^\.\. +\[(%s)\]') %
49+
m = re.match(r'^\.\. +\[(%s)\]' %
6250
app.config.numpydoc_citation_re,
6351
line, re.I)
6452
if m:
@@ -73,10 +61,10 @@ def rename_references(app, what, name, obj, options, lines):
7361
for r in references:
7462
new_r = prefix + '-' + r
7563
for i, line in enumerate(lines):
76-
lines[i] = lines[i].replace(sixu('[%s]_') % r,
77-
sixu('[%s]_') % new_r)
78-
lines[i] = lines[i].replace(sixu('.. [%s]') % r,
79-
sixu('.. [%s]') % new_r)
64+
lines[i] = lines[i].replace('[%s]_' % r,
65+
'[%s]_' % new_r)
66+
lines[i] = lines[i].replace('.. [%s]' % r,
67+
'.. [%s]' % new_r)
8068

8169

8270
def _is_cite_in_numpydoc_docstring(citation_node):
@@ -166,33 +154,29 @@ def mangle_docstrings(app, what, name, obj, options, lines):
166154
}
167155

168156
cfg.update(options or {})
169-
u_NL = sixu('\n')
157+
u_NL = '\n'
170158
if what == 'module':
171159
# Strip top title
172160
pattern = '^\\s*[#*=]{4,}\\n[a-z0-9 -]+\\n[#*=]{4,}\\s*'
173-
title_re = re.compile(sixu(pattern), re.I | re.S)
174-
lines[:] = title_re.sub(sixu(''), u_NL.join(lines)).split(u_NL)
161+
title_re = re.compile(pattern, re.I | re.S)
162+
lines[:] = title_re.sub('', u_NL.join(lines)).split(u_NL)
175163
else:
176164
try:
177165
doc = get_doc_object(obj, what, u_NL.join(lines), config=cfg,
178166
builder=app.builder)
179-
if sys.version_info[0] >= 3:
180-
doc = str(doc)
181-
else:
182-
doc = unicode(doc)
183-
lines[:] = doc.split(u_NL)
167+
lines[:] = str(doc).split(u_NL)
184168
except:
185169
logger.error('[numpydoc] While processing docstring for %r', name)
186170
raise
187171

188172
if (app.config.numpydoc_edit_link and hasattr(obj, '__name__') and
189173
obj.__name__):
190174
if hasattr(obj, '__module__'):
191-
v = dict(full_name=sixu("%s.%s") % (obj.__module__, obj.__name__))
175+
v = dict(full_name="%s.%s" % (obj.__module__, obj.__name__))
192176
else:
193177
v = dict(full_name=obj.__name__)
194-
lines += [sixu(''), sixu('.. htmlonly::'), sixu('')]
195-
lines += [sixu(' %s') % x for x in
178+
lines += ['', '.. htmlonly::', '']
179+
lines += [' %s' % x for x in
196180
(app.config.numpydoc_edit_link % v).split("\n")]
197181

198182
# call function to replace reference numbers so that there are no
@@ -218,8 +202,8 @@ def mangle_signature(app, what, name, obj, options, sig, retann):
218202
doc = get_doc_object(obj, config={'show_class_members': False})
219203
sig = doc['Signature'] or getattr(obj, '__text_signature__', None)
220204
if sig:
221-
sig = re.sub(sixu("^[^(]*"), sixu(""), sig)
222-
return sig, sixu('')
205+
sig = re.sub("^[^(]*", "", sig)
206+
return sig, ''
223207

224208

225209
def setup(app, get_doc_object_=get_doc_object):

numpydoc/tests/test_docscrape.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
# -*- encoding:utf-8 -*-
2-
from __future__ import division, absolute_import, print_function
3-
42
from collections import namedtuple
53
from copy import deepcopy
64
import re
@@ -24,12 +22,6 @@
2422
from pytest import warns as assert_warns
2523

2624

27-
if sys.version_info[0] >= 3:
28-
sixu = lambda s: s
29-
else:
30-
sixu = lambda s: unicode(s, 'unicode_escape')
31-
32-
3325
doc_txt = '''\
3426
numpy.multivariate_normal(mean, cov, shape=None, spam=None)
3527

numpydoc/tests/test_numpydoc.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
# -*- encoding:utf-8 -*-
2-
from __future__ import division, absolute_import, print_function
3-
42
from copy import deepcopy
53
from numpydoc.numpydoc import mangle_docstrings
64
from numpydoc.xref import DEFAULT_LINKS

numpydoc/tests/test_xref.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
# -*- encoding:utf-8 -*-
2-
from __future__ import division, absolute_import, print_function
3-
42
from numpydoc.xref import make_xref
53

64
xref_aliases = {

setup.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from __future__ import division, print_function
2-
31
import sys
42
import os
53

@@ -9,8 +7,8 @@
97

108
from numpydoc import __version__ as version
119

12-
if sys.version_info[:2] < (2, 7) or (3, 0) <= sys.version_info[0:2] < (3, 4):
13-
raise RuntimeError("Python version 2.7 or >= 3.4 required.")
10+
if sys.version_info < (3, 5):
11+
raise RuntimeError("Python version >= 3.5 required.")
1412

1513

1614
def read(fname):
@@ -36,18 +34,18 @@ def read(fname):
3634
"License :: OSI Approved :: BSD License",
3735
"Topic :: Documentation",
3836
"Programming Language :: Python",
39-
"Programming Language :: Python :: 2",
40-
"Programming Language :: Python :: 2.7",
4137
"Programming Language :: Python :: 3",
42-
"Programming Language :: Python :: 3.4",
4338
"Programming Language :: Python :: 3.5",
44-
"Programming Language :: Python :: 3.6"],
39+
"Programming Language :: Python :: 3.6",
40+
"Programming Language :: Python :: 3.7",
41+
],
4542
keywords="sphinx numpy",
4643
author="Pauli Virtanen and others",
4744
author_email="[email protected]",
4845
url="https://numpydoc.readthedocs.io",
4946
license="BSD",
5047
install_requires=["sphinx >= 1.6.5", 'Jinja2>=2.3'],
48+
python_requires=">=3.5",
5149
package_data={'numpydoc': [
5250
'tests/test_*.py',
5351
'tests/tinybuild/Makefile',

0 commit comments

Comments
 (0)