Skip to content

Commit a5802e6

Browse files
authored
chore: removing python2 types in compat.py (#13306)
## Checklist - [X] PR author has checked that all the criteria below are met - The PR description includes an overview of the change - The PR description articulates the motivation for the change - The change includes tests OR the PR description describes a testing strategy - The PR description notes risks associated with the change, if any - Newly-added code is easy to change - The change follows the [library release note guidelines](https://ddtrace.readthedocs.io/en/stable/releasenotes.html) - The change includes or references documentation updates if necessary - Backport labels are set (if [applicable](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting)) ## Reviewer Checklist - [x] Reviewer has checked that all the criteria below are met - Title is accurate - All changes are related to the pull request's stated goal - Avoids breaking [API](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces) changes - Testing strategy adequately addresses listed risks - Newly-added code is easy to change - Release note makes sense to a user of the library - If necessary, author has acknowledged and discussed the performance implications of this PR as reported in the benchmarks PR comment - Backport labels are set in a manner that is consistent with the [release branch maintenance policy](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting)
1 parent 3c2015e commit a5802e6

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

ddtrace/internal/compat.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
import ipaddress
33
import sys
44
from types import TracebackType
5-
from typing import Any # noqa:F401
6-
from typing import AnyStr # noqa:F401
5+
from typing import Any
6+
from typing import AnyStr
77
from typing import Optional # noqa:F401
88
from typing import Text # noqa:F401
99
from typing import Tuple # noqa:F401
@@ -37,8 +37,7 @@ def ensure_binary(s, encoding="utf-8", errors="ignore") -> bytes:
3737
NumericType = Union[int, float]
3838

3939

40-
def is_integer(obj):
41-
# type: (Any) -> bool
40+
def is_integer(obj: Any) -> bool:
4241
"""Helper to determine if the provided ``obj`` is an integer type or not"""
4342
# DEV: We have to make sure it is an integer and not a boolean
4443
# >>> type(True)
@@ -70,8 +69,7 @@ async def func_wrapper(*args, **kwargs):
7069

7170

7271
# DEV: There is `six.u()` which does something similar, but doesn't have the guard around `hasattr(s, 'decode')`
73-
def to_unicode(s):
74-
# type: (AnyStr) -> Text
72+
def to_unicode(s: AnyStr) -> Text:
7573
"""Return a unicode string for the given bytes or string instance."""
7674
# No reason to decode if we already have the unicode compatible object we expect
7775
# DEV: `six.text_type` will be a `str` for python 3 and `unicode` for python 2
@@ -90,8 +88,7 @@ def to_unicode(s):
9088
return str(s)
9189

9290

93-
def maybe_stringify(obj):
94-
# type: (Any) -> Optional[str]
91+
def maybe_stringify(obj: Any) -> Optional[str]:
9592
if obj is not None:
9693
return str(obj)
9794
return None
@@ -109,8 +106,7 @@ def is_valid_ip(ip: str) -> bool:
109106
return False
110107

111108

112-
def ip_is_global(ip):
113-
# type: (str) -> bool
109+
def ip_is_global(ip: str) -> bool:
114110
"""
115111
is_global is Python 3+ only. This could raise a ValueError if the IP is not valid.
116112
"""

0 commit comments

Comments
 (0)