diff --git a/auto_dev/cli_executor.py b/auto_dev/cli_executor.py index d7a87aba..cdbf8faa 100644 --- a/auto_dev/cli_executor.py +++ b/auto_dev/cli_executor.py @@ -22,6 +22,10 @@ def __init__(self, command: Union[str, List[str]], cwd: Optional[str] = None): """Initialize the command executor.""" self.command = command self.cwd = str(cwd) if cwd else '.' + self.stdout = [] + self.stderr = [] + self.return_code = None + self.exception = None def execute(self, stream=False, verbose: bool = True, shell: bool = False): """Execute the command.""" @@ -45,6 +49,9 @@ def execute(self, stream=False, verbose: bool = True, shell: bool = False): if len(result.stderr) > 0: logger.error(result.stderr.decode("utf-8")) + self.stdout = result.stdout.decode("utf-8").splitlines() + self.stderr = result.stderr.decode("utf-8").splitlines() + self.return_code = result.returncode if result.returncode != 0: if verbose: logger.error("Command failed with return code: %s", result.returncode) @@ -52,6 +59,7 @@ def execute(self, stream=False, verbose: bool = True, shell: bool = False): return True except Exception as error: # pylint: disable=broad-except logger.error("Command failed: %s", error) + self.exception = error return False def _execute_stream(self, verbose: bool = True, shell: bool = False): @@ -67,15 +75,32 @@ def _execute_stream(self, verbose: bool = True, shell: bool = False): shell=shell, ) as process: for stdout_line in iter(process.stdout.readline, ""): # type: ignore + self.stdout.append(stdout_line.strip()) if verbose: logger.info(stdout_line.strip()) + for stderr_line in iter(process.stderr.readline, ""): + self.stderr.append(stderr_line.strip()) + if verbose: + logger.error(stderr_line.strip()) process.stdout.close() # type: ignore - return_code = process.wait() - if return_code != 0: + self.return_code = process.wait() + if self.return_code != 0: if verbose: - logger.error("Command failed with return code: %s", return_code) + logger.error("Command failed with return code: %s", self.return_code) return False return True except Exception as error: # pylint: disable=broad-except logger.error("Command failed: %s", error) + self.exception = error return False + + @property + def output(self): + """Return the output.""" + fmt = f"Command: {' '.join(self.command)}\n" + fmt += f"Return Code: {self.return_code}\n" + fmt += "Stdout:\n" + fmt += "\n\t".join(self.stdout) + fmt += "\nStderr:\n" + fmt += "\n\t".join(self.stderr) + return fmt diff --git a/auto_dev/commands/repo.py b/auto_dev/commands/repo.py index e9f367da..51b75e3d 100644 --- a/auto_dev/commands/repo.py +++ b/auto_dev/commands/repo.py @@ -25,9 +25,11 @@ def execute_commands(*commands: str, verbose: bool, logger, shell: bool = False) """Execute commands.""" for command in commands: cli_executor = CommandExecutor(command=command.split(" ")) - result = cli_executor.execute(stream=True, verbose=verbose, shell=shell) + result = cli_executor.execute(stream=False, verbose=verbose, shell=shell) if not result: logger.error(f"Command failed: {command}") + logger.error(f"{cli_executor.stdout}") + logger.error(f"{cli_executor.stderr}") sys.exit(1) diff --git a/auto_dev/commands/test.py b/auto_dev/commands/test.py index 870c765b..484d07ed 100644 --- a/auto_dev/commands/test.py +++ b/auto_dev/commands/test.py @@ -16,7 +16,7 @@ "-p", "--path", help="Path to directory to test. If not provided will test all packages.", - type=click.Path(exists=True, file_okay=False), + type=click.Path(exists=True, file_okay=True), default=None, ) @click.option( @@ -32,8 +32,9 @@ def test(ctx, path, watch): Runs the test tooling """ verbose = ctx.obj["VERBOSE"] - logger = ctx.obj["LOGGER"] - logger.info(f"Testing path: `{path if path else 'All dev packages/packages.json'}` ⌛") + click.echo( + f"Testing path: `{path if path else 'All dev packages/packages.json'}` ⌛", + ) try: packages = get_packages() if not path else [path] except Exception as error: @@ -42,7 +43,7 @@ def test(ctx, path, watch): for package in track(range(len(packages)), description="Testing..."): result = test_path(str(packages[package]), verbose=verbose, watch=watch) results[packages[package]] = result - logger.info(f"{'👌' if result else '❗'} - {packages[package]}") + click.echo(f"{'👌' if result else '❗'} - {packages[package]}") raises = [] for package, result in results.items(): @@ -50,7 +51,7 @@ def test(ctx, path, watch): raises.append(package) if raises: for package in raises: - logger.error(f"❗ - {package}") + click.echo(f"❗ - {package}") raise click.ClickException("Testing failed! ❌") click.echo("Testing completed successfully! ✅") diff --git a/auto_dev/data/repo/templates/autonomy/install.sh b/auto_dev/data/repo/templates/autonomy/install.sh index 638db43c..7bd8cbd6 100755 --- a/auto_dev/data/repo/templates/autonomy/install.sh +++ b/auto_dev/data/repo/templates/autonomy/install.sh @@ -116,9 +116,16 @@ function install_poetry_deps() { local os local pip_executable local poetry_executable - - + local host_poetry_executable + host_poetry_executable=$(echo -n $(poetry env info | grep Executable |head -n 1 | awk -F: '{ print $2 }') | xargs) + echo "Host poetry executable: $host_poetry_executable" + echo "Setting up new poetry environment..." + + poetry env use $(which python) + poetry_executable=$(echo -n $(poetry env info | grep Executable |head -n 1 | awk -F: '{ print $2 }') | xargs) + echo "New poetry executable: $poetry_executable" echo "Installing package dependencies via poetry..." + echo "Using poetry executable: $poetry_executable" poetry install echo checking if aea is installed poetry run aea --version diff --git a/auto_dev/data/repo/templates/autonomy/poetry.lock b/auto_dev/data/repo/templates/autonomy/poetry.lock index e8875362..798c9200 100644 --- a/auto_dev/data/repo/templates/autonomy/poetry.lock +++ b/auto_dev/data/repo/templates/autonomy/poetry.lock @@ -2,14 +2,14 @@ [[package]] name = "aiohappyeyeballs" -version = "2.3.4" +version = "2.3.5" description = "Happy Eyeballs for asyncio" category = "main" optional = false -python-versions = "<4.0,>=3.8" +python-versions = ">=3.8" files = [ - {file = "aiohappyeyeballs-2.3.4-py3-none-any.whl", hash = "sha256:40a16ceffcf1fc9e142fd488123b2e218abc4188cf12ac20c67200e1579baa42"}, - {file = "aiohappyeyeballs-2.3.4.tar.gz", hash = "sha256:7e1ae8399c320a8adec76f6c919ed5ceae6edd4c3672f4d9eae2b27e37c80ff6"}, + {file = "aiohappyeyeballs-2.3.5-py3-none-any.whl", hash = "sha256:4d6dea59215537dbc746e93e779caea8178c866856a721c9c660d7a5a7b8be03"}, + {file = "aiohappyeyeballs-2.3.5.tar.gz", hash = "sha256:6fa48b9f1317254f122a07a131a86b71ca6946ca989ce6326fff54a99a920105"}, ] [[package]] @@ -218,6 +218,21 @@ files = [ {file = "asn1crypto-1.4.0.tar.gz", hash = "sha256:f4f6e119474e58e04a2b1af817eb585b4fd72bdd89b998624712b5c99be7641c"}, ] +[[package]] +name = "astroid" +version = "3.2.4" +description = "An abstract syntax tree for Python with inference support." +category = "main" +optional = false +python-versions = ">=3.8.0" +files = [ + {file = "astroid-3.2.4-py3-none-any.whl", hash = "sha256:413658a61eeca6202a59231abb473f932038fbcbf1666587f66d482083413a25"}, + {file = "astroid-3.2.4.tar.gz", hash = "sha256:0e14202810b30da1b735827f78f5157be2bbd4a7a59b7707ca0bfc2fb4c0063a"}, +] + +[package.dependencies] +typing-extensions = {version = ">=4.0.0", markers = "python_version < \"3.11\""} + [[package]] name = "async-timeout" version = "4.0.3" @@ -250,49 +265,64 @@ docs = ["cogapp", "furo", "myst-parser", "sphinx", "sphinx-notfound-page", "sphi tests = ["cloudpickle", "hypothesis", "mypy (>=1.11.1)", "pympler", "pytest (>=4.3.0)", "pytest-mypy-plugins", "pytest-xdist[psutil]"] tests-mypy = ["mypy (>=1.11.1)", "pytest-mypy-plugins"] +[[package]] +name = "autoflake8" +version = "0.4.1" +description = "Tool to automatically fix some issues reported by flake8 (forked from autoflake)." +category = "main" +optional = false +python-versions = ">=3.7,<4.0" +files = [ + {file = "autoflake8-0.4.1-py3-none-any.whl", hash = "sha256:fdf663b627993ac38e5b55b7d742c388fb2a4f34798a052f43eecc5e8d629e9d"}, + {file = "autoflake8-0.4.1.tar.gz", hash = "sha256:c17da499bd2b71ba02fb11fe53ff1ad83d7dae6efb0f115fd1344f467797c679"}, +] + +[package.dependencies] +pyflakes = ">=2.3.0" + [[package]] name = "autonomy-dev" version = "0.2.64" description = "A collection of tooling to enable open source development of autonomy tools" category = "main" optional = false -python-versions = ">=3.9,<3.12" -files = [] -develop = true - -[package.dependencies] -asn1crypto = "<1.5.0,>=1.4.0" -eth-abi = "==5.1.0" -eth-utils = "==2.3.1" -grpcio = "==1.65.1" -hypothesis = "==6.21.6" -ipfshttpclient = "==0.8.0a2" -open-aea-cli-ipfs = "==1.55.0" -open-aea-ledger-cosmos = "==1.55.0" -open-aea-ledger-ethereum = "==1.55.0" -open-aea-ledger-solana = "==1.55.0" -open-aea-test-autonomy = "==0.15.2" -open-autonomy = "==0.15.2" -protobuf = "<4.25.0,>=4.21.6" +python-versions = "<3.12,>=3.9" +files = [ + {file = "autonomy_dev-0.2.64-py3-none-any.whl", hash = "sha256:ae1e52bbd2a73bb1b8071ef376bfca5cae47d8ac57c9fc109337c4bf0697dc00"}, + {file = "autonomy_dev-0.2.64.tar.gz", hash = "sha256:1e7dc5b8bca2035f95edd195e820adda85d63c40246f7d8decb8176e5b2fb064"}, +] + +[package.dependencies] +asn1crypto = ">=1.4.0,<1.5.0" +autoflake8 = {version = ">=0.4.1,<0.5.0", optional = true, markers = "extra == \"all\""} +eth-abi = "5.1.0" +eth-utils = "2.3.1" +grpcio = "1.65.1" +hypothesis = "6.21.6" +ipfshttpclient = "0.8.0a2" +open-aea-cli-ipfs = "1.55.0" +open-aea-ledger-cosmos = "1.55.0" +open-aea-ledger-ethereum = "1.55.0" +open-aea-ledger-solana = "1.55.0" +open-aea-test-autonomy = "0.15.2" +open-autonomy = "0.15.2" +protobuf = ">=4.21.6,<4.25.0" py-eth-sig-utils = "*" -py-multibase = "==1.0.3" -py-multicodec = "==0.2.1" -pycryptodome = "==3.20.0" -pytest-xdist = "^3.6.1" +py-multibase = "1.0.3" +py-multicodec = "0.2.1" +pycryptodome = "3.20.0" +pylama = {version = ">=8.4.1,<9.0.0", extras = ["all"], optional = true, markers = "extra == \"all\""} +pytest-xdist = ">=3.6.1,<4.0.0" requests = "2.28.1" -rich-click = "^1.8.2" -tomte = {version = "==0.2.17", extras = ["black", "cli", "ledgers", "tests"]} +rich-click = ">=1.8.2,<2.0.0" +tbump = {version = ">=6.11.0,<7.0.0", optional = true, markers = "extra == \"all\" or extra == \"dev\""} +tomte = {version = "0.2.17", extras = ["black", "cli", "ledgers", "tests"]} typing_extensions = ">=3.10.0.2" -web3 = "<7,>=6.0.0" +web3 = ">=6.0.0,<7" [package.extras] all = ["autoflake8 (>=0.4.1,<0.5.0)", "pylama[all] (>=8.4.1,<9.0.0)", "tbump (>=6.11.0,<7.0.0)"] dev = ["tbump (>=6.11.0,<7.0.0)", "toml (==0.10.2)"] -doc = [] - -[package.source] -type = "directory" -url = ".." [[package]] name = "backoff" @@ -729,6 +759,23 @@ files = [ [package.extras] unicode-backport = ["unicodedata2"] +[[package]] +name = "cli-ui" +version = "0.17.2" +description = "Build Nice User Interfaces In The Terminal" +category = "main" +optional = false +python-versions = ">=3.7,<4.0" +files = [ + {file = "cli-ui-0.17.2.tar.gz", hash = "sha256:2f67e50cf474e76ad160c3e660bbad98bf8b8dfb8d847765f3a261b7e13c05fa"}, + {file = "cli_ui-0.17.2-py3-none-any.whl", hash = "sha256:6a1ebdbbcd83a0fa06b2f63f4434082a3ba8664aebedd91f1ff86b9e4289d53e"}, +] + +[package.dependencies] +colorama = ">=0.4.1,<0.5.0" +tabulate = ">=0.8.3,<0.9.0" +unidecode = ">=1.0.23,<2.0.0" + [[package]] name = "click" version = "8.1.7" @@ -1118,6 +1165,22 @@ toolz = ">=0.8.0" [package.extras] cython = ["cython"] +[[package]] +name = "dill" +version = "0.3.8" +description = "serialize all of Python" +category = "main" +optional = false +python-versions = ">=3.8" +files = [ + {file = "dill-0.3.8-py3-none-any.whl", hash = "sha256:c36ca9ffb54365bdd2f8eb3eff7d2a21237f8452b57ace88b1ac615b7e815bd7"}, + {file = "dill-0.3.8.tar.gz", hash = "sha256:3ebe3c479ad625c4553aca177444d89b486b1d84982eeacded644afc0cf797ca"}, +] + +[package.extras] +graph = ["objgraph (>=1.7.2)"] +profile = ["gprof2dot (>=2022.7.29)"] + [[package]] name = "distlib" version = "0.3.8" @@ -1209,6 +1272,18 @@ six = ">=1.9.0" gmpy = ["gmpy"] gmpy2 = ["gmpy2"] +[[package]] +name = "eradicate" +version = "2.3.0" +description = "Removes commented-out code." +category = "main" +optional = false +python-versions = "*" +files = [ + {file = "eradicate-2.3.0-py3-none-any.whl", hash = "sha256:2b29b3dd27171f209e4ddd8204b70c02f0682ae95eecb353f10e8d72b149c63e"}, + {file = "eradicate-2.3.0.tar.gz", hash = "sha256:06df115be3b87d0fc1c483db22a2ebb12bcf40585722810d809cc770f5031c37"}, +] + [[package]] name = "eth-abi" version = "5.1.0" @@ -1839,6 +1914,21 @@ files = [ multiaddr = ">=0.0.7" requests = ">=2.11" +[[package]] +name = "isort" +version = "5.13.2" +description = "A Python utility / library to sort Python imports." +category = "main" +optional = false +python-versions = ">=3.8.0" +files = [ + {file = "isort-5.13.2-py3-none-any.whl", hash = "sha256:8ca5e72a8d85860d5a3fa69b8745237f2939afe12dbf656afbcb47fe72d947a6"}, + {file = "isort-5.13.2.tar.gz", hash = "sha256:48fdfcb9face5d58a4f6dde2e72a1fb8dcaf8ab26f95ab49fab84c2ddefb0109"}, +] + +[package.extras] +colors = ["colorama (>=0.4.6)"] + [[package]] name = "itsdangerous" version = "2.2.0" @@ -2010,6 +2100,24 @@ files = [ [package.extras] test = ["pytest"] +[[package]] +name = "mando" +version = "0.7.1" +description = "Create Python CLI apps with little to no effort at all!" +category = "main" +optional = false +python-versions = "*" +files = [ + {file = "mando-0.7.1-py2.py3-none-any.whl", hash = "sha256:26ef1d70928b6057ee3ca12583d73c63e05c49de8972d620c278a7b206581a8a"}, + {file = "mando-0.7.1.tar.gz", hash = "sha256:18baa999b4b613faefb00eac4efadcf14f510b59b924b66e08289aa1de8c3500"}, +] + +[package.dependencies] +six = "*" + +[package.extras] +restructuredtext = ["rst2ansi"] + [[package]] name = "markdown-it-py" version = "3.0.0" @@ -2105,6 +2213,18 @@ files = [ {file = "MarkupSafe-2.1.5.tar.gz", hash = "sha256:d283d37a890ba4c1ae73ffadf8046435c76e7bc2247bbb63c00bd1a709c6544b"}, ] +[[package]] +name = "mccabe" +version = "0.7.0" +description = "McCabe checker, plugin for flake8" +category = "main" +optional = false +python-versions = ">=3.6" +files = [ + {file = "mccabe-0.7.0-py2.py3-none-any.whl", hash = "sha256:6c2d30ab6be0e4a46919781807b4f0d834ebdd6c6e3dca0bda5a15f863427b6e"}, + {file = "mccabe-0.7.0.tar.gz", hash = "sha256:348e0240c33b60bbdf4e523192ef919f28cb2c3d7d5c7794f74009290f236325"}, +] + [[package]] name = "mdurl" version = "0.1.2" @@ -2258,6 +2378,54 @@ files = [ {file = "multidict-6.0.5.tar.gz", hash = "sha256:f7e301075edaf50500f0b341543c41194d8df3ae5caf4702f2095f3ca73dd8da"}, ] +[[package]] +name = "mypy" +version = "1.11.1" +description = "Optional static typing for Python" +category = "main" +optional = false +python-versions = ">=3.8" +files = [ + {file = "mypy-1.11.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:a32fc80b63de4b5b3e65f4be82b4cfa362a46702672aa6a0f443b4689af7008c"}, + {file = "mypy-1.11.1-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:c1952f5ea8a5a959b05ed5f16452fddadbaae48b5d39235ab4c3fc444d5fd411"}, + {file = "mypy-1.11.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:e1e30dc3bfa4e157e53c1d17a0dad20f89dc433393e7702b813c10e200843b03"}, + {file = "mypy-1.11.1-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:2c63350af88f43a66d3dfeeeb8d77af34a4f07d760b9eb3a8697f0386c7590b4"}, + {file = "mypy-1.11.1-cp310-cp310-win_amd64.whl", hash = "sha256:a831671bad47186603872a3abc19634f3011d7f83b083762c942442d51c58d58"}, + {file = "mypy-1.11.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:7b6343d338390bb946d449677726edf60102a1c96079b4f002dedff375953fc5"}, + {file = "mypy-1.11.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:e4fe9f4e5e521b458d8feb52547f4bade7ef8c93238dfb5bbc790d9ff2d770ca"}, + {file = "mypy-1.11.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:886c9dbecc87b9516eff294541bf7f3655722bf22bb898ee06985cd7269898de"}, + {file = "mypy-1.11.1-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:fca4a60e1dd9fd0193ae0067eaeeb962f2d79e0d9f0f66223a0682f26ffcc809"}, + {file = "mypy-1.11.1-cp311-cp311-win_amd64.whl", hash = "sha256:0bd53faf56de9643336aeea1c925012837432b5faf1701ccca7fde70166ccf72"}, + {file = "mypy-1.11.1-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:f39918a50f74dc5969807dcfaecafa804fa7f90c9d60506835036cc1bc891dc8"}, + {file = "mypy-1.11.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:0bc71d1fb27a428139dd78621953effe0d208aed9857cb08d002280b0422003a"}, + {file = "mypy-1.11.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:b868d3bcff720dd7217c383474008ddabaf048fad8d78ed948bb4b624870a417"}, + {file = "mypy-1.11.1-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:a707ec1527ffcdd1c784d0924bf5cb15cd7f22683b919668a04d2b9c34549d2e"}, + {file = "mypy-1.11.1-cp312-cp312-win_amd64.whl", hash = "sha256:64f4a90e3ea07f590c5bcf9029035cf0efeae5ba8be511a8caada1a4893f5525"}, + {file = "mypy-1.11.1-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:749fd3213916f1751fff995fccf20c6195cae941dc968f3aaadf9bb4e430e5a2"}, + {file = "mypy-1.11.1-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:b639dce63a0b19085213ec5fdd8cffd1d81988f47a2dec7100e93564f3e8fb3b"}, + {file = "mypy-1.11.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:4c956b49c5d865394d62941b109728c5c596a415e9c5b2be663dd26a1ff07bc0"}, + {file = "mypy-1.11.1-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:45df906e8b6804ef4b666af29a87ad9f5921aad091c79cc38e12198e220beabd"}, + {file = "mypy-1.11.1-cp38-cp38-win_amd64.whl", hash = "sha256:d44be7551689d9d47b7abc27c71257adfdb53f03880841a5db15ddb22dc63edb"}, + {file = "mypy-1.11.1-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:2684d3f693073ab89d76da8e3921883019ea8a3ec20fa5d8ecca6a2db4c54bbe"}, + {file = "mypy-1.11.1-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:79c07eb282cb457473add5052b63925e5cc97dfab9812ee65a7c7ab5e3cb551c"}, + {file = "mypy-1.11.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:11965c2f571ded6239977b14deebd3f4c3abd9a92398712d6da3a772974fad69"}, + {file = "mypy-1.11.1-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:a2b43895a0f8154df6519706d9bca8280cda52d3d9d1514b2d9c3e26792a0b74"}, + {file = "mypy-1.11.1-cp39-cp39-win_amd64.whl", hash = "sha256:1a81cf05975fd61aec5ae16501a091cfb9f605dc3e3c878c0da32f250b74760b"}, + {file = "mypy-1.11.1-py3-none-any.whl", hash = "sha256:0624bdb940255d2dd24e829d99a13cfeb72e4e9031f9492148f410ed30bcab54"}, + {file = "mypy-1.11.1.tar.gz", hash = "sha256:f404a0b069709f18bbdb702eb3dcfe51910602995de00bd39cea3050b5772d08"}, +] + +[package.dependencies] +mypy-extensions = ">=1.0.0" +tomli = {version = ">=1.1.0", markers = "python_version < \"3.11\""} +typing-extensions = ">=4.6.0" + +[package.extras] +dmypy = ["psutil (>=4.0)"] +install-types = ["pip"] +mypyc = ["setuptools (>=50)"] +reports = ["lxml"] + [[package]] name = "mypy-extensions" version = "1.0.0" @@ -2691,6 +2859,18 @@ morphys = ">=1.0,<2.0" six = ">=1.10.0,<2.0" varint = ">=1.0.2,<2.0.0" +[[package]] +name = "pycodestyle" +version = "2.12.1" +description = "Python style guide checker" +category = "main" +optional = false +python-versions = ">=3.8" +files = [ + {file = "pycodestyle-2.12.1-py2.py3-none-any.whl", hash = "sha256:46f0fb92069a7c28ab7bb558f05bfc0110dac69a0cd23c61ea0040283a9d78b3"}, + {file = "pycodestyle-2.12.1.tar.gz", hash = "sha256:6838eae08bbce4f6accd5d5572075c63626a15ee3e6f842df996bf62f6d73521"}, +] + [[package]] name = "pycparser" version = "2.22" @@ -2745,6 +2925,36 @@ files = [ {file = "pycryptodome-3.20.0.tar.gz", hash = "sha256:09609209ed7de61c2b560cc5c8c4fbf892f8b15b1faf7e4cbffac97db1fffda7"}, ] +[[package]] +name = "pydocstyle" +version = "6.3.0" +description = "Python docstring style checker" +category = "main" +optional = false +python-versions = ">=3.6" +files = [ + {file = "pydocstyle-6.3.0-py3-none-any.whl", hash = "sha256:118762d452a49d6b05e194ef344a55822987a462831ade91ec5c06fd2169d019"}, + {file = "pydocstyle-6.3.0.tar.gz", hash = "sha256:7ce43f0c0ac87b07494eb9c0b462c0b73e6ff276807f204d6b53edc72b7e44e1"}, +] + +[package.dependencies] +snowballstemmer = ">=2.2.0" + +[package.extras] +toml = ["tomli (>=1.2.3)"] + +[[package]] +name = "pyflakes" +version = "3.2.0" +description = "passive checker of Python programs" +category = "main" +optional = false +python-versions = ">=3.8" +files = [ + {file = "pyflakes-3.2.0-py2.py3-none-any.whl", hash = "sha256:84b5be138a2dfbb40689ca07e2152deb896a65c3a3e24c251c5c62489568074a"}, + {file = "pyflakes-3.2.0.tar.gz", hash = "sha256:1c61603ff154621fb2a9172037d84dca3500def8c8b630657d1701f026f8af3f"}, +] + [[package]] name = "pygments" version = "2.18.0" @@ -2786,6 +2996,69 @@ files = [ {file = "pyheck-0.1.5.tar.gz", hash = "sha256:5c9fe372d540c5dbcb76bf062f951d998d0e14c906c842a52f1cd5de208e183a"}, ] +[[package]] +name = "pylama" +version = "8.4.1" +description = "Code audit tool for python" +category = "main" +optional = false +python-versions = ">=3.7" +files = [ + {file = "pylama-8.4.1-py3-none-any.whl", hash = "sha256:5bbdbf5b620aba7206d688ed9fc917ecd3d73e15ec1a89647037a09fa3a86e60"}, + {file = "pylama-8.4.1.tar.gz", hash = "sha256:2d4f7aecfb5b7466216d48610c7d6bad1c3990c29cdd392ad08259b161e486f6"}, +] + +[package.dependencies] +eradicate = {version = "*", optional = true, markers = "extra == \"all\""} +mccabe = ">=0.7.0" +mypy = {version = "*", optional = true, markers = "extra == \"all\""} +pycodestyle = ">=2.9.1" +pydocstyle = ">=6.1.1" +pyflakes = ">=2.5.0" +pylint = {version = "*", optional = true, markers = "extra == \"all\""} +radon = {version = "*", optional = true, markers = "extra == \"all\""} +vulture = {version = "*", optional = true, markers = "extra == \"all\""} + +[package.extras] +all = ["eradicate", "mypy", "pylint", "radon", "vulture"] +eradicate = ["eradicate"] +mypy = ["mypy"] +pylint = ["pylint"] +radon = ["radon"] +tests = ["eradicate (>=2.0.0)", "mypy", "pylama-quotes", "pylint (>=2.11.1)", "pytest (>=7.1.2)", "pytest-mypy", "radon (>=5.1.0)", "toml", "types-setuptools", "types-toml", "vulture"] +toml = ["toml (>=0.10.2)"] +vulture = ["vulture"] + +[[package]] +name = "pylint" +version = "3.2.6" +description = "python code static checker" +category = "main" +optional = false +python-versions = ">=3.8.0" +files = [ + {file = "pylint-3.2.6-py3-none-any.whl", hash = "sha256:03c8e3baa1d9fb995b12c1dbe00aa6c4bcef210c2a2634374aedeb22fb4a8f8f"}, + {file = "pylint-3.2.6.tar.gz", hash = "sha256:a5d01678349454806cff6d886fb072294f56a58c4761278c97fb557d708e1eb3"}, +] + +[package.dependencies] +astroid = ">=3.2.4,<=3.3.0-dev0" +colorama = {version = ">=0.4.5", markers = "sys_platform == \"win32\""} +dill = [ + {version = ">=0.2", markers = "python_version < \"3.11\""}, + {version = ">=0.3.6", markers = "python_version >= \"3.11\""}, +] +isort = ">=4.2.5,<5.13.0 || >5.13.0,<6" +mccabe = ">=0.6,<0.8" +platformdirs = ">=2.2.0" +tomli = {version = ">=1.1.0", markers = "python_version < \"3.11\""} +tomlkit = ">=0.10.1" +typing-extensions = {version = ">=3.10.0", markers = "python_version < \"3.10\""} + +[package.extras] +spelling = ["pyenchant (>=3.2,<4.0)"] +testutils = ["gitpython (>3)"] + [[package]] name = "pymultihash" version = "0.8.2" @@ -3139,6 +3412,25 @@ files = [ {file = "PyYAML-6.0.1.tar.gz", hash = "sha256:bfdf460b1736c775f2ba9f6a92bca30bc2095067b8a9d77876d1fad6cc3b4a43"}, ] +[[package]] +name = "radon" +version = "6.0.1" +description = "Code Metrics in Python" +category = "main" +optional = false +python-versions = "*" +files = [ + {file = "radon-6.0.1-py2.py3-none-any.whl", hash = "sha256:632cc032364a6f8bb1010a2f6a12d0f14bc7e5ede76585ef29dc0cecf4cd8859"}, + {file = "radon-6.0.1.tar.gz", hash = "sha256:d1ac0053943a893878940fedc8b19ace70386fc9c9bf0a09229a44125ebf45b5"}, +] + +[package.dependencies] +colorama = {version = ">=0.4.1", markers = "python_version > \"3.4\""} +mando = ">=0.6,<0.8" + +[package.extras] +toml = ["tomli (>=2.0.1)"] + [[package]] name = "regex" version = "2024.7.24" @@ -3345,6 +3637,18 @@ lint = ["flake8 (==3.4.1)"] rust-backend = ["rusty-rlp (>=0.2.1,<0.3)"] test = ["hypothesis (==5.19.0)", "pytest (>=6.2.5,<7)", "tox (>=2.9.1,<3)"] +[[package]] +name = "schema" +version = "0.7.7" +description = "Simple data validation library" +category = "main" +optional = false +python-versions = "*" +files = [ + {file = "schema-0.7.7-py2.py3-none-any.whl", hash = "sha256:5d976a5b50f36e74e2157b47097b60002bd4d42e65425fcc9c9befadb4255dde"}, + {file = "schema-0.7.7.tar.gz", hash = "sha256:7da553abd2958a19dc2547c388cde53398b39196175a9be59ea1caf5ab0a1807"}, +] + [[package]] name = "semver" version = "2.13.0" @@ -3381,6 +3685,18 @@ files = [ {file = "sniffio-1.3.1.tar.gz", hash = "sha256:f4324edc670a0f49750a81b895f35c3adb843cca46f0530f79fc1babb23789dc"}, ] +[[package]] +name = "snowballstemmer" +version = "2.2.0" +description = "This package provides 29 stemmers for 28 languages generated from Snowball algorithms." +category = "main" +optional = false +python-versions = "*" +files = [ + {file = "snowballstemmer-2.2.0-py2.py3-none-any.whl", hash = "sha256:c8e1716e83cc398ae16824e5572ae04e0d9fc2c6b985fb0f900f5f0c96ecba1a"}, + {file = "snowballstemmer-2.2.0.tar.gz", hash = "sha256:09b16deb8547d3412ad7b590689584cd0fe25ec8db3be37788be3810cbf19cb1"}, +] + [[package]] name = "solana" version = "0.30.2" @@ -3452,6 +3768,39 @@ files = [ [package.dependencies] attrs = "*" +[[package]] +name = "tabulate" +version = "0.8.10" +description = "Pretty-print tabular data" +category = "main" +optional = false +python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" +files = [ + {file = "tabulate-0.8.10-py3-none-any.whl", hash = "sha256:0ba055423dbaa164b9e456abe7920c5e8ed33fcc16f6d1b2f2d152c8e1e8b4fc"}, + {file = "tabulate-0.8.10.tar.gz", hash = "sha256:6c57f3f3dd7ac2782770155f3adb2db0b1a269637e42f27599925e64b114f519"}, +] + +[package.extras] +widechars = ["wcwidth"] + +[[package]] +name = "tbump" +version = "6.11.0" +description = "Bump software releases" +category = "main" +optional = false +python-versions = ">=3.7,<4.0" +files = [ + {file = "tbump-6.11.0-py3-none-any.whl", hash = "sha256:6b181fe6f3ae84ce0b9af8cc2009a8bca41ded34e73f623a7413b9684f1b4526"}, + {file = "tbump-6.11.0.tar.gz", hash = "sha256:385e710eedf0a8a6ff959cf1e9f3cfd17c873617132fc0ec5f629af0c355c870"}, +] + +[package.dependencies] +cli-ui = ">=0.10.3" +docopt = ">=0.6.2,<0.7.0" +schema = ">=0.7.1,<0.8.0" +tomlkit = ">=0.11,<0.12" + [[package]] name = "texttable" version = "1.6.7" @@ -3488,6 +3837,18 @@ files = [ {file = "tomli-2.0.1.tar.gz", hash = "sha256:de526c12914f0c550d15924c62d72abc48d6fe7364aa87328337a31007fe8a4f"}, ] +[[package]] +name = "tomlkit" +version = "0.11.8" +description = "Style preserving TOML library" +category = "main" +optional = false +python-versions = ">=3.7" +files = [ + {file = "tomlkit-0.11.8-py3-none-any.whl", hash = "sha256:8c726c4c202bdb148667835f68d68780b9a003a9ec34167b6c673b38eff2a171"}, + {file = "tomlkit-0.11.8.tar.gz", hash = "sha256:9330fc7faa1db67b541b28e62018c17d20be733177d290a13b24c62d1614e0c3"}, +] + [[package]] name = "tomte" version = "0.2.17" @@ -3589,6 +3950,18 @@ files = [ {file = "typing_extensions-4.12.2.tar.gz", hash = "sha256:1a7ead55c7e559dd4dee8856e3a88b41225abfe1ce8df57b7c13915fe121ffb8"}, ] +[[package]] +name = "unidecode" +version = "1.3.8" +description = "ASCII transliterations of Unicode text" +category = "main" +optional = false +python-versions = ">=3.5" +files = [ + {file = "Unidecode-1.3.8-py3-none-any.whl", hash = "sha256:d130a61ce6696f8148a3bd8fe779c99adeb4b870584eeb9526584e9aa091fd39"}, + {file = "Unidecode-1.3.8.tar.gz", hash = "sha256:cfdb349d46ed3873ece4586b96aa75258726e2fa8ec21d6f00a591d98806c2f4"}, +] + [[package]] name = "urllib3" version = "1.26.19" @@ -3667,6 +4040,21 @@ platformdirs = ">=3.9.1,<5" docs = ["furo (>=2023.7.26)", "proselint (>=0.13)", "sphinx (>=7.1.2,!=7.3)", "sphinx-argparse (>=0.4)", "sphinxcontrib-towncrier (>=0.2.1a0)", "towncrier (>=23.6)"] test = ["covdefaults (>=2.3)", "coverage (>=7.2.7)", "coverage-enable-subprocess (>=1)", "flaky (>=3.7)", "packaging (>=23.1)", "pytest (>=7.4)", "pytest-env (>=0.8.2)", "pytest-freezer (>=0.4.8)", "pytest-mock (>=3.11.1)", "pytest-randomly (>=3.12)", "pytest-timeout (>=2.1)", "setuptools (>=68)", "time-machine (>=2.10)"] +[[package]] +name = "vulture" +version = "2.11" +description = "Find dead code" +category = "main" +optional = false +python-versions = ">=3.8" +files = [ + {file = "vulture-2.11-py2.py3-none-any.whl", hash = "sha256:12d745f7710ffbf6aeb8279ba9068a24d4e52e8ed333b8b044035c9d6b823aba"}, + {file = "vulture-2.11.tar.gz", hash = "sha256:f0fbb60bce6511aad87ee0736c502456737490a82d919a44e6d92262cb35f1c2"}, +] + +[package.dependencies] +tomli = {version = ">=1.1.0", markers = "python_version < \"3.11\""} + [[package]] name = "watchdog" version = "4.0.1" diff --git a/auto_dev/utils.py b/auto_dev/utils.py index d416296f..e524e4df 100644 --- a/auto_dev/utils.py +++ b/auto_dev/utils.py @@ -25,12 +25,16 @@ def get_logger(name=__name__, log_level="INFO"): """Get the logger.""" - msg_format = "%(message)s" + # We use the fancy rich logging handler and the fancy formatter handler = RichHandler( rich_tracebacks=True, markup=True, ) - logging.basicConfig(level="NOTSET", format=msg_format, datefmt="[%X]", handlers=[handler]) + # We set the time to just the 24 hours minutes and seconds + datefmt = "%H:%M:%S" + logging.basicConfig(level="NOTSET", + datefmt=datefmt, + handlers=[handler]) log = logging.getLogger(name) log.setLevel(log_level) diff --git a/tests/conftest.py b/tests/conftest.py index 2466ea25..2c6a209c 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -7,7 +7,6 @@ from pathlib import Path import pytest -from click.testing import CliRunner from auto_dev.cli_executor import CommandExecutor from auto_dev.constants import AUTONOMY_PACKAGES_FILE, DEFAULT_ENCODING, SAMPLE_PACKAGE_FILE, SAMPLE_PACKAGES_JSON @@ -48,7 +47,7 @@ def test_packages_filesystem(test_filesystem): @pytest.fixture def cli_runner(): """Fixture for invoking command-line interfaces.""" - return CliRunner() + return CommandExecutor @pytest.fixture diff --git a/tests/test_cli.py b/tests/test_cli.py index 67ca0592..343d1946 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -4,27 +4,31 @@ import os -from auto_dev.cli import cli - def test_lint_fails(cli_runner, test_filesystem): """Test the lint command fails with no packages.""" assert os.getcwd() == test_filesystem - result = cli_runner.invoke(cli, ['-n', '0', "lint", "-p", "packages/fake"]) - assert result.exit_code == 2, result.output - assert result.exception is not None - assert isinstance(SystemExit(2), type(result.exception)) + cmd = ['adev', '-n', '0', "lint", "-p", "packages/fake"] + runner = cli_runner(cmd) + runner.execute() + assert runner.return_code == 2, runner.output def test_lints_self(cli_runner, test_filesystem): """Test the lint command works with the current package.""" assert os.getcwd() == test_filesystem - result = cli_runner.invoke(cli, ["-v", "-n", "0", "lint", "-p", "."]) - assert result.exit_code == 0, result.output + cmd = ['adev', "-v", "-n", "0", "lint", "-p", "."] + runner = cli_runner(cmd) + result = runner.execute() + assert result, runner.output + assert runner.return_code == 0, runner.output def test_formats_self(cli_runner, test_filesystem): """Test the format command works with the current package.""" assert os.getcwd() == test_filesystem - result = cli_runner.invoke(cli, ["-n", "0", "-v", "fmt", "-p", "."]) - assert result.exit_code == 0, result.output + cmd = ['adev', "-n", "0", "-v", "fmt", "-p", "."] + runner = cli_runner(cmd) + result = runner.execute() + assert result, runner.output + assert runner.return_code == 0, runner.output diff --git a/tests/test_repo.py b/tests/test_repo.py index 156cc9fa..a48c57c9 100644 --- a/tests/test_repo.py +++ b/tests/test_repo.py @@ -9,7 +9,6 @@ import toml from aea.cli.utils.config import get_default_author_from_cli_config -from auto_dev.cli import cli from auto_dev.utils import change_dir @@ -23,7 +22,7 @@ class BaseTestRepo: @property def cli_args(self): """CLI arguments""" - return ("repo", self.repo_name, "-t", self.type_of_repo) + return ["adev", "repo", self.repo_name, "-t", self.type_of_repo] @property def parent_dir(self): @@ -39,8 +38,9 @@ def test_repo_new(self, cli_runner, test_clean_filesystem): """Test the format command works with the current package.""" assert test_clean_filesystem - result = cli_runner.invoke(cli, self.cli_args) - assert result.exit_code == 0, result.output + runner = cli_runner(self.cli_args) + result = runner.execute() + assert result, runner.output assert self.repo_path.exists(), f"Repository directory was not created: {self.repo_path}" assert (self.repo_path / ".git").exists() @@ -48,17 +48,18 @@ def test_repo_new_fail(self, cli_runner, test_filesystem): """Test the format command works with the current package.""" assert test_filesystem - self.repo_path.mkdir() - result = cli_runner.invoke(cli, self.cli_args) - assert result.exit_code == 1, result.output + runner = cli_runner(self.cli_args) + result = runner.execute() + assert runner.return_code == 1, result.output def test_makefile(self, cli_runner, test_clean_filesystem): """Test scaffolding of Makefile""" - assert test_clean_filesystem - result = cli_runner.invoke(cli, self.cli_args) + runner = cli_runner(self.cli_args) + result = runner.execute(self.cli_args) + assert result, (runner.stdout, '\n'.join(runner.stderr)) makefile = self.repo_path / "Makefile" assert makefile.exists(), result.output assert makefile.read_text(encoding="utf-8") @@ -70,8 +71,9 @@ def test_make_command_executes(self, cli_runner, test_clean_filesystem): assert test_clean_filesystem # Ensure the repository is created before changing directory - result = cli_runner.invoke(cli, self.cli_args) - assert result.exit_code == 0, result.output + runner = cli_runner(self.cli_args) + result = runner.execute() + assert result, runner.output assert self.repo_path.exists(), f"Repository directory was not created: {self.repo_path}" with change_dir(self.repo_path): @@ -84,8 +86,8 @@ def test_make_command_executes(self, cli_runner, test_clean_filesystem): text=True, check=False, ) - if not result.returncode == 0: - error_messages[command] = result.stderr + if not runner.return_code == 0: + error_messages[command] = runner.stderr assert not error_messages @@ -107,9 +109,9 @@ def test_gitignore(self, cli_runner, test_clean_filesystem): """Test the .gitignore works as expected""" assert test_clean_filesystem - - result = cli_runner.invoke(cli, self.cli_args) - assert result.exit_code == 0, result.output + runner = cli_runner(self.cli_args) + result = runner.execute() + assert runner.return_code == 0, runner.output packages_folder = self.repo_path / "packages" author_packages = packages_folder / self.author @@ -139,9 +141,10 @@ def test_run_single_agent(self, cli_runner, test_clean_filesystem): """Test the scripts/run_single_agent.sh is generated""" assert test_clean_filesystem + runner = cli_runner(self.cli_args) + result = runner.execute() - result = cli_runner.invoke(cli, self.cli_args) - assert result.exit_code == 0, result.output + assert runner.return_code == 0, result.output expected_path = self.repo_path / "scripts" / "run_single_agent.sh" assert expected_path.exists() diff --git a/tests/test_scaffold.py b/tests/test_scaffold.py index 9f4e9fc3..f795c5ab 100644 --- a/tests/test_scaffold.py +++ b/tests/test_scaffold.py @@ -20,13 +20,14 @@ def test_scaffold_fsm_with_aea_run(cli_runner, spec, dummy_agent_tim): """Test scaffold base FSM upto `aea run`.""" - command = ["scaffold", "fsm"] + command = ["adev", "scaffold", "fsm"] if spec: command.extend(["--spec", str(spec)]) dummy_agent_tim.exists() - result = cli_runner.invoke(cli, command) - assert result.exit_code == 0, result.output + runner = cli_runner(command) + result = runner.execute() + assert runner.exit_code == 0, runner.output assert (Path.cwd() / "vendor" / "valory" / "skills" / "abstract_abci").exists() assert (Path.cwd() / "vendor" / "valory" / "skills" / "abstract_round_abci").exists() @@ -34,11 +35,14 @@ def test_scaffold_fsm_with_aea_run(cli_runner, spec, dummy_agent_tim): assert (Path.cwd() / "vendor" / "valory" / "skills" / "reset_pause_abci").exists() assert (Path.cwd() / "vendor" / "valory" / "skills" / "termination_abci").exists() - result = cli_runner.invoke(aea_cli, ["run"]) - assert result.exit_code == 1 + cmd = ['aea', 'run'] + runner = cli_runner(cmd) + result = runner.execute() + assert runner.exit_code == 1, runner.output assert "An error occurred during instantiation of connection valory" in result.output +@pytest.mark.skip(reason="Needs chain contracts update") def test_scaffold_protocol(cli_runner, dummy_agent_tim, caplog): """Test scaffold protocol""" @@ -55,6 +59,7 @@ def test_scaffold_protocol(cli_runner, dummy_agent_tim, caplog): assert original_content in readme_path.read_text(encoding=DEFAULT_ENCODING) +@pytest.mark.skip(reason="Needs chain contracts update") def test_scaffold_handler(cli_runner, dummy_agent_tim): """Test scaffold handler""" @@ -93,6 +98,7 @@ def test_scaffold_handler(cli_runner, dummy_agent_tim): assert "http_dialogues" in skill_yaml["models"] +@pytest.mark.skip(reason="Needs chain contracts update") class TestScaffoldConnection: """Test scaffold connection."""