-
Notifications
You must be signed in to change notification settings - Fork 417
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 <kyle@verhoog.ca> (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 <35776586+Yun-Kim@users.noreply.github.com> Co-authored-by: Munir Abdinur <munir.abdinur@datadoghq.com> Co-authored-by: Munir Abdinur <munir_abdinur@hotmail.com> Co-authored-by: Yun Kim <35776586+Yun-Kim@users.noreply.github.com> Co-authored-by: Brett Langdon <brett.langdon@datadoghq.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Co-authored-by: Munir Abdinur <munir.abdinur@datadoghq.com> Co-authored-by: Munir Abdinur <munir_abdinur@hotmail.com> (cherry picked from commit 026d614) # Conflicts: # ddtrace/debugging/_debugger.py # ddtrace/internal/utils/cache.py # ddtrace/profiling/collector/asyncio.py
- Loading branch information
1 parent
d38b463
commit f7f1d10
Showing
10 changed files
with
720 additions
and
13 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import typing | ||
|
||
import attr | ||
|
||
from . import _lock | ||
from .. import collector | ||
from .. import event | ||
|
||
|
||
@event.event_class | ||
class AsyncioLockAcquireEvent(_lock.LockAcquireEvent): | ||
"""An asyncio.Lock has been acquired.""" | ||
|
||
|
||
@event.event_class | ||
class AsyncioLockReleaseEvent(_lock.LockReleaseEvent): | ||
"""An asyncio.Lock has been released.""" | ||
|
||
|
||
class _ProfiledAsyncioLock(_lock._ProfiledLock): | ||
|
||
ACQUIRE_EVENT_CLASS = AsyncioLockAcquireEvent | ||
RELEASE_EVENT_CLASS = AsyncioLockReleaseEvent | ||
|
||
|
||
@attr.s | ||
class AsyncioLockCollector(_lock.LockCollector): | ||
"""Record asyncio.Lock usage.""" | ||
|
||
PROFILED_LOCK_CLASS = _ProfiledAsyncioLock | ||
|
||
def _start_service(self): | ||
# type: (...) -> None | ||
"""Start collecting lock usage.""" | ||
try: | ||
import asyncio | ||
except ImportError as e: | ||
raise collector.CollectorUnavailable(e) | ||
self._asyncio_module = asyncio | ||
return super(AsyncioLockCollector, self)._start_service() | ||
|
||
def _get_original(self): | ||
# type: (...) -> typing.Any | ||
return self._asyncio_module.Lock | ||
|
||
def _set_original( | ||
self, value # type: typing.Any | ||
): | ||
# type: (...) -> None | ||
self._asyncio_module.Lock = value # type: ignore[misc] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters