Skip to content

Commit a18dfaa

Browse files
authored
fix: remove # type: ignore after each REQUIRED (#765)
* remove # type: ignore after each REQUIRED * more cleanup * more cleanup * fix more * fix merge issues * fix linter * better typing * remove more * remove more * fix mypy
1 parent 8b0b410 commit a18dfaa

File tree

104 files changed

+248
-249
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

104 files changed

+248
-249
lines changed

tools/generate_tx_models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ def _generate_param_line(param: str, is_required: bool) -> str:
132132
param_name = param[2:]
133133
param_type = sfields[param_name][0]
134134
if is_required:
135-
param_type_output = f"{TYPE_MAP[param_type]} = REQUIRED # type: ignore"
135+
param_type_output = f"{TYPE_MAP[param_type]} = REQUIRED"
136136
else:
137137
param_type_output = f"Optional[{TYPE_MAP[param_type]}] = None"
138138
return f" {_key_to_json(param_name)}: {param_type_output}"

xrpl/asyncio/clients/websocket_base.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
from typing import TYPE_CHECKING, Any, Dict, Optional, cast
99

1010
from typing_extensions import Final, Self
11-
from websockets import client as websocket_client
11+
from websockets.asyncio import client as websocket_client
12+
from websockets.protocol import State
1213

1314
from xrpl.asyncio.clients.client import Client
1415
from xrpl.asyncio.clients.exceptions import XRPLWebsocketException
@@ -65,7 +66,7 @@ def __init__(self: Self, url: str) -> None:
6566
url: The URL of the rippled node to submit requests to.
6667
"""
6768
self._open_requests: _REQUESTS_TYPE = {}
68-
self._websocket: Optional[websocket_client.WebSocketClientProtocol] = None
69+
self._websocket: Optional[websocket_client.ClientConnection] = None
6970
self._handler_task: Optional[_HANDLER_TYPE] = None
7071
# unfortunately, we cannot create the Queue here because it needs to be
7172
# tied to a currently-running event loop. the sync websocket client
@@ -85,7 +86,7 @@ def is_open(self: Self) -> bool:
8586
self._handler_task is not None
8687
and self._messages is not None
8788
and self._websocket is not None
88-
and self._websocket.open
89+
and self._websocket.state == State.OPEN
8990
)
9091

9192
async def _do_open(self: Self) -> None:
@@ -119,7 +120,7 @@ async def _do_close(self: Self) -> None:
119120
self._messages = None
120121

121122
# close the connection
122-
await cast(websocket_client.WebSocketClientProtocol, self._websocket).close()
123+
await cast(websocket_client.ClientConnection, self._websocket).close()
123124

124125
async def _handler(self: Self) -> None:
125126
"""
@@ -131,9 +132,7 @@ async def _handler(self: Self) -> None:
131132
132133
As long as a given client remains open, this handler will be running as a Task.
133134
"""
134-
async for response in cast(
135-
websocket_client.WebSocketClientProtocol, self._websocket
136-
):
135+
async for response in cast(websocket_client.ClientConnection, self._websocket):
137136
response_dict = json.loads(response)
138137

139138
# if this response corresponds to request, fulfill the Future
@@ -175,7 +174,7 @@ async def _do_send_no_future(self: Self, request: Request) -> None:
175174
Arguments:
176175
request: The request to send.
177176
"""
178-
await cast(websocket_client.WebSocketClientProtocol, self._websocket).send(
177+
await cast(websocket_client.ClientConnection, self._websocket).send(
179178
json.dumps(
180179
request_to_websocket(request),
181180
),

xrpl/models/amounts/issued_currency_amount.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class IssuedCurrencyAmount(IssuedCurrency):
2525
See https://xrpl.org/currency-formats.html#issued-currency-amounts.
2626
"""
2727

28-
value: Union[str, int, float] = REQUIRED # type: ignore
28+
value: Union[str, int, float] = REQUIRED
2929
"""
3030
This field is required.
3131

xrpl/models/amounts/mpt_amount.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@
1818
class MPTAmount(BaseModel):
1919
"""Specifies an MPT amount."""
2020

21-
mpt_issuance_id: str = REQUIRED # type: ignore
21+
mpt_issuance_id: str = REQUIRED
2222
"""
2323
This field is required.
2424
2525
:meta hide-value:
2626
"""
2727

28-
value: str = REQUIRED # type: ignore
28+
value: str = REQUIRED
2929
"""
3030
This field is required.
3131

xrpl/models/auth_account.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
class AuthAccount(NestedModel):
1515
"""Represents one entry in a list of AuthAccounts used in AMMBid transaction."""
1616

17-
account: str = REQUIRED # type: ignore
17+
account: str = REQUIRED
1818
"""
1919
This field is required.
2020

xrpl/models/base_model.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ def _from_dict_single_param(
187187

188188
# no more collections (no params expect a Dict)
189189

190-
if param_type is Any: # type: ignore
190+
if param_type is Any:
191191
# param_type is Any (e.g. will accept anything)
192192
return param_value
193193

@@ -318,7 +318,7 @@ def _check_type(
318318
return {attr: f"{attr} is {type(value)}, expected {expected_type}"}
319319

320320
# unsure what the problem with mypy is here
321-
if expected_type is Any: # type: ignore[comparison-overlap]
321+
if expected_type is Any:
322322
return {}
323323

324324
if expected_type_origin is list:

xrpl/models/currencies/issued_currency.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,14 @@ class IssuedCurrency(BaseModel):
3636
See https://xrpl.org/currency-formats.html#specifying-currency-amounts
3737
"""
3838

39-
currency: str = REQUIRED # type: ignore
39+
currency: str = REQUIRED
4040
"""
4141
This field is required.
4242
4343
:meta hide-value:
4444
"""
4545

46-
issuer: str = REQUIRED # type: ignore
46+
issuer: str = REQUIRED
4747
"""
4848
This field is required.
4949

xrpl/models/currencies/mpt_currency.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class MPTCurrency(BaseModel):
3333
See https://xrpl.org/currency-formats.html#specifying-currency-amounts
3434
"""
3535

36-
mpt_issuance_id: str = REQUIRED # type: ignore
36+
mpt_issuance_id: str = REQUIRED
3737
"""
3838
This field is required.
3939

xrpl/models/requests/account_channels.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class AccountChannels(Request, LookupByLedgerRequest):
3030
"""
3131

3232
method: RequestMethod = field(default=RequestMethod.ACCOUNT_CHANNELS, init=False)
33-
account: str = REQUIRED # type: ignore
33+
account: str = REQUIRED
3434
"""
3535
This field is required.
3636

xrpl/models/requests/account_currencies.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class AccountCurrencies(Request, LookupByLedgerRequest):
2828
`See account_currencies <https://xrpl.org/account_currencies.html>`_
2929
"""
3030

31-
account: str = REQUIRED # type: ignore
31+
account: str = REQUIRED
3232
"""
3333
This field is required.
3434

0 commit comments

Comments
 (0)