Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: bump tomte #543

Merged
merged 13 commits into from
Jan 17, 2023
Merged
30 changes: 15 additions & 15 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ jobs:
sudo apt-get update --fix-missing
sudo apt-get autoremove
sudo apt-get autoclean
pip install tomte[tox]==0.1.5
pip install tomte[tox]==0.2.2
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make ci-requirements.txt and use pip install -r to make version edit easier?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea. Will open a Trello ticket

- name: Security Check
run: tox -e bandit
- name: Safety Check
Expand Down Expand Up @@ -97,7 +97,7 @@ jobs:
sudo apt-get update --fix-missing
sudo apt-get autoremove
sudo apt-get autoclean
pip install tomte[tox]==0.1.5
pip install tomte[tox]==0.2.2
- name: Pylint check
run: |
tox -e pylint
Expand All @@ -118,7 +118,7 @@ jobs:
sudo apt-get update --fix-missing
sudo apt-get autoremove
sudo apt-get autoclean
pip install tomte[tox]==0.1.5
pip install tomte[tox]==0.2.2
pip install --user --upgrade setuptools
# install Protobuf compiler
wget https://github.com/protocolbuffers/protobuf/releases/download/v3.19.4/protoc-3.19.4-linux-x86_64.zip
Expand Down Expand Up @@ -160,7 +160,7 @@ jobs:
sudo apt-get update --fix-missing
sudo apt-get autoremove
sudo apt-get autoclean
pip install tomte[tox]==0.1.5
pip install tomte[tox]==0.2.2
pip install --user --upgrade setuptools
- name: Copyright Check
run: tox -e check-copyright
Expand All @@ -185,7 +185,7 @@ jobs:
sudo apt-get update --fix-missing
sudo apt-get autoremove
sudo apt-get autoclean
pip install tomte[tox]==0.1.5
pip install tomte[tox]==0.2.2
- name: Install markdown-spellcheck
run: sudo npm install -g markdown-spellcheck
- name: Check API Docs updated
Expand Down Expand Up @@ -213,7 +213,7 @@ jobs:
sudo apt-get update --fix-missing
sudo apt-get autoremove
sudo apt-get autoclean
pip install tomte[tox]==0.1.5
pip install tomte[tox]==0.2.2
- name: Check Docs links and IPFS hashes
run: tox -e check-doc-links-hashes

Expand Down Expand Up @@ -247,7 +247,7 @@ jobs:
python-version: ${{ matrix.python_version }}
- name: Install tox
run: |
pip install tomte[tox]==0.1.5
pip install tomte[tox]==0.2.2
- name: Check Pipfile and tox.ini consistency
run: |
python ./scripts/check_pipfile_and_toxini.py
Expand Down Expand Up @@ -277,7 +277,7 @@ jobs:
python-version: ${{ matrix.python_version }}
- name: Install tox
run: |
pip install tomte[tox]==0.1.5
pip install tomte[tox]==0.2.2
- name: Check plugin aea-ledger-cosmos
run: |
tox -r -e plugins_env -- sh -c "pip install ./plugins/aea-ledger-cosmos && aea generate-key cosmos && echo aea-ledger-cosmos checked!"
Expand Down Expand Up @@ -335,7 +335,7 @@ jobs:
sudo apt-get update --fix-missing
sudo apt-get autoremove
sudo apt-get autoclean
pip install tomte[tox]==0.1.5
pip install tomte[tox]==0.2.2
# install Protobuf compiler
wget https://github.com/protocolbuffers/protobuf/releases/download/v3.19.4/protoc-3.19.4-linux-x86_64.zip
unzip protoc-3.19.4-linux-x86_64.zip -d protoc
Expand Down Expand Up @@ -372,7 +372,7 @@ jobs:
sudo apt-get update --fix-missing
sudo apt-get autoremove
sudo apt-get autoclean
pip install tomte[tox]==0.1.5
pip install tomte[tox]==0.2.2
# install Protobuf compiler
wget https://github.com/protocolbuffers/protobuf/releases/download/v3.19.4/protoc-3.19.4-linux-x86_64.zip
unzip protoc-3.19.4-linux-x86_64.zip -d protoc
Expand Down Expand Up @@ -401,7 +401,7 @@ jobs:
sudo apt-get update --fix-missing
sudo apt-get autoremove
sudo apt-get autoclean
pip install tomte[tox]==0.1.5
pip install tomte[tox]==0.2.2
- name: Framework integration tests
run: tox -e py3.10 -- -m 'integration and not unstable and ledger and not profiling'
- name: Packages integration tests
Expand Down Expand Up @@ -436,7 +436,7 @@ jobs:
sudo apt-get update --fix-missing
sudo apt-get autoremove
sudo apt-get autoclean
pip install tomte[tox]==0.1.5
pip install tomte[tox]==0.2.2
# install Protobuf compiler
wget https://github.com/protocolbuffers/protobuf/releases/download/v3.19.4/protoc-3.19.4-linux-x86_64.zip
unzip protoc-3.19.4-linux-x86_64.zip -d protoc
Expand All @@ -456,7 +456,7 @@ jobs:
- if: matrix.os == 'macos-latest'
name: Install dependencies (macos-latest)
run: |
pip install tomte[tox]==0.1.5
pip install tomte[tox]==0.2.2
brew install gcc
# brew install protobuf
# brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/72457f0166d5619a83f508f2345b22d0617b5021/Formula/protobuf.rb
Expand Down Expand Up @@ -485,7 +485,7 @@ jobs:
choco install make -y
# to check make was installed
make --version
pip install tomte[tox]==0.1.5
pip install tomte[tox]==0.2.2
# wget https://github.com/protocolbuffers/protobuf/releases/download/v3.19.4/protoc-3.19.4-win64.zip
# unzip protoc-3.19.4-win64.zip -d protoc
# sudo mv protoc/bin/protoc /usr/local/bin/protoc
Expand All @@ -512,7 +512,7 @@ jobs:
- if: matrix.os == 'ubuntu-latest' && matrix.python_version == '3.10'
name: Show full coverage report
run: |
pip install tomte[tests]==0.1.5
pip install tomte[tests]==0.2.2
coverage report -m -i

- if: matrix.os == 'ubuntu-latest' && matrix.python_version == '3.10'
Expand Down
2 changes: 1 addition & 1 deletion Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ py-multicodec = ">=0.2.0"
google-api-python-client = "<=2.60.0"
certifi = "<=2022.6.15.1"
mistune = "==2.0.3"
tomte = {version = "==0.1.5", extras = ["tox", "tests"]}
tomte = {version = "==0.2.2", extras = ["tox", "tests"]}

[packages]
# we don't specify dependencies for the library here for intallation as per: https://pipenv-fork.readthedocs.io/en/latest/advanced.html#pipfile-vs-setuppy
Expand Down
8 changes: 4 additions & 4 deletions aea/agent_loop.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
# ------------------------------------------------------------------------------
#
# Copyright 2022 Valory AG
# Copyright 2022-2023 Valory AG
# Copyright 2018-2021 Fetch.AI Limited
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -187,7 +187,7 @@ class AsyncAgentLoop(BaseAgentLoop):
def __init__(
self,
agent: AbstractAgent,
loop: AbstractEventLoop = None,
loop: Optional[AbstractEventLoop] = None,
threaded: bool = False,
) -> None:
"""
Expand Down Expand Up @@ -295,9 +295,9 @@ def _execution_control(
if self.agent.exception_handler(e, fn) is True:
self._state.set(AgentLoopStates.error)
raise
except Exception as e:
except Exception as e_:
self._state.set(AgentLoopStates.error)
self._exceptions.append(e)
self._exceptions.append(e_)
raise

def _register_periodic_task(
Expand Down
4 changes: 2 additions & 2 deletions aea/cli/fetch.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
# ------------------------------------------------------------------------------
#
# Copyright 2022 Valory AG
# Copyright 2022-2023 Valory AG
# Copyright 2018-2021 Fetch.AI Limited
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -20,7 +20,7 @@
"""Implementation of the 'aea fetch' subcommand."""
import os
import shutil
from distutils.dir_util import copy_tree
from distutils.dir_util import copy_tree # pylint: disable=deprecated-module

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't we use shutil.copytree here?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably

from pathlib import Path
from typing import Optional, Union, cast

Expand Down
6 changes: 3 additions & 3 deletions aea/cli/remove.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
# ------------------------------------------------------------------------------
#
# Copyright 2021-2022 Valory AG
# Copyright 2021-2023 Valory AG
# Copyright 2018-2019 Fetch.AI Limited
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -178,7 +178,7 @@ def _get_item_requirements(
:yield: package ids: (type, public_id)
"""
for item_type in map(str, ComponentType):
items = getattr(item, f"{item_type}s", set())
items: Set[PublicId] = getattr(item, f"{item_type}s", set())
for item_public_id in items:
if ignore_non_vendor and is_item_present(
self._ctx.cwd,
Expand Down Expand Up @@ -372,7 +372,7 @@ def remove(self) -> None:
@property
def agent_items(self) -> Set[PublicId]:
"""Return items registered with agent of the same type as item."""
return getattr(self.agent_config, self.item_type_plural, set)
return getattr(self.agent_config, self.item_type_plural, set())
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

found a bug


@property
def is_required_by(self) -> bool:
Expand Down
4 changes: 2 additions & 2 deletions aea/cli/utils/config.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
# ------------------------------------------------------------------------------
#
# Copyright 2021-2022 Valory AG
# Copyright 2021-2023 Valory AG
# Copyright 2018-2020 Fetch.AI Limited
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -69,7 +69,7 @@


def try_to_load_agent_config(
ctx: Context, is_exit_on_except: bool = True, agent_src_path: str = None
ctx: Context, is_exit_on_except: bool = True, agent_src_path: Optional[str] = None
) -> None:
"""
Load agent config to a click context object.
Expand Down
4 changes: 3 additions & 1 deletion aea/cli/utils/package_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -885,7 +885,9 @@ def list_available_packages(
ComponentType.CONTRACT,
ComponentType.SKILL,
):
components = getattr(agent_config, component_type.to_plural(), set())
components: Set[PublicId] = getattr(
agent_config, component_type.to_plural(), set()
)
for public_id in components:
package_path = Path(
get_package_path(
Expand Down
5 changes: 3 additions & 2 deletions aea/configurations/base.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
# ------------------------------------------------------------------------------
#
# Copyright 2021-2022 Valory AG
# Copyright 2021-2023 Valory AG
# Copyright 2018-2019 Fetch.AI Limited
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -19,7 +19,7 @@
# ------------------------------------------------------------------------------
"""Classes to handle AEA configurations."""
import pprint
from abc import ABC
from abc import ABC, abstractmethod
from collections import OrderedDict
from copy import copy, deepcopy
from operator import attrgetter
Expand Down Expand Up @@ -167,6 +167,7 @@ def __init__(self) -> None:
self._key_order: List[str] = []

@classmethod
@abstractmethod
def from_json(cls, obj: Dict) -> "Configuration":
"""Build from a JSON object."""

Expand Down
1 change: 1 addition & 0 deletions aea/configurations/data_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ def json(self) -> Dict:
"""Compute the JSON representation."""

@classmethod
@abstractmethod
def from_json(cls, obj: Dict) -> "JSONSerializable":
"""Build from a JSON object."""

Expand Down
10 changes: 6 additions & 4 deletions aea/configurations/utils.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
# ------------------------------------------------------------------------------
#
# Copyright 2022 Valory AG
# Copyright 2022-2023 Valory AG
# Copyright 2018-2021 Fetch.AI Limited
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -107,8 +107,8 @@ def _(
component_id.component_type,
replacements_by_type[component_id.public_id],
)
old_value = arg.component_configurations.pop(component_id)
arg.component_configurations[new_component_id] = old_value
old_value_ = arg.component_configurations.pop(component_id)
arg.component_configurations[new_component_id] = old_value_


@replace_component_ids.register(ProtocolConfig) # type: ignore
Expand Down Expand Up @@ -180,7 +180,9 @@ def _replace_component_id(
:param replacements: the replacements.
"""
for component_type in types_to_update:
public_id_set = getattr(config, component_type.to_plural(), set())
public_id_set: Set[PublicId] = getattr(
config, component_type.to_plural(), set()
)
replacements_given_type = replacements.get(component_type, {})
for old_public_id in list(public_id_set):
new_public_id = replacements_given_type.get(old_public_id, old_public_id)
Expand Down
14 changes: 9 additions & 5 deletions aea/helpers/async_utils.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
# ------------------------------------------------------------------------------
#
# Copyright 2022 Valory AG
# Copyright 2022-2023 Valory AG
# Copyright 2018-2021 Fetch.AI Limited
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -33,6 +33,7 @@
Awaitable,
Callable,
Container,
Coroutine,
Generator,
List,
Optional,
Expand Down Expand Up @@ -255,7 +256,7 @@ class AnotherThreadTask:
Provides better cancel behaviour: on cancel it will wait till cancelled completely.
"""

def __init__(self, coro: Awaitable, loop: AbstractEventLoop) -> None:
def __init__(self, coro: Coroutine, loop: AbstractEventLoop) -> None:
"""
Init the task.

Expand Down Expand Up @@ -325,7 +326,7 @@ def run(self) -> None:
self._loop.run_forever()
_default_logger.debug("Asyncio loop has been stopped.")

def call(self, coro: Awaitable) -> Any:
def call(self, coro: Coroutine) -> Any:
"""
Run a coroutine inside the event loop.

Expand Down Expand Up @@ -364,7 +365,7 @@ class Runnable(ABC):
"""

def __init__(
self, loop: asyncio.AbstractEventLoop = None, threaded: bool = False
self, loop: Optional[asyncio.AbstractEventLoop] = None, threaded: bool = False
) -> None:
"""
Init runnable.
Expand Down Expand Up @@ -472,7 +473,10 @@ async def run(self) -> Any:
"""Implement run logic respectful to CancelError on termination."""

def wait_completed(
self, sync: bool = False, timeout: float = None, force_result: bool = False
self,
sync: bool = False,
timeout: Optional[float] = None,
force_result: bool = False,
) -> Awaitable:
"""
Wait runnable execution completed.
Expand Down
4 changes: 3 additions & 1 deletion aea/helpers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,9 @@ def get_logger_method(fn: Callable, logger_method: Union[str, Callable]) -> Call


def try_decorator(
error_message: str, default_return: Callable = None, logger_method: Any = "error"
error_message: str,
default_return: Optional[Callable] = None,
logger_method: Any = "error",
) -> Callable:
"""
Run function, log and return default value on exception.
Expand Down
Loading