Skip to content

Commit 7321d72

Browse files
committed
address comments on PR #2547
1 parent c5f2b8c commit 7321d72

File tree

3 files changed

+7
-16
lines changed

3 files changed

+7
-16
lines changed

tests/ens/test_get_text.py

+2-9
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,6 @@
1010
)
1111
from web3 import Web3
1212

13-
SET_TEXT_RESOLVER_NOT_FOUND_CASES = (
14-
("avatar", "tester.jpeg"),
15-
("email", "user@example.com"),
16-
("url", "http://example.com"),
17-
("description", "a test"),
18-
("notice", "this contract is a test contract"),
19-
)
2013
GET_TEXT_TEST_CASES = (
2114
("avatar", "tester.jpeg"),
2215
("email", "user@example.com"),
@@ -26,7 +19,7 @@
2619
)
2720

2821

29-
@pytest.mark.parametrize("key,expected", SET_TEXT_RESOLVER_NOT_FOUND_CASES)
22+
@pytest.mark.parametrize("key,expected", GET_TEXT_TEST_CASES)
3023
def test_set_text_resolver_not_found(ens, key, expected):
3124
with pytest.raises(ResolverNotFound):
3225
ens.set_text("tld", key, expected)
@@ -92,7 +85,7 @@ def test_get_text_for_resolver_with_unsupported_function(ens):
9285

9386

9487
@pytest.mark.asyncio
95-
@pytest.mark.parametrize("key,expected", SET_TEXT_RESOLVER_NOT_FOUND_CASES)
88+
@pytest.mark.parametrize("key,expected", GET_TEXT_TEST_CASES)
9689
async def test_async_set_text_resolver_not_found(async_ens, key, expected):
9790
with pytest.raises(ResolverNotFound):
9891
await async_ens.set_text("tld", key, expected)

tests/ens/test_wildcard_resolution.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ def test_wildcard_resolution_with_extended_resolver_for_subdomains(ens, subdomai
1010
assert resolved_child_address == "0x000000000000000000000000000000000000dEaD"
1111

1212

13-
def test_async_wildcard_resolution_with_extended_resolver_for_parent_ens_domain(ens):
13+
def test_wildcard_resolution_with_extended_resolver_for_parent_ens_domain(ens):
1414
# validate `extended-resolver.eth` by asserting it returns the specified hard-coded address from
1515
# `tests/test_contracts/ExtendedResolver.sol` which requires a specific condition to be
1616
# met for the parent domain `extended-resolver.eth`
@@ -36,7 +36,7 @@ async def test_async_wildcard_resolution_with_extended_resolver_for_subdomains(
3636

3737

3838
@pytest.mark.asyncio
39-
async def test_wildcard_resolution_with_extended_resolver_for_parent_ens_domain(
39+
async def test_async_wildcard_resolution_with_extended_resolver_for_parent_ens_domain(
4040
async_ens,
4141
):
4242
# validate `extended-resolver.eth` by asserting it returns the specified hard-coded address from

web3/main.py

+3-5
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ def __init__(
249249
external_modules: Optional[
250250
Dict[str, Union[Type[Module], Sequence[Any]]]
251251
] = None,
252-
ens: Optional[Union[ENS, AsyncENS]] = None,
252+
ens: Union[ENS, AsyncENS] = cast(ENS, empty),
253253
) -> None:
254254
self.manager = self.RequestManager(self, provider, middlewares)
255255
# this codec gets used in the module initialization,
@@ -352,14 +352,12 @@ def is_encodable(self, _type: TypeStr, value: Any) -> bool:
352352
@property
353353
def ens(self) -> Union[ENS, AsyncENS]:
354354
if self._ens is cast(ENS, empty):
355-
return ENS.fromWeb3(self)
356-
elif self._ens is cast(AsyncENS, empty) or self.eth.is_async:
357-
return AsyncENS.fromWeb3(self)
355+
return AsyncENS.fromWeb3(self) if self.eth.is_async else ENS.fromWeb3(self)
358356

359357
return self._ens
360358

361359
@ens.setter
362-
def ens(self, new_ens: Optional[Union[ENS, AsyncENS]]) -> None:
360+
def ens(self, new_ens: Union[ENS, AsyncENS]) -> None:
363361
self._ens = new_ens
364362

365363
@property

0 commit comments

Comments
 (0)