Skip to content

Commit

Permalink
Added new style super calls, removed six module and some more occuren…
Browse files Browse the repository at this point in the history
…ce of python2, updated setup to enforce python>=3.4,<4
  • Loading branch information
voith committed Jun 27, 2018
1 parent 5a01c58 commit 78bca2a
Show file tree
Hide file tree
Showing 14 changed files with 15 additions and 56 deletions.
10 changes: 5 additions & 5 deletions populus/chain/geth.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def __init__(self, project_dir, blockchains_dir, chain_name, overrides):
chain_name,
'stderr',
)
super(LoggedDevGethProcess, self).__init__(
super().__init__(
overrides=overrides,
chain_name=chain_name,
base_dir=blockchains_dir,
Expand All @@ -58,14 +58,14 @@ def __init__(self, project_dir, blockchains_dir, chain_name, overrides):

class LoggedTestnetGethProccess(LoggingMixin, TestnetGethProcess):
def __init__(self, project_dir, geth_kwargs):
super(LoggedTestnetGethProccess, self).__init__(
super().__init__(
geth_kwargs=geth_kwargs,
)


class LoggedMainnetGethProcess(LoggingMixin, LiveGethProcess):
def __init__(self, project_dir, geth_kwargs):
super(LoggedMainnetGethProcess, self).__init__(
super().__init__(
geth_kwargs=geth_kwargs,
stdout_logfile_path=get_geth_logfile_path(
project_dir,
Expand Down Expand Up @@ -94,15 +94,15 @@ def __init__(self, *args, **kwargs):
)
warnings.warn(warn_msg, DeprecationWarning)
warnings.resetwarnings()
super(BaseGethChain, self).__init__(*args, **kwargs)
super().__init__(*args, **kwargs)

def initialize_chain(self):
# context manager shenanigans
self.stack = ExitStack()
self.geth = self.get_geth_process_instance()

def get_web3_config(self):
base_config = super(BaseGethChain, self).get_web3_config()
base_config = super().get_web3_config()
config = copy.deepcopy(base_config)
if not config.get('provider.settings'):
if issubclass(base_config.provider_class, IPCProvider):
Expand Down
2 changes: 1 addition & 1 deletion populus/chain/testrpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class TestRPCChain(BaseChain):
rpc_port = None

def get_web3_config(self):
base_config = super(TestRPCChain, self).get_web3_config()
base_config = super().get_web3_config()
config = copy.deepcopy(base_config)
config['provider.settings.port'] = self.rpc_port
return config
Expand Down
2 changes: 1 addition & 1 deletion populus/compilation/backends/solc_combined_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def __init__(self, *args, **kwargs):
warn_msg = 'Support for solc <0.4.11 will be dropped in the next populus release'
warnings.warn(warn_msg, DeprecationWarning)

super(SolcCombinedJSONBackend, self).__init__(*args, **kwargs)
super().__init__(*args, **kwargs)

def get_compiled_contracts(self, source_file_paths, import_remappings):
self.logger.debug("Import remappings: %s", import_remappings)
Expand Down
2 changes: 1 addition & 1 deletion populus/compilation/backends/solc_standard_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def __init__(self, *args, **kwargs):
"versions >=0.4.11. The SolcCombinedJSONBackend should be used "
"for all versions <=0.4.8"
)
super(SolcStandardJSONBackend, self).__init__(*args, **kwargs)
super().__init__(*args, **kwargs)

def get_compiled_contracts(self, source_file_paths, import_remappings):
self.logger.debug("Import remappings: %s", import_remappings)
Expand Down
5 changes: 0 additions & 5 deletions populus/plugin.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import os
import sys
import pytest

from populus.project import Project
Expand All @@ -19,10 +18,6 @@
)


if sys.version_info.major == 2:
FileNotFoundError = OSError


def pytest_addoption(parser):
parser.addoption("--populus-project", help="populus project root directory")
parser.addini("populus_project", "populus project root directory")
Expand Down
5 changes: 0 additions & 5 deletions populus/project.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import copy
import itertools
import os
import sys

from eth_utils import (
to_tuple,
Expand Down Expand Up @@ -51,10 +50,6 @@
)


if sys.version_info.major == 2:
FileNotFoundError = OSError


class Project(object):
project_dir = None
config_file_path = None
Expand Down
14 changes: 3 additions & 11 deletions populus/utils/base58.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,13 @@
"""
Lifted from the base58 package.
"""
import sys


# 58 character alphabet used
ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'


if sys.version_info.major == 2:
iseq = lambda s: list(map(ord, s)) # noqa: E731
bseq = lambda s: ''.join(map(chr, s)) # noqa: E731
buffer = lambda s: s # noqa: E731
else:
iseq = lambda s: s # noqa: E731
bseq = bytes # noqa: E731
buffer = lambda s: s.buffer # noqa: E731
iseq = lambda s: s # noqa: E731
bseq = bytes # noqa: E731
buffer = lambda s: s.buffer # noqa: E731


def b58encode(v):
Expand Down
4 changes: 1 addition & 3 deletions populus/utils/chains.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
import re
from urllib import parse

from eth_utils import (
add_0x_prefix,
Expand All @@ -10,9 +11,6 @@
from .filesystem import (
normpath,
)
from .six import (
parse,
)


BASE_BLOCKCHAIN_STORAGE_DIR = "./chains"
Expand Down
5 changes: 0 additions & 5 deletions populus/utils/filesystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import functools
import os
import shutil
import sys
import tempfile as _tempfile

from eth_utils import (
Expand All @@ -14,10 +13,6 @@
)


if sys.version_info.major == 2:
FileNotFoundError = OSError


def ensure_path_exists(dir_path):
"""
Make sure that a path exists
Expand Down
5 changes: 0 additions & 5 deletions populus/utils/six/__init__.py

This file was deleted.

3 changes: 0 additions & 3 deletions populus/utils/six/six_py3.py

This file was deleted.

9 changes: 1 addition & 8 deletions populus/utils/string.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,12 @@
import sys

from eth_utils import (
force_bytes,
force_text,
)


def normalize_class_name(value):
"""
For `type()` calls:
* Python 2 wants `str`
* Python 3.4 wants `str`
* Python 3.5 doesn't care.
"""
if sys.version_info.major == 2:
return force_bytes(value)
else:
return force_text(value)
return force_text(value)
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
include_package_data=True,
py_modules=['populus'],
setup_requires=['setuptools-markdown'],
python_requires='>=3.4,<4',
install_requires=[
"anyconfig>=0.7.0",
"click>=6.6",
Expand Down
4 changes: 1 addition & 3 deletions tests/observer-utils/test_watchdog_based_observer.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import os
import queue

from populus.utils.filesystem import (
ensure_file_exists,
)
from populus.utils.six import (
queue,
)
from populus.utils.observers import DirWatcher


Expand Down

0 comments on commit 78bca2a

Please sign in to comment.