Skip to content

Commit 026d614

Browse files
mergify[bot]Yun-Kimbrettlangdonmabdinur
authored
fix(typing): update types to be compatible with latest mypy (backport #4234) (#4263)
* fix(typing): update types to be compatible with latest mypy (#4234) * Initial mypy fixes for CI * Ignored mypy error with type and type constructors * Fix formatting * Fixed incorrect typing * Undo initial change Co-authored-by: Kyle Verhoog <[email protected]> (cherry picked from commit 5140de4) * ci(mypy): remove type callable ignores (backport #4253) (#4258) * Remove ignores for updated mypy (#4253) Mypy==0.982 has just been released and fixed the inherent type/callable type hinting that was the problem from #4234. As a result, the type ignore comments added in #4234 to bypass the type/callable issue are not unneeded and are breaking CI. (cherry picked from commit 0ba3e29) # Conflicts: # ddtrace/profiling/collector/memalloc.py # ddtrace/profiling/exporter/http.py * fix conflicts Co-authored-by: Yun Kim <[email protected]> Co-authored-by: Munir Abdinur <[email protected]> Co-authored-by: Munir Abdinur <[email protected]> Co-authored-by: Yun Kim <[email protected]> Co-authored-by: Brett Langdon <[email protected]> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Co-authored-by: Munir Abdinur <[email protected]> Co-authored-by: Munir Abdinur <[email protected]>
1 parent 5d9b158 commit 026d614

File tree

10 files changed

+17
-18
lines changed

10 files changed

+17
-18
lines changed

ddtrace/debugging/_debugger.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -596,14 +596,14 @@ def _on_configuration(self, event, probes):
596596
else:
597597
raise ValueError("Unknown probe poller event %r" % event)
598598

599-
def _stop_service(self): # type: ignore[override]
599+
def _stop_service(self):
600600
# type: () -> None
601601
self._function_store.restore_all()
602602
for service in self._services:
603603
service.stop()
604604
service.join()
605605

606-
def _start_service(self): # type: ignore[override]
606+
def _start_service(self):
607607
# type: () -> None
608608
for service in self._services:
609609
service.start()

ddtrace/internal/atexit.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def register(
4545
return func
4646

4747
def unregister(func):
48-
# type: (typing.Callable[..., None]) -> None
48+
# type: (typing.Callable[..., typing.Any]) -> None
4949
"""
5050
Unregister an exit function which was previously registered using
5151
atexit.register.

ddtrace/internal/runtime/runtime_metrics.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ def flush(self):
148148
log.debug("Writing metric %s:%s", key, value)
149149
self._dogstatsd_client.distribution(key, value)
150150

151-
def _stop_service(self): # type: ignore[override]
151+
def _stop_service(self):
152152
# type: (...) -> None
153153
# De-register span hook
154154
super(RuntimeWorker, self)._stop_service()

ddtrace/internal/utils/cache.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@
99
miss = object()
1010

1111
T = TypeVar("T")
12-
S = TypeVar("S")
13-
F = Callable[[T], S]
14-
M = Callable[[Any, T], S]
12+
F = Callable[[T], Any]
13+
M = Callable[[Any, T], Any]
1514

1615

1716
class LFUCache(dict):
@@ -29,7 +28,7 @@ def __init__(self, maxsize=256):
2928
self.lock = RLock()
3029

3130
def get(self, key, f): # type: ignore[override]
32-
# type: (T, F) -> S
31+
# type: (T, F) -> Any
3332
"""Get a value from the cache.
3433
3534
If the value with the given key is not in the cache, the expensive
@@ -69,7 +68,7 @@ def cached_wrapper(f):
6968
cache = LFUCache(maxsize)
7069

7170
def cached_f(key):
72-
# type: (T) -> S
71+
# type: (T) -> Any
7372
return cache.get(key, f)
7473

7574
cached_f.invalidate = cache.clear # type: ignore[attr-defined]

ddtrace/internal/writer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,7 @@ def flush_queue(self, raise_exc=False):
587587
def periodic(self):
588588
self.flush_queue(raise_exc=False)
589589

590-
def _stop_service( # type: ignore[override]
590+
def _stop_service(
591591
self,
592592
timeout=None, # type: Optional[float]
593593
):

ddtrace/profiling/collector/_lock.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,13 +203,13 @@ def _set_original(
203203
# type: (...) -> None
204204
pass
205205

206-
def _start_service(self): # type: ignore[override]
206+
def _start_service(self):
207207
# type: (...) -> None
208208
"""Start collecting lock usage."""
209209
self.patch()
210210
super(LockCollector, self)._start_service()
211211

212-
def _stop_service(self): # type: ignore[override]
212+
def _stop_service(self):
213213
# type: (...) -> None
214214
"""Stop collecting lock usage."""
215215
super(LockCollector, self)._stop_service()

ddtrace/profiling/collector/asyncio.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class AsyncioLockCollector(_lock.LockCollector):
2929

3030
PROFILED_LOCK_CLASS = _ProfiledAsyncioLock
3131

32-
def _start_service(self): # type: ignore[override]
32+
def _start_service(self):
3333
# type: (...) -> None
3434
"""Start collecting lock usage."""
3535
try:

ddtrace/profiling/collector/memalloc.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ class MemoryCollector(collector.PeriodicCollector):
9393
heap_sample_size = attr.ib(type=int, factory=_get_default_heap_sample_size)
9494
ignore_profiler = attr.ib(factory=attr_utils.from_env("DD_PROFILING_IGNORE_PROFILER", False, formats.asbool))
9595

96-
def _start_service(self): # type: ignore[override]
96+
def _start_service(self):
9797
# type: (...) -> None
9898
"""Start collecting memory profiles."""
9999
if _memalloc is None:
@@ -103,7 +103,7 @@ def _start_service(self): # type: ignore[override]
103103

104104
super(MemoryCollector, self)._start_service()
105105

106-
def _stop_service(self): # type: ignore[override]
106+
def _stop_service(self):
107107
# type: (...) -> None
108108
super(MemoryCollector, self)._stop_service()
109109

ddtrace/profiling/profiler.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ def copy(self):
252252
}
253253
)
254254

255-
def _start_service(self): # type: ignore[override]
255+
def _start_service(self):
256256
# type: (...) -> None
257257
"""Start the profiler."""
258258
collectors = []
@@ -270,7 +270,7 @@ def _start_service(self): # type: ignore[override]
270270
if self._scheduler is not None:
271271
self._scheduler.start()
272272

273-
def _stop_service( # type: ignore[override]
273+
def _stop_service(
274274
self, flush=True # type: bool
275275
):
276276
# type: (...) -> None

ddtrace/profiling/scheduler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def __attrs_post_init__(self):
2828
# Copy the value to use it later since we're going to adjust the real interval
2929
self._configured_interval = self.interval
3030

31-
def _start_service(self): # type: ignore[override]
31+
def _start_service(self):
3232
# type: (...) -> None
3333
"""Start the scheduler."""
3434
LOG.debug("Starting scheduler")

0 commit comments

Comments
 (0)