mirror of https://github.com/nucypher/nucypher.git
commit
9f7cdbd78c
|
@ -166,12 +166,16 @@ jobs:
|
|||
- checkout
|
||||
- attach_workspace:
|
||||
at: ~/.local/share/virtualenvs/
|
||||
- run:
|
||||
name: Install lxml
|
||||
command: |
|
||||
pipenv run pip install lxml
|
||||
- run:
|
||||
name: Run Mypy Static Type Checks
|
||||
command: |
|
||||
mkdir ./mypy_reports ./mypy_results
|
||||
export MYPYPATH=./nucypher
|
||||
pipenv run mypy ./nucypher --config-file=mypy.ini --xslt-html-report ./mypy_reports/html/ --linecount-report ./mypy_reports/linecount --junit-xml ./mypy_results/results.xml || true
|
||||
pipenv run mypy ./nucypher --config-file=mypy.ini --xslt-html-report ./mypy_reports/html/ --linecount-report ./mypy_reports/linecount --junit-xml ./mypy_results/results.xml
|
||||
- store_artifacts:
|
||||
path: ./mypy_reports
|
||||
- store_test_results:
|
||||
|
|
2
mypy.ini
2
mypy.ini
|
@ -1,7 +1,7 @@
|
|||
[mypy]
|
||||
|
||||
python_version=3.6
|
||||
verbosity=0
|
||||
[mypy-nucypher.*]
|
||||
disallow_untyped_defs=False
|
||||
check_untyped_defs=False
|
||||
disallow_untyped_calls=False
|
||||
|
|
|
@ -8,7 +8,7 @@ class Economics:
|
|||
initial_inflation=1.0,
|
||||
T_half=2.0,
|
||||
T_sat=1.0,
|
||||
small_staker_multiplier=0.5):
|
||||
small_staker_multiplier=0.5) -> None:
|
||||
"""
|
||||
Calculate parameters to use in token issuer from high-level
|
||||
human-understandable parameters
|
||||
|
|
|
@ -80,7 +80,7 @@ class Miner(NucypherTokenActor):
|
|||
def __init__(self,
|
||||
is_me=True,
|
||||
miner_agent: MinerAgent = None,
|
||||
*args, **kwargs):
|
||||
*args, **kwargs) -> None:
|
||||
|
||||
miner_agent = miner_agent if miner_agent is not None else MinerAgent()
|
||||
super().__init__(token_agent=miner_agent.token_agent, *args, **kwargs)
|
||||
|
@ -261,7 +261,7 @@ class Miner(NucypherTokenActor):
|
|||
class PolicyAuthor(NucypherTokenActor):
|
||||
"""Alice base class for blockchain operations, mocking up new policies!"""
|
||||
|
||||
def __init__(self, checksum_address: str, policy_agent: PolicyAgent = None):
|
||||
def __init__(self, checksum_address: str, policy_agent: PolicyAgent = None) -> None:
|
||||
"""
|
||||
:param policy_agent: A policy agent with the blockchain attached; If not passed, A default policy
|
||||
agent and blockchain connection will be created from default values.
|
||||
|
|
|
@ -103,7 +103,7 @@ class MinerAgent(EthereumContractAgent):
|
|||
class NotEnoughMiners(Exception):
|
||||
pass
|
||||
|
||||
def __init__(self, token_agent: NucypherTokenAgent=None, registry_filepath=None, *args, **kwargs):
|
||||
def __init__(self, token_agent: NucypherTokenAgent=None, registry_filepath=None, *args, **kwargs) -> None:
|
||||
token_agent = token_agent if token_agent is not None else NucypherTokenAgent(registry_filepath=registry_filepath)
|
||||
super().__init__(blockchain=token_agent.blockchain, registry_filepath=registry_filepath, *args, **kwargs)
|
||||
self.token_agent = token_agent
|
||||
|
@ -239,7 +239,7 @@ class PolicyAgent(EthereumContractAgent):
|
|||
def __init__(self,
|
||||
miner_agent: MinerAgent = None,
|
||||
registry_filepath=None,
|
||||
*args, **kwargs):
|
||||
*args, **kwargs) -> None:
|
||||
miner_agent = miner_agent if miner_agent is not None else MinerAgent(registry_filepath=registry_filepath)
|
||||
super().__init__(blockchain=miner_agent.blockchain, registry_filepath=registry_filepath, *args, **kwargs)
|
||||
self.miner_agent = miner_agent
|
||||
|
|
|
@ -20,7 +20,7 @@ class Blockchain:
|
|||
class ConnectionNotEstablished(RuntimeError):
|
||||
pass
|
||||
|
||||
def __init__(self, interface: Union[BlockchainInterface, BlockchainDeployerInterface]=None):
|
||||
def __init__(self, interface: Union[BlockchainInterface, BlockchainDeployerInterface]=None) -> None:
|
||||
|
||||
if interface is None:
|
||||
interface = self.__default_interface_class()
|
||||
|
@ -108,7 +108,7 @@ class TesterBlockchain(Blockchain):
|
|||
__default_num_test_accounts = 10
|
||||
_default_network = 'tester'
|
||||
|
||||
def __init__(self, test_accounts=None, poa=True, airdrop=False, *args, **kwargs):
|
||||
def __init__(self, test_accounts=None, poa=True, airdrop=False, *args, **kwargs) -> None:
|
||||
|
||||
# Depends on circumflex
|
||||
super().__init__(*args, **kwargs)
|
||||
|
|
|
@ -18,7 +18,7 @@ class ContractDeployer:
|
|||
class ContractDeploymentError(Exception):
|
||||
pass
|
||||
|
||||
def __init__(self, blockchain: Blockchain, deployer_address: str):
|
||||
def __init__(self, blockchain: Blockchain, deployer_address: str) -> None:
|
||||
self.__armed = False
|
||||
self._contract = None
|
||||
self.deployment_receipt = None
|
||||
|
@ -158,7 +158,7 @@ class NucypherTokenDeployer(ContractDeployer):
|
|||
agency = NucypherTokenAgent
|
||||
_contract_name = agency.principal_contract_name # TODO
|
||||
|
||||
def __init__(self, blockchain, deployer_address):
|
||||
def __init__(self, blockchain, deployer_address) -> None:
|
||||
if not type(blockchain.interface) is self._interface_class:
|
||||
raise ValueError("{} must be used to create a {}".format(self._interface_class.__name__,
|
||||
self.__class__.__name__))
|
||||
|
@ -377,7 +377,7 @@ class UserEscrowDeployer(ContractDeployer):
|
|||
agency = UserEscrowAgent
|
||||
_contract_name = agency.principal_contract_name
|
||||
|
||||
def __init__(self, miner_escrow_deployer, policy_deployer, *args, **kwargs):
|
||||
def __init__(self, miner_escrow_deployer, policy_deployer, *args, **kwargs) -> None:
|
||||
self.miner_deployer = miner_escrow_deployer
|
||||
self.policy_deployer = policy_deployer
|
||||
self.token_deployer = miner_escrow_deployer.token_deployer
|
||||
|
|
|
@ -329,7 +329,7 @@ class BlockchainInterface:
|
|||
|
||||
class BlockchainDeployerInterface(BlockchainInterface):
|
||||
|
||||
def __init__(self, deployer_address: str=None, *args, **kwargs):
|
||||
def __init__(self, deployer_address: str=None, *args, **kwargs) -> None:
|
||||
|
||||
# Depends on web3 instance
|
||||
super().__init__(*args, **kwargs)
|
||||
|
|
|
@ -27,7 +27,7 @@ class BlockchainArrangement(Arrangement):
|
|||
value: int,
|
||||
lock_periods: int,
|
||||
expiration: maya.MayaDT,
|
||||
*args, **kwargs):
|
||||
*args, **kwargs) -> None:
|
||||
super().__init__(alice=author, ursula=miner, *args, **kwargs)
|
||||
|
||||
delta = expiration - maya.now()
|
||||
|
@ -91,7 +91,7 @@ class BlockchainPolicy(Policy):
|
|||
class NotEnoughBlockchainUrsulas(Exception):
|
||||
pass
|
||||
|
||||
def __init__(self, author: PolicyAuthor, *args, **kwargs):
|
||||
def __init__(self, author: PolicyAuthor, *args, **kwargs) -> None:
|
||||
self.author = author
|
||||
super().__init__(alice=author, *args, **kwargs)
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ class EthereumContractRegistry:
|
|||
class IllegalRegistrar(RegistryError):
|
||||
"""Raised when invalid data is encountered in the registry"""
|
||||
|
||||
def __init__(self, registry_filepath: str=None):
|
||||
def __init__(self, registry_filepath: str=None) -> None:
|
||||
self.__registry_filepath = registry_filepath or self.__default_registry_path
|
||||
|
||||
@classmethod
|
||||
|
@ -120,7 +120,7 @@ class EthereumContractRegistry:
|
|||
|
||||
class TemporaryEthereumContractRegistry(EthereumContractRegistry):
|
||||
|
||||
def __init__(self):
|
||||
def __init__(self) -> None:
|
||||
_, self.temp_filepath = tempfile.mkstemp()
|
||||
super().__init__(registry_filepath=self.temp_filepath)
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ class SolidityCompiler:
|
|||
__default_chain_name = 'tester'
|
||||
|
||||
def __init__(self, solc_binary_path=None, configuration_path=None,
|
||||
chain_name=None, contract_dir=None, test_contract_dir=None):
|
||||
chain_name=None, contract_dir=None, test_contract_dir=None) -> None:
|
||||
|
||||
# Compiler binary and root solidity source code directory
|
||||
self.__sol_binary_path = solc_binary_path if solc_binary_path is not None else self.__default_sol_binary_path
|
||||
|
|
|
@ -680,7 +680,7 @@ class Character:
|
|||
class Alice(Character, PolicyAuthor):
|
||||
_default_crypto_powerups = [SigningPower, EncryptingPower, DelegatingPower]
|
||||
|
||||
def __init__(self, is_me=True, federated_only=False, network_middleware=None, *args, **kwargs):
|
||||
def __init__(self, is_me=True, federated_only=False, network_middleware=None, *args, **kwargs) -> None:
|
||||
|
||||
policy_agent = kwargs.pop("policy_agent", None)
|
||||
checksum_address = kwargs.pop("checksum_address", None)
|
||||
|
@ -787,7 +787,7 @@ class Alice(Character, PolicyAuthor):
|
|||
class Bob(Character):
|
||||
_default_crypto_powerups = [SigningPower, EncryptingPower]
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
def __init__(self, *args, **kwargs) -> None:
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
from nucypher.policy.models import WorkOrderHistory # Need a bigger strategy to avoid circulars.
|
||||
|
|
|
@ -232,7 +232,7 @@ class NucypherKeyring:
|
|||
pub_root_key_path: str=None,
|
||||
signing_key_path: str=None,
|
||||
pub_signing_key_path: str=None,
|
||||
transacting_key_path: str=None):
|
||||
transacting_key_path: str=None) -> None:
|
||||
"""
|
||||
Generates a NuCypherKeyring instance with the provided key paths,
|
||||
falling back to default keyring paths.
|
||||
|
|
|
@ -22,7 +22,7 @@ class CryptoKit:
|
|||
|
||||
class MessageKit(CryptoKit):
|
||||
|
||||
def __init__(self, capsule, sender_pubkey_sig=None, ciphertext=None, signature=constants.NOT_SIGNED):
|
||||
def __init__(self, capsule, sender_pubkey_sig=None, ciphertext=None, signature=constants.NOT_SIGNED) -> None:
|
||||
self.ciphertext = ciphertext
|
||||
self.capsule = capsule
|
||||
self.sender_pubkey_sig = sender_pubkey_sig
|
||||
|
@ -52,7 +52,7 @@ class UmbralMessageKit(MessageKit):
|
|||
return_remainder_when_splitting = True
|
||||
splitter = capsule_splitter + key_splitter
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
def __init__(self, *args, **kwargs) -> None:
|
||||
super().__init__(*args, **kwargs)
|
||||
self.policy_pubkey = None
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ class NoBlockchainPower(PowerUpError):
|
|||
|
||||
|
||||
class CryptoPower(object):
|
||||
def __init__(self, power_ups=None):
|
||||
def __init__(self, power_ups=None) -> None:
|
||||
self._power_ups = {}
|
||||
# TODO: The keys here will actually be IDs for looking up in a KeyStore.
|
||||
self.public_keys = {}
|
||||
|
@ -74,7 +74,7 @@ class BlockchainPower(CryptoPowerUp):
|
|||
"""
|
||||
not_found_error = NoBlockchainPower
|
||||
|
||||
def __init__(self, blockchain: 'Blockchain', account: str):
|
||||
def __init__(self, blockchain: 'Blockchain', account: str) -> None:
|
||||
"""
|
||||
Instantiates a BlockchainPower for the given account id.
|
||||
"""
|
||||
|
@ -196,7 +196,7 @@ class EncryptingPower(KeyPairBasedPower):
|
|||
|
||||
class DelegatingPower(DerivedKeyBasedPower):
|
||||
|
||||
def __init__(self):
|
||||
def __init__(self) -> None:
|
||||
self.umbral_keying_material = UmbralKeyingMaterial()
|
||||
|
||||
def generate_kfrags(self, bob_pubkey_enc, signer, label, m, n) -> Union[UmbralPublicKey, List]:
|
||||
|
|
|
@ -12,7 +12,7 @@ class SignatureStamp(object):
|
|||
key as bytes.
|
||||
"""
|
||||
|
||||
def __init__(self, verifying_key, signer: Signer = None):
|
||||
def __init__(self, verifying_key, signer: Signer = None) -> None:
|
||||
self.__signer = signer
|
||||
self._as_bytes = bytes(verifying_key)
|
||||
self._as_umbral_pubkey = verifying_key
|
||||
|
|
|
@ -8,7 +8,7 @@ from nucypher.keystore.keypairs import SigningKeypair
|
|||
|
||||
class DataSource:
|
||||
|
||||
def __init__(self, policy_pubkey_enc, signing_keypair=NO_SIGNING_POWER, label=None):
|
||||
def __init__(self, policy_pubkey_enc, signing_keypair=NO_SIGNING_POWER, label=None) -> None:
|
||||
self.policy_pubkey = policy_pubkey_enc
|
||||
if signing_keypair is NO_SIGNING_POWER:
|
||||
signing_keypair = SigningKeypair() # TODO: Generate signing key properly. #241
|
||||
|
|
|
@ -18,7 +18,7 @@ class Key(Base):
|
|||
is_signing = Column(Boolean, unique=False)
|
||||
created_at = Column(DateTime, default=datetime.utcnow)
|
||||
|
||||
def __init__(self, fingerprint, key_data, is_signing):
|
||||
def __init__(self, fingerprint, key_data, is_signing) -> None:
|
||||
self.fingerprint = fingerprint
|
||||
self.key_data = key_data
|
||||
self.is_signing = is_signing
|
||||
|
@ -47,7 +47,7 @@ class PolicyArrangement(Base):
|
|||
def __init__(self, expiration, id,
|
||||
k_frag=None, alice_pubkey_sig=None,
|
||||
# alice_pubkey_enc_id, bob_pubkey_sig_id,
|
||||
alice_signature=None):
|
||||
alice_signature=None) -> None:
|
||||
self.expiration = expiration
|
||||
self.id = id
|
||||
self.k_frag = k_frag
|
||||
|
@ -66,7 +66,7 @@ class Workorder(Base):
|
|||
arrangement_id = Column(LargeBinary, unique=False)
|
||||
created_at = Column(DateTime, default=datetime.utcnow)
|
||||
|
||||
def __init__(self, bob_pubkey_sig_id, bob_signature, arrangement_id):
|
||||
def __init__(self, bob_pubkey_sig_id, bob_signature, arrangement_id) -> None:
|
||||
self.bob_pubkey_sig_id = bob_pubkey_sig_id
|
||||
self.bob_signature = bob_signature
|
||||
self.arrangement_id = arrangement_id
|
||||
|
|
|
@ -29,7 +29,7 @@ class Keypair(object):
|
|||
def __init__(self,
|
||||
private_key=None,
|
||||
public_key=None,
|
||||
generate_keys_if_needed=True):
|
||||
generate_keys_if_needed=True) -> None:
|
||||
"""
|
||||
Initalizes a Keypair object with an Umbral key object.
|
||||
:param generate_keys_if_needed: Generate keys or not?
|
||||
|
@ -75,7 +75,7 @@ class EncryptingKeypair(Keypair):
|
|||
A keypair for Umbral
|
||||
"""
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
def __init__(self, *args, **kwargs) -> None:
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
def decrypt(self, message_kit: MessageKit, verifying_key: UmbralPublicKey = None) -> bytes:
|
||||
|
@ -97,7 +97,7 @@ class SigningKeypair(Keypair):
|
|||
A SigningKeypair that uses ECDSA.
|
||||
"""
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
def __init__(self, *args, **kwargs) -> None:
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
def sign(self, message: bytes) -> bytes:
|
||||
|
@ -135,8 +135,8 @@ class HostingKeypair(Keypair):
|
|||
certificate=None,
|
||||
curve=None,
|
||||
generate_keys_if_needed=True,
|
||||
save_cert_to_disk=False,
|
||||
):
|
||||
save_cert_to_disk=False
|
||||
) -> None:
|
||||
|
||||
self.curve = curve or self._DEFAULT_CURVE
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ class KeyStore(object):
|
|||
"""
|
||||
kfrag_splitter = BytestringSplitter(Signature, (KFrag, KFrag.expected_bytes_length()))
|
||||
|
||||
def __init__(self, sqlalchemy_engine=None):
|
||||
def __init__(self, sqlalchemy_engine=None) -> None:
|
||||
"""
|
||||
Initalizes a KeyStore object.
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ from sqlalchemy.orm import sessionmaker, scoped_session
|
|||
|
||||
class ThreadedSession:
|
||||
|
||||
def __init__(self, sqlalchemy_engine):
|
||||
def __init__(self, sqlalchemy_engine) -> None:
|
||||
self.engine = sqlalchemy_engine
|
||||
|
||||
def __enter__(self):
|
||||
|
|
|
@ -15,7 +15,7 @@ class SuspiciousActivity(RuntimeError):
|
|||
|
||||
|
||||
class NucypherHashProtocol(KademliaProtocol):
|
||||
def __init__(self, sourceNode, storage, ksize, *args, **kwargs):
|
||||
def __init__(self, sourceNode, storage, ksize, *args, **kwargs) -> None:
|
||||
super().__init__(sourceNode, storage, ksize, *args, **kwargs)
|
||||
|
||||
self.router = NucypherRoutingTable(self, ksize, sourceNode)
|
||||
|
@ -119,7 +119,7 @@ class NucypherHashProtocol(KademliaProtocol):
|
|||
|
||||
|
||||
class NucypherSeedOnlyProtocol(NucypherHashProtocol):
|
||||
def __init__(self, *args, **kwargs):
|
||||
def __init__(self, *args, **kwargs) -> None:
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
def rpc_store(self, sender, nodeid, key, value):
|
||||
|
@ -134,7 +134,7 @@ class NucypherSeedOnlyProtocol(NucypherHashProtocol):
|
|||
class InterfaceInfo:
|
||||
expected_bytes_length = lambda: VariableLengthBytestring
|
||||
|
||||
def __init__(self, host, port):
|
||||
def __init__(self, host, port) -> None:
|
||||
self.host = host
|
||||
self.port = int(port)
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ class NucypherDHTServer(Server):
|
|||
capabilities = ()
|
||||
digests_set = 0
|
||||
|
||||
def __init__(self, node_storage, treasure_map_storage, federated_only=False, id=None, *args, **kwargs):
|
||||
def __init__(self, node_storage, treasure_map_storage, federated_only=False, id=None, *args, **kwargs) -> None:
|
||||
super().__init__(ksize=20, alpha=3, id=None, storage=None)
|
||||
self.node = kademlia.node.Node(id=id or digest(
|
||||
random.getrandbits(255))) # TODO: Assume that this can be attacked to get closer to desired kFrags.
|
||||
|
@ -92,6 +92,14 @@ class NucypherDHTServer(Server):
|
|||
return await self.set_digest(key, value)
|
||||
|
||||
|
||||
class NucypherSeedOnlyDHTServer(NucypherDHTServer):
|
||||
protocol_class = NucypherSeedOnlyProtocol
|
||||
|
||||
def __init__(self, *args, **kwargs) -> None:
|
||||
super().__init__(*args, **kwargs)
|
||||
self.storage = SeedOnlyStorage()
|
||||
|
||||
|
||||
class ProxyRESTServer:
|
||||
log = getLogger("characters")
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ class Arrangement:
|
|||
(bytes, 27))
|
||||
|
||||
def __init__(self, alice, expiration, ursula=None, id=None,
|
||||
kfrag=constants.UNKNOWN_KFRAG, value=None, alices_signature=None):
|
||||
kfrag=constants.UNKNOWN_KFRAG, value=None, alices_signature=None) -> None:
|
||||
"""
|
||||
:param deposit: Funds which will pay for the timeframe of this Arrangement (not the actual re-encryptions);
|
||||
a portion will be locked for each Ursula that accepts.
|
||||
|
@ -105,7 +105,7 @@ class Policy:
|
|||
"""
|
||||
|
||||
def __init__(self, alice, label, bob=None, kfrags=(constants.UNKNOWN_KFRAG,),
|
||||
public_key=None, m=None, alices_signature=constants.NOT_SIGNED):
|
||||
public_key=None, m=None, alices_signature=constants.NOT_SIGNED) -> None:
|
||||
|
||||
"""
|
||||
:param kfrags: A list of KFrags to distribute per this Policy.
|
||||
|
@ -274,7 +274,7 @@ class Policy:
|
|||
class FederatedPolicy(Policy):
|
||||
_arrangement_class = Arrangement
|
||||
|
||||
def __init__(self, ursulas: Set[Ursula], *args, **kwargs):
|
||||
def __init__(self, ursulas: Set[Ursula], *args, **kwargs) -> None:
|
||||
self.ursulas = ursulas
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
|
@ -321,7 +321,7 @@ class TreasureMap:
|
|||
destinations=None,
|
||||
message_kit=None,
|
||||
public_signature=None,
|
||||
hrac=None):
|
||||
hrac=None) -> None:
|
||||
|
||||
if m is not None:
|
||||
if m > 255:
|
||||
|
@ -447,7 +447,7 @@ class TreasureMap:
|
|||
|
||||
class WorkOrder(object):
|
||||
def __init__(self, bob, arrangement_id, capsules, receipt_bytes,
|
||||
receipt_signature, ursula=None):
|
||||
receipt_signature, ursula=None) -> None:
|
||||
self.bob = bob
|
||||
self.arrangement_id = arrangement_id
|
||||
self.capsules = capsules
|
||||
|
@ -501,7 +501,7 @@ class WorkOrder(object):
|
|||
|
||||
class WorkOrderHistory:
|
||||
|
||||
def __init__(self):
|
||||
def __init__(self) -> None:
|
||||
self.by_ursula = {}
|
||||
|
||||
def __contains__(self, item):
|
||||
|
|
Loading…
Reference in New Issue