Skip to content

Commit 38cf54a

Browse files
committed
Fix type warnings due to mypy version update
github CI was using a newer mypy version which started throwing excessive warnings about the meta-operations happening behind the scenes here. The operations aren't wrong or broken, but because they act to fix/repair/mutate some of the underlying python object hierarchies themselves, mypy can't figure out what's happening. Simplest solution is to ignore the false warnings since we know these code paths have been working fine for years already. Also adding mypy to the poetry dev group so maybe we can track mypy version updates better going forward.
1 parent c464f21 commit 38cf54a

File tree

5 files changed

+10
-21
lines changed

5 files changed

+10
-21
lines changed

ib_async/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -213,10 +213,10 @@
213213
# compatibility with old Object
214214
for obj in locals().copy().values():
215215
if dataclasses.is_dataclass(obj):
216-
obj.dict = util.dataclassAsDict
217-
obj.tuple = util.dataclassAsTuple
218-
obj.update = util.dataclassUpdate
219-
obj.nonDefaults = util.dataclassNonDefaults
216+
obj.dict = util.dataclassAsDict # type: ignore
217+
obj.tuple = util.dataclassAsTuple # type: ignore
218+
obj.update = util.dataclassUpdate # type: ignore
219+
obj.nonDefaults = util.dataclassNonDefaults # type: ignore
220220

221221
del sys
222222
del dataclasses

ib_async/objects.py

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -421,12 +421,9 @@ def __init__(self, *args):
421421
super().__init__(*args)
422422
self.updateEvent = Event("updateEvent")
423423

424-
def __eq__(self, other):
424+
def __eq__(self, other) -> bool:
425425
return self is other
426426

427-
def __hash__(self):
428-
return id(self)
429-
430427

431428
class RealTimeBarList(List[RealTimeBar]):
432429
"""
@@ -449,12 +446,9 @@ def __init__(self, *args):
449446
super().__init__(*args)
450447
self.updateEvent = Event("updateEvent")
451448

452-
def __eq__(self, other):
449+
def __eq__(self, other) -> bool:
453450
return self is other
454451

455-
def __hash__(self):
456-
return id(self)
457-
458452

459453
class ScanDataList(List[ScanData]):
460454
"""
@@ -476,9 +470,6 @@ def __init__(self, *args):
476470
def __eq__(self, other):
477471
return self is other
478472

479-
def __hash__(self):
480-
return id(self)
481-
482473

483474
class DynamicObject:
484475
def __init__(self, **kwargs):

ib_async/ticker.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -274,12 +274,9 @@ def __init__(self, *args):
274274
super().__init__(*args)
275275
self.updateEvent = Event("updateEvent")
276276

277-
def __eq__(self, other):
277+
def __eq__(self, other) -> bool:
278278
return self is other
279279

280-
def __hash__(self):
281-
return id(self)
282-
283280

284281
class TimeBars(Op):
285282
__slots__ = (

ib_async/util.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,9 @@ def dataclassUpdate(obj, *srcObjs, **kwargs) -> object:
119119
raise TypeError(f"Object {obj} is not a dataclass")
120120

121121
for srcObj in srcObjs:
122-
obj.__dict__.update(dataclassAsDict(srcObj))
122+
obj.__dict__.update(dataclassAsDict(srcObj)) # type: ignore
123123

124-
obj.__dict__.update(**kwargs)
124+
obj.__dict__.update(**kwargs) # type: ignore
125125
return obj
126126

127127

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ nest_asyncio = "*"
3333
optional = true
3434

3535
[tool.poetry.group.dev.dependencies]
36+
mypy = ">=1.11.0"
3637
pytest = ">=8.0"
3738
pytest-asyncio = ">=0.23"
3839
pandas = "^2.2.1"

0 commit comments

Comments
 (0)