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