Commit cca86c7f authored by Jason R. Coombs's avatar Jason R. Coombs

Use Python 3 syntax for new-style clasess

parent 7068f1d4
...@@ -78,6 +78,9 @@ __import__('pkg_resources.extern.packaging.requirements') ...@@ -78,6 +78,9 @@ __import__('pkg_resources.extern.packaging.requirements')
__import__('pkg_resources.extern.packaging.markers') __import__('pkg_resources.extern.packaging.markers')
__metaclass__ = type
if (3, 0) < sys.version_info < (3, 4): if (3, 0) < sys.version_info < (3, 4):
raise RuntimeError("Python 3.4 or later is required") raise RuntimeError("Python 3.4 or later is required")
...@@ -537,7 +540,7 @@ class IResourceProvider(IMetadataProvider): ...@@ -537,7 +540,7 @@ class IResourceProvider(IMetadataProvider):
"""List of resource names in the directory (like ``os.listdir()``)""" """List of resource names in the directory (like ``os.listdir()``)"""
class WorkingSet(object): class WorkingSet:
"""A collection of active distributions on sys.path (or a similar list)""" """A collection of active distributions on sys.path (or a similar list)"""
def __init__(self, entries=None): def __init__(self, entries=None):
...@@ -944,7 +947,7 @@ class _ReqExtras(dict): ...@@ -944,7 +947,7 @@ class _ReqExtras(dict):
return not req.marker or any(extra_evals) return not req.marker or any(extra_evals)
class Environment(object): class Environment:
"""Searchable snapshot of distributions on a search path""" """Searchable snapshot of distributions on a search path"""
def __init__( def __init__(
...@@ -2279,7 +2282,7 @@ EGG_NAME = re.compile( ...@@ -2279,7 +2282,7 @@ EGG_NAME = re.compile(
).match ).match
class EntryPoint(object): class EntryPoint:
"""Object representing an advertised importable object""" """Object representing an advertised importable object"""
def __init__(self, name, module_name, attrs=(), extras=(), dist=None): def __init__(self, name, module_name, attrs=(), extras=(), dist=None):
...@@ -2433,7 +2436,7 @@ def _version_from_file(lines): ...@@ -2433,7 +2436,7 @@ def _version_from_file(lines):
return safe_version(value.strip()) or None return safe_version(value.strip()) or None
class Distribution(object): class Distribution:
"""Wrap an actual or potential sys.path entry w/metadata""" """Wrap an actual or potential sys.path entry w/metadata"""
PKG_INFO = 'PKG-INFO' PKG_INFO = 'PKG-INFO'
......
...@@ -23,6 +23,8 @@ try: ...@@ -23,6 +23,8 @@ try:
except NameError: except NameError:
unicode = str unicode = str
__metaclass__ = type
def timestamp(dt): def timestamp(dt):
""" """
...@@ -43,7 +45,7 @@ class EggRemover(unicode): ...@@ -43,7 +45,7 @@ class EggRemover(unicode):
os.remove(self) os.remove(self)
class TestZipProvider(object): class TestZipProvider:
finalizers = [] finalizers = []
ref_time = datetime.datetime(2013, 5, 12, 13, 25, 0) ref_time = datetime.datetime(2013, 5, 12, 13, 25, 0)
...@@ -132,7 +134,7 @@ class TestZipProvider(object): ...@@ -132,7 +134,7 @@ class TestZipProvider(object):
manager.cleanup_resources() manager.cleanup_resources()
class TestResourceManager(object): class TestResourceManager:
def test_get_cache_path(self): def test_get_cache_path(self):
mgr = pkg_resources.ResourceManager() mgr = pkg_resources.ResourceManager()
path = mgr.get_cache_path('foo') path = mgr.get_cache_path('foo')
...@@ -163,7 +165,7 @@ class TestIndependence: ...@@ -163,7 +165,7 @@ class TestIndependence:
subprocess.check_call(cmd) subprocess.check_call(cmd)
class TestDeepVersionLookupDistutils(object): class TestDeepVersionLookupDistutils:
@pytest.fixture @pytest.fixture
def env(self, tmpdir): def env(self, tmpdir):
""" """
......
...@@ -9,6 +9,8 @@ import pkg_resources ...@@ -9,6 +9,8 @@ import pkg_resources
from .test_resources import Metadata from .test_resources import Metadata
__metaclass__ = type
def strip_comments(s): def strip_comments(s):
return '\n'.join( return '\n'.join(
...@@ -54,7 +56,7 @@ def parse_distributions(s): ...@@ -54,7 +56,7 @@ def parse_distributions(s):
yield dist yield dist
class FakeInstaller(object): class FakeInstaller:
def __init__(self, installable_dists): def __init__(self, installable_dists):
self._installable_dists = installable_dists self._installable_dists = installable_dists
......
...@@ -15,6 +15,8 @@ from setuptools.dist import Distribution, Feature ...@@ -15,6 +15,8 @@ from setuptools.dist import Distribution, Feature
from setuptools.depends import Require from setuptools.depends import Require
from . import monkey from . import monkey
__metaclass__ = type
__all__ = [ __all__ = [
'setup', 'Distribution', 'Feature', 'Command', 'Extension', 'Require', 'setup', 'Distribution', 'Feature', 'Command', 'Extension', 'Require',
'find_packages', 'find_packages',
...@@ -31,7 +33,7 @@ run_2to3_on_doctests = True ...@@ -31,7 +33,7 @@ run_2to3_on_doctests = True
lib2to3_fixer_packages = ['lib2to3.fixes'] lib2to3_fixer_packages = ['lib2to3.fixes']
class PackageFinder(object): class PackageFinder:
""" """
Generate a list of all Python packages found within a directory Generate a list of all Python packages found within a directory
""" """
......
...@@ -12,6 +12,8 @@ from setuptools.command.easy_install import easy_install ...@@ -12,6 +12,8 @@ from setuptools.command.easy_install import easy_install
from setuptools import namespaces from setuptools import namespaces
import setuptools import setuptools
__metaclass__ = type
class develop(namespaces.DevelopInstaller, easy_install): class develop(namespaces.DevelopInstaller, easy_install):
"""Set up package for development""" """Set up package for development"""
...@@ -192,7 +194,7 @@ class develop(namespaces.DevelopInstaller, easy_install): ...@@ -192,7 +194,7 @@ class develop(namespaces.DevelopInstaller, easy_install):
return easy_install.install_wrapper_scripts(self, dist) return easy_install.install_wrapper_scripts(self, dist)
class VersionlessRequirement(object): class VersionlessRequirement:
""" """
Adapt a pkg_resources.Distribution to simply return the project Adapt a pkg_resources.Distribution to simply return the project
name as the 'requirement' so that scripts will work across name as the 'requirement' so that scripts will work across
......
...@@ -63,6 +63,8 @@ from pkg_resources import ( ...@@ -63,6 +63,8 @@ from pkg_resources import (
) )
import pkg_resources.py31compat import pkg_resources.py31compat
__metaclass__ = type
# Turn on PEP440Warnings # Turn on PEP440Warnings
warnings.filterwarnings("default", category=pkg_resources.PEP440Warning) warnings.filterwarnings("default", category=pkg_resources.PEP440Warning)
...@@ -2050,7 +2052,7 @@ class WindowsCommandSpec(CommandSpec): ...@@ -2050,7 +2052,7 @@ class WindowsCommandSpec(CommandSpec):
split_args = dict(posix=False) split_args = dict(posix=False)
class ScriptWriter(object): class ScriptWriter:
""" """
Encapsulates behavior around writing entry point scripts for console and Encapsulates behavior around writing entry point scripts for console and
gui apps. gui apps.
......
...@@ -16,6 +16,8 @@ from pkg_resources import (resource_listdir, resource_exists, normalize_path, ...@@ -16,6 +16,8 @@ from pkg_resources import (resource_listdir, resource_exists, normalize_path,
add_activation_listener, require, EntryPoint) add_activation_listener, require, EntryPoint)
from setuptools import Command from setuptools import Command
__metaclass__ = type
class ScanningLoader(TestLoader): class ScanningLoader(TestLoader):
...@@ -58,7 +60,7 @@ class ScanningLoader(TestLoader): ...@@ -58,7 +60,7 @@ class ScanningLoader(TestLoader):
# adapted from jaraco.classes.properties:NonDataProperty # adapted from jaraco.classes.properties:NonDataProperty
class NonDataProperty(object): class NonDataProperty:
def __init__(self, fget): def __init__(self, fget):
self.fget = fget self.fget = fget
......
...@@ -11,6 +11,9 @@ from setuptools.extern.packaging.version import LegacyVersion, parse ...@@ -11,6 +11,9 @@ from setuptools.extern.packaging.version import LegacyVersion, parse
from setuptools.extern.six import string_types from setuptools.extern.six import string_types
__metaclass__ = type
def read_configuration( def read_configuration(
filepath, find_others=False, ignore_option_errors=False): filepath, find_others=False, ignore_option_errors=False):
"""Read given configuration file and returns options from it as a dict. """Read given configuration file and returns options from it as a dict.
...@@ -113,7 +116,7 @@ def parse_configuration( ...@@ -113,7 +116,7 @@ def parse_configuration(
return meta, options return meta, options
class ConfigHandler(object): class ConfigHandler:
"""Handles metadata supplied in configuration files.""" """Handles metadata supplied in configuration files."""
section_prefix = None section_prefix = None
......
...@@ -26,6 +26,8 @@ from setuptools.py27compat import get_all_headers ...@@ -26,6 +26,8 @@ from setuptools.py27compat import get_all_headers
from setuptools.py33compat import unescape from setuptools.py33compat import unescape
from setuptools.wheel import Wheel from setuptools.wheel import Wheel
__metaclass__ = type
EGG_FRAGMENT = re.compile(r'^egg=([-A-Za-z0-9_.+!]+)$') EGG_FRAGMENT = re.compile(r'^egg=([-A-Za-z0-9_.+!]+)$')
HREF = re.compile("""href\\s*=\\s*['"]?([^'"> ]+)""", re.I) HREF = re.compile("""href\\s*=\\s*['"]?([^'"> ]+)""", re.I)
# this is here to fix emacs' cruddy broken syntax highlighting # this is here to fix emacs' cruddy broken syntax highlighting
...@@ -235,7 +237,7 @@ def find_external_links(url, page): ...@@ -235,7 +237,7 @@ def find_external_links(url, page):
yield urllib.parse.urljoin(url, htmldecode(match.group(1))) yield urllib.parse.urljoin(url, htmldecode(match.group(1)))
class ContentChecker(object): class ContentChecker:
""" """
A null content checker that defines the interface for checking content A null content checker that defines the interface for checking content
""" """
...@@ -980,7 +982,7 @@ def _encode_auth(auth): ...@@ -980,7 +982,7 @@ def _encode_auth(auth):
return encoded.replace('\n', '') return encoded.replace('\n', '')
class Credential(object): class Credential:
""" """
A username/password pair. Use like a namedtuple. A username/password pair. Use like a namedtuple.
""" """
......
__all__ = [] __all__ = []
__metaclass__ = type
try: try:
# Python >=3.2 # Python >=3.2
from tempfile import TemporaryDirectory from tempfile import TemporaryDirectory
...@@ -7,7 +10,7 @@ except ImportError: ...@@ -7,7 +10,7 @@ except ImportError:
import shutil import shutil
import tempfile import tempfile
class TemporaryDirectory(object): class TemporaryDirectory:
""" """
Very simple temporary directory context manager. Very simple temporary directory context manager.
Will try to delete afterward, but will also ignore OS and similar Will try to delete afterward, but will also ignore OS and similar
......
...@@ -10,11 +10,12 @@ except ImportError: ...@@ -10,11 +10,12 @@ except ImportError:
from setuptools.extern import six from setuptools.extern import six
from setuptools.extern.six.moves import html_parser from setuptools.extern.six.moves import html_parser
__metaclass__ = type
OpArg = collections.namedtuple('OpArg', 'opcode arg') OpArg = collections.namedtuple('OpArg', 'opcode arg')
class Bytecode_compat(object): class Bytecode_compat:
def __init__(self, code): def __init__(self, code):
self.code = code self.code = code
......
...@@ -5,12 +5,14 @@ import pytest ...@@ -5,12 +5,14 @@ import pytest
from .files import build_files from .files import build_files
from .textwrap import DALS from .textwrap import DALS
__metaclass__ = type
futures = pytest.importorskip('concurrent.futures') futures = pytest.importorskip('concurrent.futures')
importlib = pytest.importorskip('importlib') importlib = pytest.importorskip('importlib')
class BuildBackendBase(object): class BuildBackendBase:
def __init__(self, cwd=None, env={}, backend_name='setuptools.build_meta'): def __init__(self, cwd=None, env={}, backend_name='setuptools.build_meta'):
self.cwd = cwd self.cwd = cwd
self.env = env self.env = env
......
...@@ -36,8 +36,10 @@ import pkg_resources ...@@ -36,8 +36,10 @@ import pkg_resources
from . import contexts from . import contexts
from .textwrap import DALS from .textwrap import DALS
__metaclass__ = type
class FakeDist(object):
class FakeDist:
def get_entry_map(self, group): def get_entry_map(self, group):
if group != 'console_scripts': if group != 'console_scripts':
return {} return {}
......
...@@ -16,12 +16,14 @@ from .files import build_files ...@@ -16,12 +16,14 @@ from .files import build_files
from .textwrap import DALS from .textwrap import DALS
from . import contexts from . import contexts
__metaclass__ = type
class Environment(str): class Environment(str):
pass pass
class TestEggInfo(object): class TestEggInfo:
setup_script = DALS(""" setup_script = DALS("""
from setuptools import setup from setuptools import setup
...@@ -181,7 +183,7 @@ class TestEggInfo(object): ...@@ -181,7 +183,7 @@ class TestEggInfo(object):
) )
invalid_marker = "<=>++" invalid_marker = "<=>++"
class RequiresTestHelper(object): class RequiresTestHelper:
@staticmethod @staticmethod
def parametrize(*test_list, **format_dict): def parametrize(*test_list, **format_dict):
......
...@@ -4,6 +4,8 @@ import pytest ...@@ -4,6 +4,8 @@ import pytest
from setuptools.glibc import check_glibc_version from setuptools.glibc import check_glibc_version
__metaclass__ = type
@pytest.fixture(params=[ @pytest.fixture(params=[
"2.20", "2.20",
...@@ -23,7 +25,7 @@ def bad_string(request): ...@@ -23,7 +25,7 @@ def bad_string(request):
return request.param return request.param
class TestGlibc(object): class TestGlibc:
def test_manylinux1_check_glibc_version(self, two_twenty): def test_manylinux1_check_glibc_version(self, two_twenty):
""" """
Test that the check_glibc_version function is robust against weird Test that the check_glibc_version function is robust against weird
......
...@@ -18,6 +18,8 @@ from setuptools.tests.textwrap import DALS ...@@ -18,6 +18,8 @@ from setuptools.tests.textwrap import DALS
import pytest import pytest
__metaclass__ = type
py3_only = pytest.mark.xfail(six.PY2, reason="Test runs on Python 3 only") py3_only = pytest.mark.xfail(six.PY2, reason="Test runs on Python 3 only")
...@@ -157,7 +159,7 @@ def test_translated_pattern_mismatch(pattern_mismatch): ...@@ -157,7 +159,7 @@ def test_translated_pattern_mismatch(pattern_mismatch):
assert not translate_pattern(pattern).match(target) assert not translate_pattern(pattern).match(target)
class TempDirTestCase(object): class TempDirTestCase:
def setup_method(self, method): def setup_method(self, method):
self.temp_dir = tempfile.mkdtemp() self.temp_dir = tempfile.mkdtemp()
self.old_cwd = os.getcwd() self.old_cwd = os.getcwd()
......
...@@ -4,8 +4,10 @@ from mock import patch ...@@ -4,8 +4,10 @@ from mock import patch
from setuptools import pep425tags from setuptools import pep425tags
__metaclass__ = type
class TestPEP425Tags(object):
class TestPEP425Tags:
def mock_get_config_var(self, **kwd): def mock_get_config_var(self, **kwd):
""" """
...@@ -104,7 +106,7 @@ class TestPEP425Tags(object): ...@@ -104,7 +106,7 @@ class TestPEP425Tags(object):
self.abi_tag_unicode('dm', {'Py_DEBUG': True, 'WITH_PYMALLOC': True}) self.abi_tag_unicode('dm', {'Py_DEBUG': True, 'WITH_PYMALLOC': True})
class TestManylinux1Tags(object): class TestManylinux1Tags:
@patch('setuptools.pep425tags.get_platform', lambda: 'linux_x86_64') @patch('setuptools.pep425tags.get_platform', lambda: 'linux_x86_64')
@patch('setuptools.glibc.have_compatible_glibc', @patch('setuptools.glibc.have_compatible_glibc',
......
...@@ -24,6 +24,8 @@ from .contexts import tempdir ...@@ -24,6 +24,8 @@ from .contexts import tempdir
from .files import build_files from .files import build_files
from .textwrap import DALS from .textwrap import DALS
__metaclass__ = type
WHEEL_INFO_TESTS = ( WHEEL_INFO_TESTS = (
('invalid.whl', ValueError), ('invalid.whl', ValueError),
...@@ -148,7 +150,7 @@ def _check_wheel_install(filename, install_dir, install_tree_includes, ...@@ -148,7 +150,7 @@ def _check_wheel_install(filename, install_dir, install_tree_includes,
assert requires_txt == dist.get_metadata('requires.txt').lstrip() assert requires_txt == dist.get_metadata('requires.txt').lstrip()
class Record(object): class Record:
def __init__(self, id, **kwargs): def __init__(self, id, **kwargs):
self._id = id self._id = id
......
...@@ -16,6 +16,9 @@ from setuptools import pep425tags ...@@ -16,6 +16,9 @@ from setuptools import pep425tags
from setuptools.command.egg_info import write_requirements from setuptools.command.egg_info import write_requirements
__metaclass__ = type
WHEEL_NAME = re.compile( WHEEL_NAME = re.compile(
r"""^(?P<project_name>.+?)-(?P<version>\d.*?) r"""^(?P<project_name>.+?)-(?P<version>\d.*?)
((-(?P<build>\d.*?))?-(?P<py_version>.+?)-(?P<abi>.+?)-(?P<platform>.+?) ((-(?P<build>\d.*?))?-(?P<py_version>.+?)-(?P<abi>.+?)-(?P<platform>.+?)
...@@ -52,7 +55,7 @@ def unpack(src_dir, dst_dir): ...@@ -52,7 +55,7 @@ def unpack(src_dir, dst_dir):
os.rmdir(dirpath) os.rmdir(dirpath)
class Wheel(object): class Wheel:
def __init__(self, filename): def __init__(self, filename):
match = WHEEL_NAME(os.path.basename(filename)) match = WHEEL_NAME(os.path.basename(filename))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment