Skip to content

Commit 7f292bc

Browse files
authored
Merge pull request #250 from python/debt/py36
Require Python 3.6
2 parents 49f223d + 3aa1141 commit 7f292bc

File tree

12 files changed

+24
-150
lines changed

12 files changed

+24
-150
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ jobs:
66
test:
77
strategy:
88
matrix:
9-
python: [2.7, 3.5, 3.6, 3.7, 3.8, 3.9]
9+
python: [3.6, 3.7, 3.8, 3.9]
1010
platform: [ubuntu-latest, macos-latest, windows-latest]
1111
runs-on: ${{ matrix.platform }}
1212
steps:

coverage.ini

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ exclude_lines =
1717
raise NotImplementedError
1818
raise AssertionError
1919
assert\s
20-
nocoverpy${PYV}
2120

2221
[paths]
2322
source =

docs/changelog.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
importlib_metadata NEWS
33
=========================
44

5+
v3.0.0
6+
======
7+
8+
* Require Python 3.6 or later.
9+
510
v2.0.0
611
======
712

importlib_metadata/__init__.py

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,31 @@
1-
from __future__ import unicode_literals, absolute_import
2-
31
import io
42
import os
53
import re
64
import abc
75
import csv
86
import sys
97
import zipp
8+
import email
9+
import pathlib
1010
import operator
1111
import functools
1212
import itertools
1313
import posixpath
1414
import collections
1515

1616
from ._compat import (
17-
install,
1817
NullFinder,
19-
ConfigParser,
20-
suppress,
21-
map,
22-
FileNotFoundError,
23-
IsADirectoryError,
24-
NotADirectoryError,
25-
PermissionError,
26-
pathlib,
27-
ModuleNotFoundError,
28-
MetaPathFinder,
29-
email_message_from_string,
3018
PyPy_repr,
31-
unique_ordered,
32-
str,
19+
install,
3320
)
21+
22+
from configparser import ConfigParser
23+
from contextlib import suppress
3424
from importlib import import_module
25+
from importlib.abc import MetaPathFinder
3526
from itertools import starmap
3627

3728

38-
__metaclass__ = type
39-
40-
4129
__all__ = [
4230
'Distribution',
4331
'DistributionFinder',
@@ -277,7 +265,7 @@ def metadata(self):
277265
# (which points to the egg-info file) attribute unchanged.
278266
or self.read_text('')
279267
)
280-
return email_message_from_string(text)
268+
return email.message_from_string(text)
281269

282270
@property
283271
def version(self):
@@ -457,7 +445,7 @@ def zip_children(self):
457445
names = zip_path.root.namelist()
458446
self.joinpath = zip_path.joinpath
459447

460-
return unique_ordered(
448+
return dict.fromkeys(
461449
child.split(posixpath.sep, 1)[0]
462450
for child in names
463451
)

importlib_metadata/_compat.py

Lines changed: 1 addition & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,7 @@
1-
from __future__ import absolute_import, unicode_literals
2-
3-
import io
4-
import abc
51
import sys
6-
import email
7-
8-
9-
if sys.version_info > (3,): # pragma: nocover
10-
import builtins
11-
from configparser import ConfigParser
12-
import contextlib
13-
FileNotFoundError = builtins.FileNotFoundError
14-
IsADirectoryError = builtins.IsADirectoryError
15-
NotADirectoryError = builtins.NotADirectoryError
16-
PermissionError = builtins.PermissionError
17-
map = builtins.map
18-
from itertools import filterfalse
19-
else: # pragma: nocover
20-
from backports.configparser import ConfigParser
21-
from itertools import imap as map # type: ignore
22-
from itertools import ifilterfalse as filterfalse
23-
import contextlib2 as contextlib
24-
FileNotFoundError = IOError, OSError
25-
IsADirectoryError = IOError, OSError
26-
NotADirectoryError = IOError, OSError
27-
PermissionError = IOError, OSError
28-
29-
str = type('')
30-
31-
suppress = contextlib.suppress
32-
33-
if sys.version_info > (3, 5): # pragma: nocover
34-
import pathlib
35-
else: # pragma: nocover
36-
import pathlib2 as pathlib
37-
38-
try:
39-
ModuleNotFoundError = builtins.FileNotFoundError
40-
except (NameError, AttributeError): # pragma: nocover
41-
ModuleNotFoundError = ImportError # type: ignore
42-
43-
44-
if sys.version_info >= (3,): # pragma: nocover
45-
from importlib.abc import MetaPathFinder
46-
else: # pragma: nocover
47-
class MetaPathFinder(object):
48-
__metaclass__ = abc.ABCMeta
492

503

51-
__metaclass__ = type
52-
__all__ = [
53-
'install', 'NullFinder', 'MetaPathFinder', 'ModuleNotFoundError',
54-
'pathlib', 'ConfigParser', 'map', 'suppress', 'FileNotFoundError',
55-
'NotADirectoryError', 'email_message_from_string',
56-
]
4+
__all__ = ['install', 'NullFinder', 'PyPy_repr']
575

586

597
def install(cls):
@@ -104,20 +52,6 @@ def find_spec(*args, **kwargs):
10452
find_module = find_spec
10553

10654

107-
def py2_message_from_string(text): # nocoverpy3
108-
# Work around https://bugs.python.org/issue25545 where
109-
# email.message_from_string cannot handle Unicode on Python 2.
110-
io_buffer = io.StringIO(text)
111-
return email.message_from_file(io_buffer)
112-
113-
114-
email_message_from_string = (
115-
py2_message_from_string
116-
if sys.version_info < (3,) else
117-
email.message_from_string
118-
)
119-
120-
12155
class PyPy_repr:
12256
"""
12357
Override repr for EntryPoint objects on PyPy to avoid __iter__ access.
@@ -135,18 +69,3 @@ def make_param(name):
13569
if affected: # pragma: nocover
13670
__repr__ = __compat_repr__
13771
del affected
138-
139-
140-
# from itertools recipes
141-
def unique_everseen(iterable): # pragma: nocover
142-
"List unique elements, preserving order. Remember all elements ever seen."
143-
seen = set()
144-
seen_add = seen.add
145-
146-
for element in filterfalse(seen.__contains__, iterable):
147-
seen_add(element)
148-
yield element
149-
150-
151-
unique_ordered = (
152-
unique_everseen if sys.version_info < (3, 7) else dict.fromkeys)

setup.cfg

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,12 @@ classifiers =
1212
License :: OSI Approved :: Apache Software License
1313
Topic :: Software Development :: Libraries
1414
Programming Language :: Python :: 3
15-
Programming Language :: Python :: 2
1615

1716
[options]
18-
python_requires = >=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*
17+
python_requires = >=3.6
1918
setup_requires = setuptools-scm
2019
install_requires =
2120
zipp>=0.5
22-
pathlib2; python_version < '3'
23-
contextlib2; python_version < '3'
24-
configparser>=3.5; python_version < '3'
2521
packages = importlib_metadata
2622

2723
[mypy]

tests/fixtures.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,13 @@
1-
from __future__ import unicode_literals
2-
31
import os
42
import sys
53
import shutil
4+
import pathlib
65
import tempfile
76
import textwrap
7+
import contextlib
88

99
from .py39compat import FS_NONASCII
1010

11-
from importlib_metadata._compat import pathlib, contextlib
12-
13-
14-
__metaclass__ = type
15-
1611

1712
@contextlib.contextmanager
1813
def tempdir():

tests/test_api.py

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,6 @@
88
entry_points, files, metadata, requires, version,
99
)
1010

11-
try:
12-
from collections.abc import Iterator
13-
except ImportError:
14-
from collections import Iterator # noqa: F401
15-
16-
try:
17-
from builtins import str as text
18-
except ImportError:
19-
from __builtin__ import unicode as text
20-
2111

2212
class APITests(
2313
fixtures.EggInfoPkg,
@@ -29,12 +19,12 @@ class APITests(
2919

3020
def test_retrieves_version_of_self(self):
3121
pkg_version = version('egginfo-pkg')
32-
assert isinstance(pkg_version, text)
22+
assert isinstance(pkg_version, str)
3323
assert re.match(self.version_pattern, pkg_version)
3424

3525
def test_retrieves_version_of_distinfo_pkg(self):
3626
pkg_version = version('distinfo-pkg')
37-
assert isinstance(pkg_version, text)
27+
assert isinstance(pkg_version, str)
3828
assert re.match(self.version_pattern, pkg_version)
3929

4030
def test_for_name_does_not_exist(self):

tests/test_integration.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
# coding: utf-8
2-
3-
from __future__ import unicode_literals
4-
51
import unittest
62
import packaging.requirements
73
import packaging.version

tests/test_main.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
# coding: utf-8
2-
from __future__ import unicode_literals
3-
41
import re
52
import json
63
import pickle
@@ -17,18 +14,13 @@
1714
entry_points, metadata, version,
1815
)
1916

20-
try:
21-
from builtins import str as text
22-
except ImportError:
23-
from __builtin__ import unicode as text
24-
2517

2618
class BasicTests(fixtures.DistInfoPkg, unittest.TestCase):
2719
version_pattern = r'\d+\.\d+(\.\d)?'
2820

2921
def test_retrieves_version_of_self(self):
3022
dist = Distribution.from_name('distinfo-pkg')
31-
assert isinstance(dist.version, text)
23+
assert isinstance(dist.version, str)
3224
assert re.match(self.version_pattern, dist.version)
3325

3426
def test_for_name_does_not_exist(self):

0 commit comments

Comments
 (0)