Skip to content

Commit

Permalink
fix: shi
Browse files Browse the repository at this point in the history
  • Loading branch information
antazoey committed Dec 12, 2023
1 parent e74f121 commit d22ff36
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
14 changes: 11 additions & 3 deletions ape_addressbook/addressbook.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,16 @@ def _validate_entries(entries: Dict) -> Dict:


class AddressBookConfig(PluginConfig):
__root__: Dict[str, AddressType] = {}

@root_validator(pre=True)
def validate_entries(cls, entries):
return _validate_entries(entries)

def __len__(self) -> int:
return len(self.dict())

class Config:
extra = "allow"


class AddressBook(ManagerAccessMixin):
"""
Expand Down Expand Up @@ -67,14 +71,18 @@ def registry(self) -> Dict[str, AddressType]:
and project addresses.
"""

return self.config.dict()
data = self.config.dict()

# Sorted for consistency's sake.
return {k: data[k] for k in sorted(data)}

@property
def aliases(self) -> Iterator[str]:
"""
An iterator over all aliases in the registry.
"""

# NOTE: self.registry is sorted.
for alias in self.registry:
yield alias

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
include_package_data=True,
install_requires=[
"eth-ape>=0.6.0,<0.7",
"pydantic<2",
"pydantic", # Use same version as eth-ape.
],
python_requires=">=3.8,<4",
extras_require=extras_require,
Expand Down
7 changes: 3 additions & 4 deletions tests/test_addressbook.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,9 @@ def test_aliases(project_alias_unchecksummed, project_alias_no_quotes):
The aliases includes both project and global addresses.
"""

assert list(addressbook.aliases) == [
project_alias_unchecksummed,
project_alias_no_quotes,
]
actual = list(addressbook.aliases)
expected = [project_alias_no_quotes, project_alias_unchecksummed]
assert actual == expected


def test_contains(
Expand Down

0 comments on commit d22ff36

Please sign in to comment.