From 5dfc73367cee25d884b2bc4d908c49e04be951cc Mon Sep 17 00:00:00 2001 From: antazoey Date: Mon, 13 Nov 2023 12:17:42 -0600 Subject: [PATCH 1/3] fix: handle PackageName regression from ethpm-types [APE-1537] (#1735) --- .pre-commit-config.yaml | 4 ++-- setup.py | 6 +++--- src/ape/api/projects.py | 2 +- src/ape/managers/project/manager.py | 6 +++--- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b9bbcebef7..bc69f6b5fa 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -10,7 +10,7 @@ repos: - id: isort - repo: https://github.com/psf/black - rev: 23.10.1 + rev: 23.11.0 hooks: - id: black name: black @@ -21,7 +21,7 @@ repos: - id: flake8 - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.6.1 + rev: v1.7.0 hooks: - id: mypy additional_dependencies: [ diff --git a/setup.py b/setup.py index 4c54c5f549..cb9e412881 100644 --- a/setup.py +++ b/setup.py @@ -18,8 +18,8 @@ "hypothesis-jsonschema==0.19.0", # JSON Schema fuzzer extension ], "lint": [ - "black>=23.10.1,<24", # Auto-formatter and linter - "mypy>=1.6.1,<2", # Static type analyzer + "black>=23.11.0,<24", # Auto-formatter and linter + "mypy>=1.7.0,<2", # Static type analyzer "types-PyYAML", # Needed due to mypy typeshed "types-requests", # Needed due to mypy typeshed "types-setuptools", # Needed due to mypy typeshed @@ -124,7 +124,7 @@ "web3[tester]>=6.7.0,<7", # ** Dependencies maintained by ApeWorX ** "eip712>=0.2.1,<0.3", - "ethpm-types>=0.5.8,<0.6", + "ethpm-types>=0.5.10,<0.6", "evm-trace>=0.1.0a23", ], entry_points={ diff --git a/src/ape/api/projects.py b/src/ape/api/projects.py index ba7c45c484..297fbcde87 100644 --- a/src/ape/api/projects.py +++ b/src/ape/api/projects.py @@ -182,7 +182,7 @@ def _create_manifest( initial_manifest: Optional[PackageManifest] = None, ) -> PackageManifest: manifest = initial_manifest or PackageManifest() - manifest.name = PackageName(name.lower()) if name is not None else manifest.name + manifest.name = PackageName(__root__=name.lower()) if name is not None else manifest.name manifest.version = version or manifest.version manifest.sources = cls._create_source_dict(source_paths, contracts_path) manifest.contract_types = contract_types diff --git a/src/ape/managers/project/manager.py b/src/ape/managers/project/manager.py index e79a0e72ea..6a744c4e51 100644 --- a/src/ape/managers/project/manager.py +++ b/src/ape/managers/project/manager.py @@ -275,12 +275,12 @@ def extract_manifest(self) -> PackageManifest: return manifest def _extract_manifest_dependencies(self) -> Optional[Dict[PackageName, AnyUrl]]: - package_dependencies: Dict[PackageName, AnyUrl] = {} + package_dependencies: Dict[str, AnyUrl] = {} for dependency_config in self.config_manager.dependencies: package_name = dependency_config.name.replace("_", "-").lower() - package_dependencies[PackageName(package_name)] = dependency_config.uri + package_dependencies[package_name] = dependency_config.uri - return package_dependencies + return cast(Optional[Dict[PackageName, AnyUrl]], package_dependencies) @property def _package_deployments_folder(self) -> Path: From e06bec72c3d93091bfdfb1f376a70f20dfb3e433 Mon Sep 17 00:00:00 2001 From: antazoey Date: Fri, 17 Nov 2023 04:25:05 -0600 Subject: [PATCH 2/3] fix: use getattribute (#1739) --- src/ape/utils/basemodel.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ape/utils/basemodel.py b/src/ape/utils/basemodel.py index 593125b427..5551b6b007 100644 --- a/src/ape/utils/basemodel.py +++ b/src/ape/utils/basemodel.py @@ -203,7 +203,7 @@ def __getattr__(self, name: str) -> Any: """ try: - return super().__getattr__(name) + return super().__getattribute__(name) except AttributeError: extras_checked = set() for ape_extra in self.__ape_extra_attributes__(): From f2511ae6064e9d369a2e16c9271f2cab6820aabd Mon Sep 17 00:00:00 2001 From: antazoey Date: Fri, 17 Nov 2023 04:39:20 -0600 Subject: [PATCH 3/3] fix: empty plugins sections repr (#1738) --- src/ape_plugins/utils.py | 3 +++ tests/functional/test_plugins.py | 13 +++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/ape_plugins/utils.py b/src/ape_plugins/utils.py index 9f19d64094..00dba29df0 100644 --- a/src/ape_plugins/utils.py +++ b/src/ape_plugins/utils.py @@ -441,6 +441,9 @@ def __str__(self) -> str: if PluginType.AVAILABLE in self.include and self.metadata.available: sections.append(self.metadata.available) + if not sections: + return "" + # Use a single max length for all the sections. max_length = max(x.max_name_length for x in sections) diff --git a/tests/functional/test_plugins.py b/tests/functional/test_plugins.py index 37f163b630..c6e551e1ea 100644 --- a/tests/functional/test_plugins.py +++ b/tests/functional/test_plugins.py @@ -115,8 +115,8 @@ def test_is_available(self): class TestApePluginsRepr: def test_str(self, plugin_metadata): - plugin_map = ApePluginsRepr(plugin_metadata) - actual = str(plugin_map) + representation = ApePluginsRepr(plugin_metadata) + actual = str(representation) expected = f""" Installed Plugins installed {VERSION} @@ -127,8 +127,8 @@ def test_str(self, plugin_metadata): assert actual == expected.strip() def test_str_all_types(self, plugin_metadata): - plugin_map = ApePluginsRepr(plugin_metadata, include=list(PluginType)) - actual = str(plugin_map) + representation = ApePluginsRepr(plugin_metadata, include=list(PluginType)) + actual = str(representation) expected = f""" Core Plugins run @@ -143,3 +143,8 @@ def test_str_all_types(self, plugin_metadata): available """ assert actual == expected.strip() + + def test_str_no_plugins(self): + plugins = PluginMetadataList.from_package_names([]) + representation = ApePluginsRepr(plugins) + assert str(representation) == ""