diff --git a/.github/workflows/main_workflow.yml b/.github/workflows/main_workflow.yml index e282a2c..5d87a5e 100644 --- a/.github/workflows/main_workflow.yml +++ b/.github/workflows/main_workflow.yml @@ -57,14 +57,16 @@ jobs: sudo apt-get update --fix-missing sudo apt-get autoremove sudo apt-get autoclean - pip install tomte[tox]==0.2.4 + pip install tomte[tox,cli]==0.2.12 pip install --upgrade setuptools==60.10.0 - name: Check copyright headers - run: tox -e check-copyright + run: tomte check-copyright --author balancer - name: License compatibility check run: tox -e liccheck - - name: Check doc links and IPFS hashes - run: tox -e check-doc-links-hashes + - name: Check doc links + run: tomte check-doc-links + - name: Check doc IPFS hashes + run: tox -e check-doc-hashes linter_checks: continue-on-error: False @@ -87,7 +89,7 @@ jobs: sudo apt-get update --fix-missing sudo apt-get autoremove sudo apt-get autoclean - pip install tomte[tox]==0.2.4 + pip install tomte[tox,cli]==0.2.12 pip install --upgrade setuptools==60.10.0 # install Protobuf compiler wget https://github.com/protocolbuffers/protobuf/releases/download/v3.11.4/protoc-3.11.4-linux-x86_64.zip @@ -101,27 +103,17 @@ jobs: sudo mv go-ipfs/ipfs /usr/local/bin/ipfs ipfs init - name: Security checks - run: | - tox -e bandit - tox -e safety + run: tomte check-security - name: Check packages run: tox -e check-packages - name: Check FSM Spec run: tox -e check-abciapp-specs - name: Check hash run: tox -e check-hash - - name: Code style check - run: | - tox -e black-check - tox -e isort-check - tox -e flake8 - tox -e darglint - - name: Static type check - run: tox -e mypy - - name: Pylint - run: tox -e pylint + - name: Code checks + run: tomte check-code - name: Check spelling - run: tox -e spell-check + run: tomte check-spelling scan: name: gitleaks @@ -169,7 +161,7 @@ jobs: sudo apt-get update --fix-missing sudo apt-get autoremove sudo apt-get autoclean - pip install tomte[tox]==0.2.4 + pip install tomte[tox]==0.2.12 pip install --upgrade setuptools==60.10.0 # install Protobuf compiler @@ -202,7 +194,7 @@ jobs: - if: matrix.os == 'macos-latest' name: Install dependencies (macos-latest) run: | - pip install tomte[tox]==0.2.4 + pip install tomte[tox]==0.2.12 brew install gcc # brew install protobuf # brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/72457f0166d5619a83f508f2345b22d0617b5021/Formula/protobuf.rb @@ -239,7 +231,7 @@ jobs: choco install make -y # to check make was installed make --version - pip install tomte[tox]==0.2.4 + pip install tomte[tox]==0.2.12 # 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 @@ -288,7 +280,7 @@ jobs: sudo apt-get update --fix-missing sudo apt-get autoremove sudo apt-get autoclean - pip install tomte[tox]==0.2.4 + pip install tomte[tox]==0.2.12 pip install --upgrade setuptools==60.10.0 # install Protobuf compiler diff --git a/HISTORY.md b/HISTORY.md index 2de8eba..fc047cc 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,5 +1,8 @@ # Release History - `Autonomous Fund` +## (TBD) +- Bumps to `tomte@v0.2.12` and cleans up the repo #107 + ## 0.6.3 (2023-05-29) - Bumps `open-aea` and `open-autonomy` frameworks to `v1.34.0` and `v0.10.5.post1` correspondingly #106 diff --git a/Makefile b/Makefile index 3d051f3..83413dc 100644 --- a/Makefile +++ b/Makefile @@ -42,8 +42,7 @@ clean-test: # black: format files according to the pep standards .PHONY: formatters formatters: - tox -e isort - tox -e black + tomte format-code # black-check: check code style # isort-check: check for import order @@ -53,13 +52,14 @@ formatters: # darglint: docstring linter .PHONY: code-checks code-checks: - tox -p -e black-check -e isort-check -e flake8 -e mypy -e pylint -e darglint + tomte check-code # safety: checks dependencies for known security vulnerabilities # bandit: security linter .PHONY: security security: - tox -p -e safety -e bandit + tomte check-security + gitleaks detect --report-format json --report-path leak_report # generate latest abci docstrings # generate latest hashes for updated packages @@ -67,13 +67,15 @@ security: .PHONY: generators generators: tox -e abci-docstrings - tox -e fix-copyright + tomte format-copyright --author balancer autonomy hash all autonomy packages lock .PHONY: common-checks-1 common-checks-1: - tox -p -e check-copyright -e check-hash -e check-packages + tomte check-copyright --author balancer + tomte check-doc-links + tox -p -e check-hash -e check-packages -e check-doc-hashes .PHONY: test test: diff --git a/Pipfile b/Pipfile index 62f4046..d4c560d 100644 --- a/Pipfile +++ b/Pipfile @@ -28,7 +28,7 @@ open-aea-ledger-cosmos = "==1.34.0" open-aea-cli-ipfs = "==1.34.0" open-aea-test-autonomy = "==0.10.5.post1" open-autonomy = {version = "==0.10.5.post1", extras = ["all"]} -tomte = {version = "==0.2.4", extras = ["tox", "tests"]} +tomte = {version = "==0.2.12", extras = ["cli", "tests"]} [requires] python_version = "3.10" diff --git a/docs/index.md b/docs/index.md index b09e4aa..1075f7d 100644 --- a/docs/index.md +++ b/docs/index.md @@ -26,7 +26,7 @@ In order to run a local demo based on the SMPKit: 2. Fetch the Smart Managed Pools service. ```bash - autonomy fetch balancer/autonomous_fund_goerli:0.1.0:bafybeia2jxoqj3l7oxuazitlingy5wzat6qacvzfsdslgow7a4sswm22ue --service + autonomy fetch balancer/autonomous_fund_goerli:0.1.0:bafybeievjazzdjqv47z5jt3iaw423bqdgbe3tc5dzulwlokyx6v47zdpea --service ``` 3. Build the Docker image of the service agents diff --git a/liccheck.ini b/liccheck.ini deleted file mode 100644 index 91bc90d..0000000 --- a/liccheck.ini +++ /dev/null @@ -1,106 +0,0 @@ -; some useful links: -; - https://janelia-flyem.github.io/licenses.html -; - https://dwheeler.com/essays/floss-license-slide.html - -; Authorized and unauthorized licenses in LOWER CASE -[Licenses] -authorized_licenses: - ; aliases for MIT License - MIT - MIT license - https://opensource.org/licenses/MIT - License :: OSI Approved :: MIT - - ; aliases for BSD License (and variants) - BSD - BSD license - new BSD - (new) BSD - new BDS license - simplified BSD - 3-Clause BSD - BSD-3-Clause - BSD 3-Clause - BSD-2-Clause - BSD-like - BSD-2-Clause or Apache-2.0 - BSD, Public Domain - - ; Apache - Apache Software - - ; aliases for Apache License version 2.0 - Apache 2.0 - Apache-2.0 - Apache License 2.0 - Apache License, Version 2.0 - Apache License Version 2.0 - Apache2 - ASL 2 -; some packages use 'Apache Software' as license string, -; which is ambiguous. However, 'Apache Software' -; will likely match with 'Apache 2.0' - Apache Software - BSD, Public Domain, Apache - http://www.apache.org/licenses/LICENSE-2.0 - -; PSF (BSD-style) - Python Software Foundation - PSF - - ; other permissive licenses - Historical Permission Notice and Disclaimer (HPND) - HPND - ISC - BSD or Apache License, Version 2.0 - Modified BSD - Expat - Public Domain - -unauthorized_licenses: -; aliases for MPL 2.0 - MPL-2.0 - MPL 2.0 - Mozilla Public License 2.0 (MPL 2.0) - -; Section 8 of https://www.mozilla.org/en-US/MPL/2.0/Revision-FAQ/ - MPL 1.1 - MPL-1.1 - -; http://www.gnu.org/licenses/license-list.en.html#apache2 - GPLv2 - GPLv2+ - GNU General Public License v2 or later (GPLv2+) - -; LGPL - LGPL - GNU Library or Lesser General Public License (LGPL) - -; LGPLv2.1 - LGPLv2.1 - LGPLv2.1+ - GNU Lesser General Public License v2 or later (LGPLv2+) - -; LGPLv3 - GNU Lesser General Public License v3 (LGPLv3) - LGPLv3 - -; GPL v3 - GPL v3 - GPLv3+ - GNU General Public License v3 (GPLv3) - -[Authorized Packages] -gym: >=0.15 -;filelock is public domain -filelock: >=3.0.12 -fetchai-ledger-api: >=0.0.1 -chardet: >=3.0.4 -certifi: >=2019.11.28 -;TODO: the following are confilctive packages that need to be sorted -; sub-dep of open-aea-ledger-ethereum-hwi -hidapi: >=0.13.1 -; shows in pip freesze but not referenced on code -paramiko: >=3.1.0 -; sub-dep of docker-compose -websocket-client: >=0.59.0 diff --git a/packages/balancer/agents/autonomous_fund/aea-config.yaml b/packages/balancer/agents/autonomous_fund/aea-config.yaml index d28dd68..e78bca3 100644 --- a/packages/balancer/agents/autonomous_fund/aea-config.yaml +++ b/packages/balancer/agents/autonomous_fund/aea-config.yaml @@ -31,8 +31,8 @@ protocols: - open_aea/signing:1.0.0:bafybeibqlfmikg5hk4phzak6gqzhpkt6akckx7xppbp53mvwt6r73h7tk4 - valory/ipfs:0.1.0:bafybeic72ncgqbzoz2guj4p4yjqulid7mv6yroeh65hxznloamoveeg7hq skills: -- balancer/autonomous_fund_abci:0.1.0:bafybeicbx53zdczmnio3hyrjnaytyacczimxx3oopqnhkxx3ywfbe3b3k4 -- balancer/fear_and_greed_oracle_abci:0.1.0:bafybeiao62xpueyq3bw4ftnyfol7ck3hucfmxkqlc5rng72tdvgqwrrtbe +- balancer/autonomous_fund_abci:0.1.0:bafybeihcfyfkquwq7fenkzecsv7alv6wmpxn4ix3t4rvzszh5xfolpiety +- balancer/fear_and_greed_oracle_abci:0.1.0:bafybeidfvohetnouyglawqodc7tho5ibw7nkqcg2723mzwhl5ul34geu6y - balancer/liquidity_provision_abci:0.1.0:bafybeigqec62rvlcpel4t63nxf6ilbukdnz257qzcyuwnf62253hsllydq - balancer/pool_manager_abci:0.1.0:bafybeico4qp7yb27kgmnv4yqxhkt7lq7zimuqojglheyrgzgg36zhrqijq - valory/abstract_abci:0.1.0:bafybeigte2l4en4otdp2maaoc3uesqdga5z4sqozrybsmcdp26bgfbcy54 diff --git a/packages/balancer/services/autonomous_fund/service.yaml b/packages/balancer/services/autonomous_fund/service.yaml index 8c3719d..f5da952 100644 --- a/packages/balancer/services/autonomous_fund/service.yaml +++ b/packages/balancer/services/autonomous_fund/service.yaml @@ -7,7 +7,7 @@ license: Apache-2.0 fingerprint: README.md: bafybeibfahh3htjez7vf7lwx2s7tth26cwxgtalgn5hj7yg7akhk67f4ny fingerprint_ignore_patterns: [] -agent: balancer/autonomous_fund:0.1.0:bafybeiauemik3nihzvtdw346oiw53koyzxmfprdkbrbccs7chlijbwmaoe +agent: balancer/autonomous_fund:0.1.0:bafybeifxkk5jzw5esvvmdcz632ur2w3hhf4syimjdg7qeleevg5n62isjy number_of_agents: 4 deployment: {} --- diff --git a/packages/balancer/services/autonomous_fund_goerli/service.yaml b/packages/balancer/services/autonomous_fund_goerli/service.yaml index df19a17..bb75362 100644 --- a/packages/balancer/services/autonomous_fund_goerli/service.yaml +++ b/packages/balancer/services/autonomous_fund_goerli/service.yaml @@ -7,7 +7,7 @@ license: Apache-2.0 fingerprint: README.md: bafybeie36flrik7sho37ynqzv7vc4thd5daw7h3af6fvi4o467fddbwgte fingerprint_ignore_patterns: [] -agent: balancer/autonomous_fund:0.1.0:bafybeiauemik3nihzvtdw346oiw53koyzxmfprdkbrbccs7chlijbwmaoe +agent: balancer/autonomous_fund:0.1.0:bafybeifxkk5jzw5esvvmdcz632ur2w3hhf4syimjdg7qeleevg5n62isjy number_of_agents: 4 deployment: {} --- diff --git a/packages/balancer/skills/autonomous_fund_abci/skill.yaml b/packages/balancer/skills/autonomous_fund_abci/skill.yaml index e4beab4..d870429 100644 --- a/packages/balancer/skills/autonomous_fund_abci/skill.yaml +++ b/packages/balancer/skills/autonomous_fund_abci/skill.yaml @@ -25,7 +25,7 @@ connections: [] contracts: [] protocols: [] skills: -- balancer/fear_and_greed_oracle_abci:0.1.0:bafybeiao62xpueyq3bw4ftnyfol7ck3hucfmxkqlc5rng72tdvgqwrrtbe +- balancer/fear_and_greed_oracle_abci:0.1.0:bafybeidfvohetnouyglawqodc7tho5ibw7nkqcg2723mzwhl5ul34geu6y - balancer/liquidity_provision_abci:0.1.0:bafybeigqec62rvlcpel4t63nxf6ilbukdnz257qzcyuwnf62253hsllydq - balancer/pool_manager_abci:0.1.0:bafybeico4qp7yb27kgmnv4yqxhkt7lq7zimuqojglheyrgzgg36zhrqijq - valory/abstract_round_abci:0.1.0:bafybeigsbglflua5vdwmwmo2rjsogp4anxtpqjbtrcwfivuxjiv6xczpba diff --git a/packages/balancer/skills/fear_and_greed_oracle_abci/behaviours.py b/packages/balancer/skills/fear_and_greed_oracle_abci/behaviours.py index a241451..6748242 100644 --- a/packages/balancer/skills/fear_and_greed_oracle_abci/behaviours.py +++ b/packages/balancer/skills/fear_and_greed_oracle_abci/behaviours.py @@ -329,8 +329,8 @@ def _is_in_allowed_range(self, most_voted_estimates: Dict) -> bool: if not status: self.context.logger.warning( f"The estimated values are outside of the allowed limits. " - f'min allowed value is "{self.params.min_index_value}", ' - f'max allowed value is "{self.params.max_index_value}", ' + f"min allowed value is {self.params.min_index_value!r}, " + f"max allowed value is {self.params.max_index_value!r}, " f"the last two values are: {[values[0], values[1]]}." ) return status @@ -349,8 +349,8 @@ def _is_not_aggressive_change(self, most_voted_estimates: Dict) -> bool: status = change <= self.params.max_index_change if not status: self.context.logger.warning( - f'The change is too aggressive. The max allowed change is "{self.params.max_index_change}", ' - f'the current change is "{change}".' + f"The change is too aggressive. The max allowed change is {self.params.max_index_change!r}, " + f"the current change is {change!r}." ) return status diff --git a/packages/balancer/skills/fear_and_greed_oracle_abci/skill.yaml b/packages/balancer/skills/fear_and_greed_oracle_abci/skill.yaml index c6f2dca..d706edf 100644 --- a/packages/balancer/skills/fear_and_greed_oracle_abci/skill.yaml +++ b/packages/balancer/skills/fear_and_greed_oracle_abci/skill.yaml @@ -7,7 +7,7 @@ license: Apache-2.0 aea_version: '>=1.0.0, <2.0.0' fingerprint: __init__.py: bafybeibbvllj3mw4xbmnpbhat6hngbmdijpbxe464ekrg5kkhzbyoa4exe - behaviours.py: bafybeih6wxgupvr4exxvemijucfixw7zzqw2etjxb5irxwjg25hu5jnyhq + behaviours.py: bafybeigchzsthpug54fp2jsudwg5evfyic6reatnu3ymxve3tyy66ufcfe dialogues.py: bafybeiffd2prpsv5uk4xxr2qixgpbgy2flonh2etz2fdtnojj2mrey4qty fsm_specification.yaml: bafybeie4a2veb7scm7upgydyq2xroie3uj7ikbkiagc56y2eilmoiwqohm handlers.py: bafybeia3xdhc2ffeqlk6n2krffvxvb6x2kq2eb2xzdazyqwamyzcluwrxa diff --git a/packages/packages.json b/packages/packages.json index b085989..97896c0 100644 --- a/packages/packages.json +++ b/packages/packages.json @@ -1,12 +1,12 @@ { "dev": { - "agent/balancer/autonomous_fund/0.1.0": "bafybeiauemik3nihzvtdw346oiw53koyzxmfprdkbrbccs7chlijbwmaoe", - "skill/balancer/autonomous_fund_abci/0.1.0": "bafybeicbx53zdczmnio3hyrjnaytyacczimxx3oopqnhkxx3ywfbe3b3k4", + "agent/balancer/autonomous_fund/0.1.0": "bafybeifxkk5jzw5esvvmdcz632ur2w3hhf4syimjdg7qeleevg5n62isjy", + "skill/balancer/autonomous_fund_abci/0.1.0": "bafybeihcfyfkquwq7fenkzecsv7alv6wmpxn4ix3t4rvzszh5xfolpiety", "skill/balancer/pool_manager_abci/0.1.0": "bafybeico4qp7yb27kgmnv4yqxhkt7lq7zimuqojglheyrgzgg36zhrqijq", - "skill/balancer/fear_and_greed_oracle_abci/0.1.0": "bafybeiao62xpueyq3bw4ftnyfol7ck3hucfmxkqlc5rng72tdvgqwrrtbe", + "skill/balancer/fear_and_greed_oracle_abci/0.1.0": "bafybeidfvohetnouyglawqodc7tho5ibw7nkqcg2723mzwhl5ul34geu6y", "contract/balancer/managed_pool/0.1.0": "bafybeiethywywvvqxqhs4u3urj6gqp5qcw25gemyomg6mc3qfl47n326rq", - "service/balancer/autonomous_fund_goerli/0.1.0": "bafybeia2jxoqj3l7oxuazitlingy5wzat6qacvzfsdslgow7a4sswm22ue", - "service/balancer/autonomous_fund/0.1.0": "bafybeieslmzxicczsjaclewgwwialnvupvpzan7vyfzcqlvswckrmeuoke", + "service/balancer/autonomous_fund_goerli/0.1.0": "bafybeievjazzdjqv47z5jt3iaw423bqdgbe3tc5dzulwlokyx6v47zdpea", + "service/balancer/autonomous_fund/0.1.0": "bafybeib4oszvjn4cvxugaae4w6honupp74jbuzuzgn47lvn463chn5532y", "skill/balancer/liquidity_provision_abci/0.1.0": "bafybeigqec62rvlcpel4t63nxf6ilbukdnz257qzcyuwnf62253hsllydq" }, "third_party": { diff --git a/pytest.ini b/pytest.ini deleted file mode 100644 index 56f93cb..0000000 --- a/pytest.ini +++ /dev/null @@ -1,13 +0,0 @@ -[pytest] -log_cli = 1 -log_cli_level = DEBUG -log_cli_format = %(asctime)s [%(levelname)8s] %(message)s (%(filename)s:%(lineno)s) -log_cli_date_format=%Y-%m-%d %H:%M:%S -asyncio_mode=strict - -markers = - integration: marks integration tests which require other network services - e2e: marks end-to-end agent tests - -filterwarnings = - ignore::DeprecationWarning:aea.*: diff --git a/scripts/check_copyright.py b/scripts/check_copyright.py deleted file mode 100755 index dc43c47..0000000 --- a/scripts/check_copyright.py +++ /dev/null @@ -1,346 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- -# ------------------------------------------------------------------------------ -# -# Copyright 2021-2023 Valory AG -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# ------------------------------------------------------------------------------ - -""" -This script checks that all the Python files of the repository have the copyright notice. - -In particular: -- (optional) the Python shebang -- the encoding header; -- the copyright and license notices; - -It is assumed the script is run from the repository root. -""" - -import argparse -import itertools -import re -import shutil -import subprocess # nosec -import sys -from datetime import datetime -from pathlib import Path -from typing import Dict, Iterator, Optional, Tuple, cast - - -CURRENT_YEAR = datetime.now().year -GIT_PATH = shutil.which("git") -START_YEARS = (2021, 2022, 2023) -SHEBANG = "#!/usr/bin/env python3" -HEADER_REGEX = re.compile( - r"""(#!/usr/bin/env python3 -)?# -\*- coding: utf-8 -\*- -# ------------------------------------------------------------------------------ -# -# Copyright ((20\d\d)(-20\d\d)?) Valory AG -# -# Licensed under the Apache License, Version 2\.0 \(the \"License\"\); -# you may not use this file except in compliance with the License\. -# You may obtain a copy of the License at -# -# http://www\.apache\.org/licenses/LICENSE-2\.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an \"AS IS\" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied\. -# See the License for the specific language governing permissions and -# limitations under the License\. -# -# ------------------------------------------------------------------------------ -""", - re.MULTILINE, -) -HEADER_TEMPLATE = """# -*- coding: utf-8 -*- -# ------------------------------------------------------------------------------ -# -{copyright_string} -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# ------------------------------------------------------------------------------ -""" - - -class ErrorTypes: # pylint: disable=too-few-public-methods - """Types of corrupt headers.""" - - NO_ERROR = 0 - START_YEAR_NOT_ALLOWED = 1 - START_YEAR_GT_END_YEAR = 2 - END_YEAR_WRONG = 3 - END_YEAR_MISSING = 4 - - -def get_modification_date(file: Path) -> datetime: - """Returns modification date for the file.""" - ( - date_string, - _, - ) = subprocess.Popen( # nosec # pylint: disable=consider-using-with - [str(GIT_PATH), "log", "-1", '--format="%ad"', "--", str(file)], - stdout=subprocess.PIPE, - ).communicate() - date_string_ = date_string.decode().strip() - if date_string_ == "": - return datetime.now() - return datetime.strptime(date_string_, '"%a %b %d %X %Y %z"') - - -def get_year_data(match: re.Match) -> Tuple[int, Optional[int]]: - """Get year data from match.""" - _, year_string, *_ = match.groups() - if "-" in year_string: - return (*map(int, year_string.split("-")),) # type: ignore - return int(year_string), None - - -def _validate_years( - file: Path, - allowed_start_years: Tuple[int, ...], - start_year: int, - end_year: int, - check_end_year: bool = True, -) -> Dict: - """ - Given a file, check if the header stuff is in place. - - Return True if the files has the encoding header and the copyright notice, - optionally prefixed by the shebang. Return False otherwise. - - :param file: the file to check. - :param allowed_start_years: list of allowed start years - :param start_year: year when the file was created - :param end_year: year when the file was last modified - :param check_end_year: whether to validate end year or not - :return: True if the file is compliant with the checks, False otherwise. - """ - - modification_date = get_modification_date(file) - check_info = { - "check": True, - "message": f"Start year {start_year} is not in the list of allowed years; {allowed_start_years}.", - "start_year": start_year, - "end_year": end_year, - "last_modification": modification_date, - "error_code": ErrorTypes.NO_ERROR, - } - - # Start year is not in allowed start years list - if start_year not in allowed_start_years: - check_info["check"] = False - check_info[ - "message" - ] = f"Start year {start_year} is not in the list of allowed years; {allowed_start_years}." - check_info["error_code"] = ErrorTypes.START_YEAR_NOT_ALLOWED - return check_info - - # Specified year is 2021 but the file has been last modified in another later year (missing -202x) - if end_year is not None and check_end_year: - - if start_year > end_year: - check_info["check"] = False - check_info["message"] = "End year should be greater then start year." - check_info["error_code"] = ErrorTypes.START_YEAR_GT_END_YEAR - return check_info - - if end_year != modification_date.year: - check_info["check"] = False - check_info[ - "message" - ] = f"End year does not match the last modification year. Header has: {end_year}; Last Modified: {modification_date.year}" - check_info["error_code"] = ErrorTypes.END_YEAR_WRONG - return check_info - - if end_year is None and modification_date.year > start_year: - check_info["check"] = False - check_info["message"] = f"Missing later year ({start_year}-20..)" - check_info["error_code"] = ErrorTypes.END_YEAR_MISSING - return check_info - - return check_info - - -def fix_header(check_info: Dict) -> bool: - """Fix currupt headers.""" - - path = cast(Path, check_info.get("path")) - content = path.read_text() - copyright_string = "" - is_update_needed = False - - if "error_code" not in check_info: - is_update_needed = False - elif check_info["error_code"] in ( - ErrorTypes.END_YEAR_WRONG, - ErrorTypes.END_YEAR_MISSING, - ): - copyright_string = "# Copyright {start_year}-{end_year} Valory AG".format( - start_year=check_info["start_year"], - end_year=check_info["last_modification"].year, - ) - is_update_needed = True - - elif check_info["error_code"] == ErrorTypes.START_YEAR_GT_END_YEAR: - copyright_string = "# Copyright {end_year}-{start_year} Valory AG".format( - start_year=check_info["start_year"], - end_year=check_info["last_modification"].year, - ) - is_update_needed = True - - if is_update_needed: - new_header = HEADER_TEMPLATE.format(copyright_string=copyright_string) - if SHEBANG in content: - new_header = SHEBANG + "\n" + new_header - updated_content = HEADER_REGEX.sub(new_header, content) - path.write_text(updated_content) - - return is_update_needed - - -def update_headers(files: Iterator[Path]) -> None: - """Update headers.""" - - needs_update = [] - - for path in files: - print("Checking {}".format(path)) - check_data = check_copyright(path) - if not check_data["check"]: - check_data["path"] = path - needs_update.append(check_data) - - if len(needs_update) > 0: - print("\n\nUpdating headers.\n") - cannot_update = [] - for check_data in needs_update: - print("Updating {}".format(check_data["path"])) - if not fix_header(check_data): - cannot_update.append(check_data) - - if len(cannot_update) > 0: - print("\nFollowing files were not updated.\n") - print("\n".join([str(check_data["path"]) for check_data in cannot_update])) - else: - print("No update needed.") - - -def check_copyright(file: Path) -> Dict: - """ - Given a file, check if the header stuff is in place. - - Return True if the files has the encoding header and the copyright notice, - optionally prefixed by the shebang. Return False otherwise. - - :param file: the file to check. - :return: True if the file is compliant with the checks, False otherwise. - """ - content = file.read_text() - match = HEADER_REGEX.match(content) - if match is not None: - return _validate_years(file, START_YEARS, *get_year_data(match)) # type: ignore - - return {"check": False, "message": "Invalid copyright header."} - - -def run_check(files: Iterator[Path]) -> None: - """Run copyright check.""" - bad_files = set() - for path in files: - print("Processing {}".format(path)) - check_data = check_copyright(path) - if not check_data["check"]: - bad_files.add((path, check_data["message"])) - - if len(bad_files) > 0: - print("The following files are not well formatted:") - print( - "\n".join( - map( - lambda x: f"File: {x[0]}\nReason: {x[1]}\n", - sorted(bad_files, key=lambda x: x[0]), - ) - ) - ) - sys.exit(1) - else: - print("OK") - sys.exit(0) - - -def get_args() -> argparse.Namespace: - """Get CLI arguments.""" - - argparser = argparse.ArgumentParser() - argparser.add_argument("--check", action="store_true") - return argparser.parse_args() - - -def main() -> None: - """Main function.""" - - args = get_args() - - exclude_files = {Path("scripts", "whitelist.py")} - python_files = filter( - lambda x: x not in exclude_files, - itertools.chain( - Path("packages", "balancer").glob("**/*.py"), - Path("tests").glob("**/*.py"), - Path("scripts").glob("**/*.py"), - ), - ) - - def _file_filter(file: Path) -> bool: - """Filter for files.""" - file_str = str(file) - - # protocols are generated using generate_all_protocols.py - return ( - not file_str.endswith("_pb2.py") - and not file_str.endswith("_pb2_grpc.py") - and ( - ( - "protocols" not in file.parts - and "t_protocol" not in file.parts - and "t_protocol_no_ct" not in file.parts - and "build" not in file.parts - ) - ) - ) - - python_files_filtered = filter(_file_filter, python_files) - if args.check: - run_check(python_files_filtered) - else: - update_headers(python_files_filtered) - - -if __name__ == "__main__": - main() diff --git a/scripts/check_doc_ipfs_hashes.py b/scripts/check_doc_ipfs_hashes.py index f7258c6..574b254 100755 --- a/scripts/check_doc_ipfs_hashes.py +++ b/scripts/check_doc_ipfs_hashes.py @@ -168,7 +168,7 @@ def get_hash_by_package_line( # No match if not m_command and not m_package: print( - f"[{target_file}]: line '{package_line}' does not match an autonomy/aea command or package format" + f"[{target_file}]: line {package_line!r} does not match an autonomy/aea command or package format" ) return None m = m_command or m_package @@ -185,7 +185,7 @@ def get_hash_by_package_line( # This hash does not exist in packages.json print( - f"[{target_file}]: unknown IPFS hash in line '{package_line}'. Can't fix because this command just uses the hash" + f"[{target_file}]: unknown IPFS hash in line {package_line!r}. Can't fix because this command just uses the hash" ) return None @@ -220,7 +220,7 @@ def get_hash_by_package_line( if not package_type: raise ValueError( - f"[{target_file}]: could not infer the package type for line '{package_line}'\nPlease update the hash manually." + f"[{target_file}]: could not infer the package type for line {package_line!r}\nPlease update the hash manually." ) return self.package_tree[d["vendor"]][package_type][d["package"]].hash @@ -228,7 +228,7 @@ def get_hash_by_package_line( # Otherwise log the error except KeyError: print( - f"[{target_file}]: could not find the corresponding hash for line '{package_line}'" + f"[{target_file}]: could not find the corresponding hash for line {package_line!r}" ) return None diff --git a/scripts/check_doc_links.py b/scripts/check_doc_links.py deleted file mode 100755 index f5ea0f0..0000000 --- a/scripts/check_doc_links.py +++ /dev/null @@ -1,205 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- -# ------------------------------------------------------------------------------ -# -# Copyright 2022-2023 Valory AG -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# ------------------------------------------------------------------------------ - -"""This module contains the tests for the links in the documentation.""" - - -import re -import sys -from concurrent.futures import ThreadPoolExecutor -from itertools import chain -from pathlib import Path -from typing import Any, Dict, List, Optional - -import requests -import urllib3 # type: ignore -from requests.adapters import HTTPAdapter # type: ignore -from requests.packages.urllib3.util.retry import ( # type: ignore # pylint: disable=import-error - Retry, -) - - -# Disable insecure request warning (expired SSL certificates) -urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) - - -MAX_WORKERS = 10 -URL_REGEX = r'(https?:\/\/(?:www\.|(?!www))[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s)"]{2,}|www\.[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s)"]{2,}|https?:\/\/(?:www\.|(?!www))[a-zA-Z0-9]+\.[^\s)"]{2,}|www\.[a-zA-Z0-9]+\.[^\s)"]{2,})' -DEFAULT_REQUEST_TIMEOUT = 5 # seconds - -# Allow some links to be HTTP because there is no HTTPS alternative -# Remove non-url-allowed characters like ` before adding them here -HTTP_SKIPS = [ - "http://www.fipa.org/repository/ips.php3", - "http://host.docker.internal:8545", -] - -# Special links that are allowed to respond with an error status -# Remove non-url-allowed characters like ` before adding them here -URL_SKIPS = [ - "https://gateway.autonolas.tech/ipfs/,", # non link (400) - "https://github.com/valory-xyz/open-autonomy/trunk/infrastructure", # svn link (404) - "http://host.docker.internal:8545", # internal (ERR_NAME_NOT_RESOLVED) -] - -# Define here custom timeouts for some edge cases -CUSTOM_TIMEOUTS = { - "http://www.fipa.org/repository/ips.php3": 30, -} - - -def read_file(filepath: str) -> str: - """Loads a file into a string""" - with open(filepath, "r", encoding="utf-8") as file_: - file_str = file_.read() - return file_str - - -def check_file( - session: Any, - md_file: str, - http_skips: Optional[List[str]] = None, - url_skips: Optional[List[str]] = None, -) -> Dict: - """Check for broken or HTTP links in a specific file""" - - http_skips = http_skips or HTTP_SKIPS - url_skips = url_skips or URL_SKIPS - - text = read_file(md_file) - m = re.findall(URL_REGEX, text) - http_links = [] - broken_links = [] - - for url in m: - - # Add the closing parenthesis if it is missing, as the REGEX is too strict sometimes - if "(" in url and ")" not in url: - url += ")" - - # Remove non allowed chars - url = url.replace("`", "") - - # Check for HTTP urls - if not url.startswith("https") and url not in http_skips: - http_links.append((md_file, url)) - - # Check for url skips - if url in url_skips: - continue - - # Check for broken links: 200 and 403 codes are admitted - try: - # Do not verify requests. Expired SSL certificates would make those links fail - status_code = session.get( - url, - timeout=CUSTOM_TIMEOUTS.get(url, DEFAULT_REQUEST_TIMEOUT), - verify=False, - ).status_code - if status_code not in [200, 403]: - broken_links.append({"url": url, "status_code": status_code}) - except ( - requests.exceptions.RetryError, - requests.exceptions.ConnectionError, - ) as e: - broken_links.append({"url": url, "status_code": e}) - - return { - "file": str(md_file), - "http_links": http_links, - "broken_links": broken_links, - } - - -def main() -> None: # pylint: disable=too-many-locals - """Check for broken or HTTP links""" - all_md_files = [ - str(p.relative_to(".")) - for p in chain( - Path("docs").rglob("*.md"), - Path("packages").rglob("*.md"), - Path(".").glob("*.md"), - ) - ] - - broken_links: Dict[str, Dict] = {} - http_links: Dict[str, List[str]] = {} - - # Configure request retries - retry_strategy = Retry( - total=3, # number of retries - status_forcelist=[404, 429, 500, 502, 503, 504], # codes to retry on - ) - # https://stackoverflow.com/questions/18466079/change-the-connection-pool-size-for-pythons-requests-module-when-in-threading - adapter = HTTPAdapter( - max_retries=retry_strategy, pool_connections=100, pool_maxsize=100 - ) - session = requests.Session() - session.mount("https://", adapter) - session.mount("http://", adapter) - - # Run all file checks in a thread pool - with ThreadPoolExecutor(max_workers=MAX_WORKERS) as executor: - futures = [] - for md_file in all_md_files: - print(f"Checking {str(md_file)}...") - futures.append(executor.submit(check_file, session, md_file)) - - # Awaiting for results is blocking - print("Awaiting for results...") - future_results = [future.result() for future in futures] - - # Get errors - for i in future_results: - if i["http_links"]: - http_links[i["file"]] = i["http_links"] - if i["broken_links"]: - broken_links[i["file"]] = i["broken_links"] - - # Check errors - if broken_links: - broken_links_str = "\n".join( - [ - f"{file_name}: {[entry['url'] + ', status: ' + str(entry['status_code']) for entry in error_data]}" - for file_name, error_data in broken_links.items() - ] - ) - print(f"Found broken url in the docs:\n{broken_links_str}") - - if http_links: - http_links_str = "\n".join( - [ - f"{file_name}: {[url[1] for url in urls]}" - for file_name, urls in http_links.items() - ] - ) - print( - f"Found HTTP urls in the docs:\n{http_links_str}\nTry to use HTTPS equivalent urls or add them to 'http_skips' if not possible" - ) - - if broken_links or http_links: - sys.exit(1) - - print("OK") - sys.exit(0) - - -if __name__ == "__main__": - main() diff --git a/scripts/freeze_dependencies.py b/scripts/freeze_dependencies.py deleted file mode 100755 index dc9c8dd..0000000 --- a/scripts/freeze_dependencies.py +++ /dev/null @@ -1,45 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- -# ------------------------------------------------------------------------------ -# -# Copyright 2021-2023 Valory AG -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# ------------------------------------------------------------------------------ - -"""This CLI tool freezes the dependencies.""" -import argparse -import subprocess # nosec - - -def parse_args() -> argparse.Namespace: - """Parse CLI arguments.""" - parser = argparse.ArgumentParser("freeze_dependencies") - parser.add_argument("-o", "--output", type=argparse.FileType("w"), default=None) - return parser.parse_args() - - -if __name__ == "__main__": - arguments = parse_args() - - pip_freeze_call = subprocess.Popen( # nosec # pylint: disable=consider-using-with - ["pip", "freeze"], stdout=subprocess.PIPE - ) - (stdout, stderr) = pip_freeze_call.communicate() - requirements = stdout.decode("utf-8") - - if arguments.output is None: - print(requirements) - else: - arguments.output.write(requirements) diff --git a/scripts/spell-check.sh b/scripts/spell-check.sh deleted file mode 100755 index 1187b17..0000000 --- a/scripts/spell-check.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash -# This script requires `mdspell`: -# -# https://www.npmjs.com/package/markdown-spellcheck -# -# Run this script from the root directory. -# Usage: -# ./scripts/spell-check.sh -# - -MDSPELL_PATH="$(which mdspell)" -if [ -z "${MDSPELL_PATH}" ]; then - echo "Cannot find executable 'mdspell'. Please install it to run this script: npm i markdown-spellcheck -g" - exit 127 -else - echo "Found 'mdspell' executable at ${MDSPELL_PATH}" - mdspell -r -n -a --en-gb '**/*.md' '!docker-images/*.md' '!docs/api/**/*.md' '!third_party/**/*.md' '!go-ipfs/**/*.md' '!docs/package_list.md' -fi diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index d2918f1..0000000 --- a/setup.cfg +++ /dev/null @@ -1,98 +0,0 @@ -[flake8] -paths=packages -exclude=.md, - *_pb2.py, - *_pb2_grpc.py, - custom_types.py, - -max-line-length = 88 -select = B,C,D,E,F,I,W, -ignore = E203,E501,W503,D202,B014,D400,D401,DAR,B028 -application-import-names = packages,tests,scripts - -# ignore as too restrictive for our needs: -# D400: First line should end with a period -# D401: First line should be in imperative mood -# E501: https://www.flake8rules.com/rules/E501.html (Line too long) -# E203: https://www.flake8rules.com/rules/E203.html (Whitespace) -# W503: https://www.flake8rules.com/rules/W503.html (Line break) -# D202: blank lines -# B014: redundant exception - -[isort] -# for black compatibility -multi_line_output=3 -include_trailing_comma=True -force_grid_wrap=0 -use_parentheses=True -ensure_newline_before_comments = True -line_length=88 -# custom configurations -order_by_type=False -case_sensitive=True -lines_after_imports=2 -skip=packages/valory/skills/abstract_round_abci/test_tools/integration.py,packages/valory/skills/transaction_settlement_abci/test_tools/integration.py, -skip_glob = -known_first_party=autonomy -known_packages=packages -known_local_folder=tests -sections=FUTURE,STDLIB,THIRDPARTY,FIRSTPARTY,PACKAGES,LOCALFOLDER - -[mypy] -python_version = 3.8 -strict_optional = True -exclude=(.*_pb2|.*custom_types) - -# Before adding a module here, make sure it does not support type hints -# Per-module options for aea dir: - -[mypy-packages.valory.*] -ignore_errors=True - -[mypy-packages.open_aea.*] -ignore_errors=True - -[mypy-aea_ledger_ethereum.*] -ignore_missing_imports=True - -[mypy-ipfshttpclient.*] -ignore_missing_imports = True - -[mypy-pytest] -ignore_missing_imports = True - -[mypy-hypothesis.*] -ignore_missing_imports = True - -[mypy-docker.*] -ignore_missing_imports = True - -[mypy-certifi.*] -ignore_missing_imports = True - -[mypy-aea_cli_ipfs.*] -ignore_missing_imports = True - -[mypy-py_eth_sig_utils.*] -ignore_missing_imports = True - -[mypy-aea.*] -ignore_missing_imports = True - -[mypy-web3.*] -ignore_missing_imports = True - -[mypy-requests] -ignore_missing_imports=True - -[mypy-aea_test_autonomy.*] -ignore_missing_imports=True - -[mypy-yaml] -ignore_missing_imports=True - -[darglint] -docstring_style=sphinx -strictness=short -ignore_regex=async_act -ignore=DAR401 diff --git a/tests/__init__.py b/tests/__init__.py deleted file mode 100644 index 6a4c5f2..0000000 --- a/tests/__init__.py +++ /dev/null @@ -1,20 +0,0 @@ -# -*- coding: utf-8 -*- -# ------------------------------------------------------------------------------ -# -# Copyright 2021-2022 Valory AG -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# ------------------------------------------------------------------------------ - -"""Tests package.""" diff --git a/tox.ini b/tox.ini index 52170df..811c546 100644 --- a/tox.ini +++ b/tox.ini @@ -6,7 +6,7 @@ ; we set the associated flag (e.g. for linting we don't need ; the package installation). [tox] -envlist = bandit, safety, black, black-check, isort, isort-check, fix-copyright, check-copyright, check-hash, check-packages, flake8, mypy, pylint, darglint, check-generate-all-protocols, abci-docstrings, check-abciapp-specs, py{3.7,3.8,3.9,3.10.9}-{win,linux,darwin} +envlist = bandit, safety, black, black-check, isort, isort-check, check-hash, check-packages, flake8, mypy, pylint, darglint, check-generate-all-protocols, abci-docstrings, check-abciapp-specs, py{3.7,3.8,3.9,3.10.9}-{win,linux,darwin} ; when running locally we don't want to fail for no good reason skip_missing_interpreters = true @@ -37,10 +37,11 @@ deps = open-autonomy==0.10.5.post1 setenv = PYTHONHASHSEED=0 + PACKAGES_PATHS = packages/balancer commands = autonomy init --reset --author ci --remote --ipfs --ipfs-node "/dns/registry.autonolas.tech/tcp/443/https" autonomy packages sync - pytest -rfE --doctest-modules packages/balancer/ --cov=packages --cov-report=xml --cov-report=term --cov-report=term-missing --cov-config=.coveragerc {posargs} + pytest -rfE --doctest-modules {env:PACKAGES_PATHS} --cov=packages --cov-report=xml --cov-report=term --cov-report=term-missing --cov-config=.coveragerc {posargs} [testenv:py3.7-linux] basepython = python3.7 @@ -154,53 +155,37 @@ setenv = skipsdist = True skip_install = True deps = - tomte[bandit]==0.2.4 + tomte[bandit]==0.2.12 commands = bandit -s B101 -r packages bandit -s B101 -r tests scripts [testenv:black] skipsdist = True skip_install = True -deps = - tomte[black]==0.2.4 -commands = black packages/balancer scripts tests +deps = tomte[black]==0.2.12 +commands = black {env:PACKAGES_PATHS} scripts [testenv:black-check] skipsdist = True skip_install = True -deps = - tomte[black]==0.2.4 -commands = black --check packages/balancer scripts tests +deps = tomte[black]==0.2.12 +commands = black --check {env:PACKAGES_PATHS} scripts [testenv:isort] skipsdist = True skip_install = True -deps = tomte[isort]==0.2.4 +deps = tomte[isort]==0.2.12 commands = - isort packages/balancer/ + isort {env:PACKAGES_PATHS} --gitignore isort scripts/ - isort tests/ [testenv:isort-check] skipsdist = True skip_install = True -deps = tomte[isort]==0.2.4 +deps = tomte[isort]==0.2.12 commands = - isort --check-only packages/balancer + isort --check-only {env:PACKAGES_PATHS} isort --check-only scripts/ - isort --check-only tests/ - -[testenv:fix-copyright] -skipsdist = True -skip_install = True -deps = -commands = {toxinidir}/scripts/check_copyright.py - -[testenv:check-copyright] -skipsdist = True -skip_install = True -deps = -commands = {toxinidir}/scripts/check_copyright.py --check [testenv:check-hash] skipsdist = True @@ -222,48 +207,45 @@ commands = skipsdist = True skip_install = True deps = - tomte[flake8]==0.2.4 -commands = flake8 packages/balancer scripts tests + tomte[flake8]==0.2.12 +commands = flake8 {env:PACKAGES_PATHS} scripts [testenv:mypy] skipsdist = True skip_install = True deps = {[testenv]deps} - tomte[mypy]==0.2.4 -commands = autonomy init --reset --author ci --remote --ipfs --ipfs-node "/dns/registry.autonolas.tech/tcp/443/https" - autonomy packages sync - mypy packages/balancer scripts --disallow-untyped-defs - mypy tests --disallow-untyped-defs + tomte[mypy]==0.2.12 +commands = mypy {env:PACKAGES_PATHS} scripts --disallow-untyped-defs --config-file tox.ini [testenv:pylint] whitelist_externals = /bin/sh skipsdist = True deps = {[testenv]deps} - tomte[pylint]==0.2.4 -commands = pylint packages/balancer scripts + tomte[pylint]==0.2.12 +commands = pylint --ignore-patterns=".*_pb2.py" --ignore-paths="^packages/valory/.*$" --disable=C0103,R0801,R0912,C0301,C0201,C0204,C0209,W1203,C0302,R1735,R1729,W0511 {env:PACKAGES_PATHS} scripts [testenv:safety] skipsdist = True skip_install = True deps = - tomte[safety]==0.2.4 + tomte[safety]==0.2.12 commands = safety check -i 37524 -i 38038 -i 37776 -i 38039 -i 39621 -i 40291 -i 39706 -i 41002 -i 51358 -i 51499 [testenv:darglint] skipsdist = True skip_install = True deps = - tomte[darglint]==0.2.4 -commands = darglint scripts packages/balancer/* tests + tomte[darglint]==0.2.12 +commands = darglint scripts {env:PACKAGES_PATHS}/* [testenv:check-generate-all-protocols] skipsdist = True usedevelop = True deps = - tomte[isort]==0.2.4 - tomte[black]==0.2.4 + tomte[isort]==0.2.12 + tomte[black]==0.2.12 commands = aea generate-all-protocols --check-clean [testenv:abci-docstrings] @@ -278,33 +260,272 @@ commands = autonomy init --reset --author ci --remote --ipfs --ipfs-node "/dns/ autonomy packages sync autonomy analyse fsm-specs -[testenv:check-doc-links-hashes] +[testenv:check-doc-hashes] skipsdist = True skip_install = True commands = aea init --reset --author ci --remote --ipfs --ipfs-node "/dns/registry.autonolas.tech/tcp/443/https" aea packages sync - {toxinidir}/scripts/check_doc_links.py {toxinidir}/scripts/check_doc_ipfs_hashes.py [testenv:fix-doc-hashes] skipsdist = True skip_install = True -commands = - {toxinidir}/scripts/check_doc_ipfs_hashes.py --fix +commands = {toxinidir}/scripts/check_doc_ipfs_hashes.py --fix [testenv:spell-check] whitelist_externals = mdspell skipsdist = True usedevelop = True deps = -commands = - {toxinidir}/scripts/spell-check.sh +commands = tomte check-spelling [testenv:liccheck] skipsdist = True usedevelop = True deps = - tomte[liccheck]==0.2.4 -commands = {toxinidir}/scripts/freeze_dependencies.py -o {envtmpdir}/requirements.txt - liccheck -s liccheck.ini -r {envtmpdir}/requirements.txt -l PARANOID \ No newline at end of file + tomte[liccheck,cli]==0.2.12 +commands = + tomte freeze-dependencies --output-path {envtmpdir}/requirements.txt + liccheck -s tox.ini -r {envtmpdir}/requirements.txt -l PARANOID + +[flake8] +paths=packages +exclude=.md, + *_pb2.py, + *_pb2_grpc.py, + custom_types.py, + packages/valory + +max-line-length = 88 +select = B,C,D,E,F,I,W, +ignore = E203,E501,W503,D202,B014,D400,D401,DAR +application-import-names = packages,tests,scripts + +# ignore as too restrictive for our needs: +# D400: First line should end with a period +# D401: First line should be in imperative mood +# E501: https://www.flake8rules.com/rules/E501.html (Line too long) +# E203: https://www.flake8rules.com/rules/E203.html (Whitespace) +# W503: https://www.flake8rules.com/rules/W503.html (Line break) +# D202: blank lines +# B014: redundant exception + +[isort] +# for black compatibility +multi_line_output=3 +include_trailing_comma=True +force_grid_wrap=0 +use_parentheses=True +ensure_newline_before_comments = True +line_length=88 +# custom configurations +order_by_type=False +case_sensitive=True +lines_after_imports=2 +skip=packages/valory +skip_glob = +known_first_party=autonomy +known_packages=packages +known_local_folder=tests +sections=FUTURE,STDLIB,THIRDPARTY,FIRSTPARTY,PACKAGES,LOCALFOLDER + +[mypy] +python_version = 3.10 +strict_optional = True +exclude=(.*_pb2|.*custom_types) + +# Before adding a module here, make sure it does not support type hints +# Per-module options for aea dir: + +[mypy-aea.*] +ignore_missing_imports = True + +[mypy-packages.open_aea.*] +ignore_errors=True + +[mypy-packages.valory.connections.*] +ignore_errors=True + +[mypy-packages.valory.contracts.*] +ignore_errors=True + +[mypy-packages.valory.protocols.*] +ignore_errors=True + +[mypy-packages.valory.skills.abstract_abci.*] +ignore_errors=True + +[mypy-packages.valory.skills.abstract_round_abci.*] +ignore_errors=True + +[mypy-packages.valory.skills.registration_abci.*] +ignore_errors=True + +[mypy-packages.valory.skills.transaction_settlement_abci.*] +ignore_errors=True + +[mypy-requests] +ignore_missing_imports=True + +[mypy-yaml] +ignore_missing_imports=True + +[mypy-aea_test_autonomy.*] +ignore_missing_imports = True + +[mypy-_pytest.*] +ignore_missing_imports = True + +[mypy-aea_ledger_ethereum.*] +ignore_missing_imports=True + +[mypy-ipfshttpclient.*] +ignore_missing_imports = True + +[mypy-pytest] +ignore_missing_imports = True + +[mypy-hypothesis.*] +ignore_missing_imports = True + +[mypy-docker.*] +ignore_missing_imports = True + +[mypy-certifi.*] +ignore_missing_imports = True + +[mypy-pandas.*] +ignore_missing_imports = True + +[mypy-aea_cli_ipfs.*] +ignore_missing_imports = True + +[mypy-py_eth_sig_utils.*] +ignore_missing_imports = True + +[darglint] +docstring_style=sphinx +strictness=short +ignore_regex=async_act +ignore=DAR401 + +[pytest] +log_cli = 1 +log_cli_level = DEBUG +log_cli_format = %(asctime)s [%(levelname)8s] %(message)s (%(filename)s:%(lineno)s) +log_cli_date_format=%Y-%m-%d %H:%M:%S +asyncio_mode=strict + +markers = + integration: marks integration tests which require other network services + e2e: marks end-to-end agent tests + +filterwarnings = ignore::DeprecationWarning:aea.*: + +; some useful links: +; - https://janelia-flyem.github.io/licenses.html +; - https://dwheeler.com/essays/floss-license-slide.html + +; Authorized and unauthorized licenses in LOWER CASE +[Licenses] +authorized_licenses: + ; aliases for MIT License + MIT + MIT license + https://opensource.org/licenses/MIT + License :: OSI Approved :: MIT + + ; aliases for BSD License (and variants) + BSD + BSD license + new BSD + (new) BSD + new BDS license + simplified BSD + 3-Clause BSD + BSD-3-Clause + BSD 3-Clause + BSD-2-Clause + BSD-like + BSD-2-Clause or Apache-2.0 + BSD, Public Domain + + ; Apache + Apache Software + + ; aliases for Apache License version 2.0 + Apache 2.0 + Apache-2.0 + Apache License 2.0 + Apache License, Version 2.0 + Apache License Version 2.0 + Apache2 + ASL 2 +; some packages use 'Apache Software' as license string, +; which is ambiguous. However, 'Apache Software' +; will likely match with 'Apache 2.0' + Apache Software + BSD, Public Domain, Apache + http://www.apache.org/licenses/LICENSE-2.0 + +; PSF (BSD-style) + Python Software Foundation + PSF + + ; other permissive licenses + Historical Permission Notice and Disclaimer (HPND) + HPND + ISC + BSD or Apache License, Version 2.0 + Modified BSD + Expat + Public Domain + +unauthorized_licenses: +; aliases for MPL 2.0 + MPL-2.0 + MPL 2.0 + Mozilla Public License 2.0 (MPL 2.0) + +; Section 8 of https://www.mozilla.org/en-US/MPL/2.0/Revision-FAQ/ + MPL 1.1 + MPL-1.1 + +; http://www.gnu.org/licenses/license-list.en.html#apache2 + GPLv2 + GPLv2+ + GNU General Public License v2 or later (GPLv2+) + +; LGPL + LGPL + GNU Library or Lesser General Public License (LGPL) + +; LGPLv2.1 + LGPLv2.1 + LGPLv2.1+ + GNU Lesser General Public License v2 or later (LGPLv2+) + +; LGPLv3 + GNU Lesser General Public License v3 (LGPLv3) + LGPLv3 + +; GPL v3 + GPL v3 + GPLv3+ + GNU General Public License v3 (GPLv3) + +[Authorized Packages] +gym: >=0.15 +;filelock is public domain +filelock: >=3.0.12 +fetchai-ledger-api: >=0.0.1 +chardet: >=3.0.4 +certifi: >=2019.11.28 +;TODO: the following are conflicting packages that need to be sorted +; sub-dep of open-aea-ledger-ethereum-hwi +hidapi: >=0.13.1 +; shows in pip freeze but not referenced on code +paramiko: >=3.1.0 +; sub-dep of docker-compose +websocket-client: >=0.59.0