Skip to content

Commit

Permalink
Merge pull request #179 from valory-xyz/chore/bump-black
Browse files Browse the repository at this point in the history
Bump black to stable version
  • Loading branch information
DavidMinarsch authored Jun 9, 2022
2 parents 00d7717 + a889152 commit 5a71708
Show file tree
Hide file tree
Showing 288 changed files with 3,251 additions and 1,331 deletions.
4 changes: 2 additions & 2 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ aiohttp = "==3.7.4.post0"
asn1crypto = "==1.4.0"
bandit = "==1.7.0"
bech32 = "==1.2.0"
black = "==19.10b0"
black = "==22.1.0"
bs4 = "==0.0.1"
click = "==8.0.4"
click = "==8.0.2"
darglint = "==1.8.0"
defusedxml = "==0.6.0"
docker = "==4.2.0"
Expand Down
8 changes: 6 additions & 2 deletions aea/aea.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,8 @@ def __init__(
self._connection_exception_policy = connection_exception_policy

aea_logger = AgentLoggerAdapter(
logger=get_logger(__name__, identity.name), agent_name=identity.name,
logger=get_logger(__name__, identity.name),
agent_name=identity.name,
)

self._resources = resources
Expand Down Expand Up @@ -408,7 +409,10 @@ def get_message_handlers(self) -> List[Tuple[Callable[[Any], None], Callable]]:
:return: List of tuples of callables: handler and coroutine to get a message
"""
return super().get_message_handlers() + [
(self.filter.handle_internal_message, self.filter.get_internal_message,),
(
self.filter.handle_internal_message,
self.filter.get_internal_message,
),
(self.handle_envelope, self.runtime.agent_loop.skill2skill_queue.get),
]

Expand Down
32 changes: 23 additions & 9 deletions aea/aea_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,9 @@ def _load_decision_maker_handler_class(

return _class

def _load_error_handler_class(self,) -> Optional[Type[AbstractErrorHandler]]:
def _load_error_handler_class(
self,
) -> Optional[Type[AbstractErrorHandler]]:
"""
Load error handler class.
Expand Down Expand Up @@ -1096,7 +1098,9 @@ def get_build_root_directory(self) -> str:

@classmethod
def run_build_for_component_configuration(
cls, config: ComponentConfiguration, logger: Optional[logging.Logger] = None,
cls,
config: ComponentConfiguration,
logger: Optional[logging.Logger] = None,
) -> None:
"""Run a build entrypoint script for component configuration."""
if not config.build_entrypoint:
Expand Down Expand Up @@ -1242,7 +1246,8 @@ def _build_identity_from_wallet(self, wallet: Wallet) -> Identity:
return identity

def _process_connection_ids( # pylint: disable=unsubscriptable-object
self, connection_ids: Optional[Collection[PublicId]] = None,
self,
connection_ids: Optional[Collection[PublicId]] = None,
) -> List[PublicId]:
"""
Process connection ids.
Expand Down Expand Up @@ -1423,15 +1428,19 @@ def _get_max_reactions(self) -> int:
else self.DEFAULT_MAX_REACTIONS
)

def _get_error_handler_class(self,) -> Optional[Type]:
def _get_error_handler_class(
self,
) -> Optional[Type]:
"""
Return the error handler class.
:return: error handler class
"""
return self._error_handler_class

def _get_error_handler_config(self,) -> Optional[Dict[str, Any]]:
def _get_error_handler_config(
self,
) -> Optional[Dict[str, Any]]:
"""
Return the error handler config.
Expand All @@ -1449,7 +1458,9 @@ def _get_decision_maker_handler_class(
"""
return self._decision_maker_handler_class

def _get_decision_maker_handler_config(self,) -> Optional[Dict[str, Any]]:
def _get_decision_maker_handler_config(
self,
) -> Optional[Dict[str, Any]]:
"""
Return the decision maker handler config.
Expand Down Expand Up @@ -1683,10 +1694,12 @@ def _check_valid_entrypoint(build_entrypoint: str, directory: str) -> None:
build_entrypoint = cast(str, build_entrypoint)
script_path = Path(directory) / build_entrypoint
enforce(
script_path.exists(), f"File '{build_entrypoint}' does not exists.",
script_path.exists(),
f"File '{build_entrypoint}' does not exists.",
)
enforce(
script_path.is_file(), f"'{build_entrypoint}' is not a file.",
script_path.is_file(),
f"'{build_entrypoint}' is not a file.",
)
try:
ast.parse(script_path.read_text())
Expand Down Expand Up @@ -2021,7 +2034,8 @@ def _preliminary_checks_before_build(self) -> None:


def make_component_logger(
configuration: ComponentConfiguration, agent_name: str,
configuration: ComponentConfiguration,
agent_name: str,
) -> Optional[logging.Logger]:
"""
Make the logger for a component.
Expand Down
5 changes: 4 additions & 1 deletion aea/agent_loop.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,10 @@ def send_to_skill(
elif isinstance(message_or_envelope, Message):
message = message_or_envelope
envelope = Envelope(
to=message.to, sender=message.sender, message=message, context=context,
to=message.to,
sender=message.sender,
message=message,
context=context,
)
else:
raise ValueError(
Expand Down
10 changes: 8 additions & 2 deletions aea/cli/add.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,10 @@ def fetch_item_remote(
click.echo("Will try with http repository.")

return fetch_package(
item_type, public_id=item_public_id, cwd=ctx.cwd, dest=dest_path,
item_type,
public_id=item_public_id,
cwd=ctx.cwd,
dest=dest_path,
)


Expand All @@ -241,7 +244,10 @@ def find_item_locally_or_distributed(


def fetch_item_mixed(
ctx: Context, item_type: str, item_public_id: PublicId, dest_path: str,
ctx: Context,
item_type: str,
item_public_id: PublicId,
dest_path: str,
) -> Path:
"""
Find item, mixed mode.That is, give priority to local registry, and fall back to remote registry in case of failure.
Expand Down
5 changes: 4 additions & 1 deletion aea/cli/add_key.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@
required=True,
)
@click.argument(
"file", metavar="FILE", type=key_file_argument, required=False,
"file",
metavar="FILE",
type=key_file_argument,
required=False,
)
@password_option()
@click.option(
Expand Down
3 changes: 2 additions & 1 deletion aea/cli/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ def build_aea(skip_consistency_check: bool) -> None:
"""
try:
builder = AEABuilder.from_aea_project(
Path("."), skip_consistency_check=skip_consistency_check,
Path("."),
skip_consistency_check=skip_consistency_check,
)
builder.call_all_build_entrypoints()
except Exception as e:
Expand Down
6 changes: 5 additions & 1 deletion aea/cli/check_packages.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,11 @@ def __init__(
class EmptyPackageDescription(Exception):
"""Custom exception for empty description field."""

def __init__(self, configuration_file: Path, *args: Any,) -> None:
def __init__(
self,
configuration_file: Path,
*args: Any,
) -> None:
"""
Initialize EmptyPackageDescription exception.
Expand Down
5 changes: 4 additions & 1 deletion aea/cli/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,10 @@ def create(

@clean_after
def create_aea(
ctx: Context, agent_name: str, author: Optional[str] = None, empty: bool = False,
ctx: Context,
agent_name: str,
author: Optional[str] = None,
empty: bool = False,
) -> None:
"""
Create AEA project.
Expand Down
4 changes: 3 additions & 1 deletion aea/cli/delete.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@

@click.command()
@click.argument(
"agent_name", type=AgentDirectory(), required=True,
"agent_name",
type=AgentDirectory(),
required=True,
)
@click.pass_context
def delete(click_context: click.Context, agent_name: str) -> None:
Expand Down
5 changes: 4 additions & 1 deletion aea/cli/fetch.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,10 @@
@click.command(name="fetch")
@registry_flag()
@click.option(
"--alias", type=str, required=False, help="Provide a local alias for the agent.",
"--alias",
type=str,
required=False,
help="Provide a local alias for the agent.",
)
@click.argument("public-id", type=PublicIdParameter(), required=True)
@click.pass_context
Expand Down
4 changes: 3 additions & 1 deletion aea/cli/fingerprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@

@click.group(invoke_without_command=True)
@click.pass_context
def fingerprint(click_context: click.core.Context,) -> None:
def fingerprint(
click_context: click.core.Context,
) -> None:
"""Fingerprint a non-vendor package of the agent."""
if click_context.invoked_subcommand is None:
fingerprint_agent(click_context)
Expand Down
20 changes: 16 additions & 4 deletions aea/cli/generate_all_protocols.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,12 @@ def run_isort_and_black(directory: Path, **kwargs: Any) -> None:
raise click.ClickException(str(e)) from e

AEAProject.run_cli(
sys.executable, "-m", "black", "-q", str(directory.absolute()), **kwargs,
sys.executable,
"-m",
"black",
"-q",
str(directory.absolute()),
**kwargs,
)
AEAProject.run_cli(
sys.executable,
Expand Down Expand Up @@ -183,7 +188,9 @@ def _fingerprint_protocol(name: str) -> None:
"""Fingerprint the generated (and modified) protocol."""
log(f"Fingerprint the generated (and modified) protocol '{name}'")
protocol_config = load_component_configuration(
ComponentType.PROTOCOL, Path(PROTOCOLS, name), skip_consistency_check=True,
ComponentType.PROTOCOL,
Path(PROTOCOLS, name),
skip_consistency_check=True,
)
AEAProject.run_aea("fingerprint", "protocol", str(protocol_config.public_id))

Expand Down Expand Up @@ -430,7 +437,9 @@ def _process_packages_protocol(
default=Path(".").resolve(),
)
@click.option(
"--check-clean", is_flag=True, help="Check if git tree is clean..",
"--check-clean",
is_flag=True,
help="Check if git tree is clean..",
)
def generate_all_protocols(
packages_dir: Path,
Expand All @@ -454,7 +463,10 @@ def generate_all_protocols(
if not no_bump:
_bump_protocol_specification_id_if_needed(package_path)
_process_packages_protocol(
package_path, no_bump, no_format, root_dir,
package_path,
no_bump,
no_format,
root_dir,
)

if check_clean:
Expand Down
11 changes: 8 additions & 3 deletions aea/cli/generate_key.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
# ------------------------------------------------------------------------------
#
# Copyright 2021 Valory AG
# Copyright 2021-2022 Valory AG
# Copyright 2018-2020 Fetch.AI Limited
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -46,13 +46,18 @@
)
@password_option(confirmation_prompt=True)
@click.option(
"--add-key", is_flag=True, help="Add key generated.",
"--add-key",
is_flag=True,
help="Add key generated.",
)
@click.option(
"--connection", is_flag=True, help="For adding a private key for connections."
)
@click.option(
"--extra-entropy", type=str, required=False, default="",
"--extra-entropy",
type=str,
required=False,
default="",
)
@click.pass_context
def generate_key(
Expand Down
24 changes: 20 additions & 4 deletions aea/cli/get_multiaddress.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,32 @@
@password_option()
@click.option("-c", "--connection", is_flag=True)
@click.option(
"-i", "--connection-id", type=PublicIdParameter(), required=False, default=None,
"-i",
"--connection-id",
type=PublicIdParameter(),
required=False,
default=None,
)
@click.option(
"-h", "--host-field", type=str, required=False, default=None,
"-h",
"--host-field",
type=str,
required=False,
default=None,
)
@click.option(
"-p", "--port-field", type=str, required=False, default=None,
"-p",
"--port-field",
type=str,
required=False,
default=None,
)
@click.option(
"-u", "--uri-field", type=str, required=False, default="public_uri",
"-u",
"--uri-field",
type=str,
required=False,
default="public_uri",
)
@click.pass_context
@check_aea_project
Expand Down
9 changes: 7 additions & 2 deletions aea/cli/ipfs_hash.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,9 @@ def hash_package(
raise ValueError("configuration.directory cannot be None.")

key = os.path.join(
configuration.author, package_type.to_plural(), configuration.directory.name,
configuration.author,
package_type.to_plural(),
configuration.directory.name,
)
package_hash = IPFSHashOnly.hash_directory(
str(configuration.directory), wrap=(not no_wrap)
Expand Down Expand Up @@ -342,7 +344,10 @@ def hash_group() -> None:
@click.option("--no-wrap", is_flag=True)
@click.option("--check", is_flag=True)
def generate_all(
packages_dir: Path, vendor: Optional[str], no_wrap: bool, check: bool,
packages_dir: Path,
vendor: Optional[str],
no_wrap: bool,
check: bool,
) -> None:
"""Generate IPFS hashes."""
packages_dir = Path(packages_dir).absolute()
Expand Down
3 changes: 2 additions & 1 deletion aea/cli/issue_certificates.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ def issue_certificates(
"""Issue certificates for connections that require them."""
ctx = cast(Context, click_context.obj)
agent_config_manager = AgentConfigManager.load(
ctx.cwd, substitude_env_vars=apply_environment_variables,
ctx.cwd,
substitude_env_vars=apply_environment_variables,
)
issue_certificates_(ctx.cwd, agent_config_manager, password=password)

Expand Down
Loading

0 comments on commit 5a71708

Please sign in to comment.