Skip to content

Commit

Permalink
ci(mypy): remove type callable ignores (backport #4253) (#4258)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
4 people authored Oct 4, 2022
1 parent c4586be commit 3cf4fc5
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 17 deletions.
2 changes: 1 addition & 1 deletion ddtrace/profiling/collector/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,5 +77,5 @@ def _create_capture_sampler(collector):

@attr.s
class CaptureSamplerCollector(Collector):
capture_pct = attr.ib(factory=attr_utils.from_env("DD_PROFILING_CAPTURE_PCT", 1.0, float)) # type: ignore[arg-type]
capture_pct = attr.ib(factory=attr_utils.from_env("DD_PROFILING_CAPTURE_PCT", 1.0, float))
_capture_sampler = attr.ib(default=attr.Factory(_create_capture_sampler, takes_self=True), init=False, repr=False)
2 changes: 1 addition & 1 deletion ddtrace/profiling/collector/_lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ def __get__(self, instance, owner=None):
class LockCollector(collector.CaptureSamplerCollector):
"""Record lock usage."""

nframes = attr.ib(factory=attr_utils.from_env("DD_PROFILING_MAX_FRAMES", 64, int)) # type: ignore[arg-type]
nframes = attr.ib(factory=attr_utils.from_env("DD_PROFILING_MAX_FRAMES", 64, int))
endpoint_collection_enabled = attr.ib(
factory=attr_utils.from_env("DD_PROFILING_ENDPOINT_COLLECTION_ENABLED", True, formats.asbool)
)
Expand Down
10 changes: 2 additions & 8 deletions ddtrace/profiling/collector/memalloc.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,8 @@ class MemoryCollector(collector.PeriodicCollector):
_interval = attr.ib(default=_DEFAULT_INTERVAL, repr=False)

# TODO make this dynamic based on the 1. interval and 2. the max number of events allowed in the Recorder
_max_events = attr.ib(
factory=attr_utils.from_env(
"_DD_PROFILING_MEMORY_EVENTS_BUFFER",
_DEFAULT_MAX_EVENTS,
int, # type: ignore[arg-type]
)
)
max_nframe = attr.ib(factory=attr_utils.from_env("DD_PROFILING_MAX_FRAMES", 64, int)) # type: ignore[arg-type]
_max_events = attr.ib(factory=attr_utils.from_env("_DD_PROFILING_MEMORY_EVENTS_BUFFER", _DEFAULT_MAX_EVENTS, int))
max_nframe = attr.ib(factory=attr_utils.from_env("DD_PROFILING_MAX_FRAMES", 64, int))
heap_sample_size = attr.ib(type=int, factory=_get_default_heap_sample_size)
ignore_profiler = attr.ib(factory=attr_utils.from_env("DD_PROFILING_IGNORE_PROFILER", False, formats.asbool))

Expand Down
5 changes: 1 addition & 4 deletions ddtrace/profiling/exporter/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,7 @@ class PprofHTTPExporter(pprof.PprofExporter):
api_key = attr.ib(default=None, type=typing.Optional[str])
# Do not use the default agent timeout: it is too short, the agent is just a unbuffered proxy and the profiling
# backend is not as fast as the tracer one.
timeout = attr.ib(
factory=attr_utils.from_env("DD_PROFILING_API_TIMEOUT", 10.0, float), # type: ignore[arg-type]
type=float,
)
timeout = attr.ib(factory=attr_utils.from_env("DD_PROFILING_API_TIMEOUT", 10.0, float), type=float)
service = attr.ib(default=None, type=typing.Optional[str])
env = attr.ib(default=None, type=typing.Optional[str])
version = attr.ib(default=None, type=typing.Optional[str])
Expand Down
4 changes: 1 addition & 3 deletions ddtrace/profiling/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ class Scheduler(periodic.PeriodicService):
recorder = attr.ib()
exporters = attr.ib()
before_flush = attr.ib(default=None, eq=False)
_interval = attr.ib(
factory=attr_utils.from_env("DD_PROFILING_UPLOAD_INTERVAL", 60.0, float) # type: ignore[arg-type]
)
_interval = attr.ib(factory=attr_utils.from_env("DD_PROFILING_UPLOAD_INTERVAL", 60.0, float))
_configured_interval = attr.ib(init=False)
_last_export = attr.ib(init=False, default=None, eq=False)

Expand Down

0 comments on commit 3cf4fc5

Please sign in to comment.