Skip to content

Commit 9a82f7b

Browse files
authored
Update black (#1379)
* Updated black * Reformatted code with new black. * fix(tests): pin werkzeug to a working version. * fix(tests): pin flask version to have working tests.
1 parent 17ea781 commit 9a82f7b

File tree

19 files changed

+78
-83
lines changed

19 files changed

+78
-83
lines changed

linter-requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
black==21.7b0
1+
black==22.3.0
22
flake8==3.9.2
33
flake8-import-order==0.18.1
44
mypy==0.782

sentry_sdk/client.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,6 @@ class get_options(ClientConstructor, Dict[str, Any]): # noqa: N801
451451
class Client(ClientConstructor, _Client):
452452
pass
453453

454-
455454
else:
456455
# Alias `get_options` for actual usage. Go through the lambda indirection
457456
# to throw PyCharm off of the weakly typed signature (it would otherwise

sentry_sdk/hub.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@ def _init(*args, **kwargs):
120120
class init(ClientConstructor, ContextManager[Any]): # noqa: N801
121121
pass
122122

123-
124123
else:
125124
# Alias `init` for actual usage. Go through the lambda indirection to throw
126125
# PyCharm off of the weakly typed signature (it would otherwise discover

sentry_sdk/integrations/_wsgi_common.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ def request_body_within_bounds(client, content_length):
3939
bodies = client.options["request_bodies"]
4040
return not (
4141
bodies == "never"
42-
or (bodies == "small" and content_length > 10 ** 3)
43-
or (bodies == "medium" and content_length > 10 ** 4)
42+
or (bodies == "small" and content_length > 10**3)
43+
or (bodies == "medium" and content_length > 10**4)
4444
)
4545

4646

sentry_sdk/integrations/django/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ def is_authenticated(request_user):
6969
# type: (Any) -> bool
7070
return request_user.is_authenticated()
7171

72-
7372
else:
7473

7574
def is_authenticated(request_user):
@@ -202,7 +201,7 @@ def _django_queryset_repr(value, hint):
202201
# querysets. This might be surprising to the user but it's likely
203202
# less annoying.
204203

205-
return u"<%s from %s at 0x%x>" % (
204+
return "<%s from %s at 0x%x>" % (
206205
value.__class__.__name__,
207206
value.__module__,
208207
id(value),

sentry_sdk/integrations/pyramid.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ def authenticated_userid(request):
4040
# type: (Request) -> Optional[Any]
4141
return request.authenticated_userid
4242

43-
4443
else:
4544
# bw-compat for pyramid < 1.5
4645
from pyramid.security import authenticated_userid # type: ignore

sentry_sdk/integrations/wsgi.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ def wsgi_decoding_dance(s, charset="utf-8", errors="replace"):
4646
# type: (str, str, str) -> str
4747
return s.decode(charset, errors)
4848

49-
5049
else:
5150

5251
def wsgi_decoding_dance(s, charset="utf-8", errors="replace"):

sentry_sdk/serializer.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,11 @@
6666
# Can be overwritten if wanting to send more bytes, e.g. with a custom server.
6767
# When changing this, keep in mind that events may be a little bit larger than
6868
# this value due to attached metadata, so keep the number conservative.
69-
MAX_EVENT_BYTES = 10 ** 6
69+
MAX_EVENT_BYTES = 10**6
7070

7171
MAX_DATABAG_DEPTH = 5
7272
MAX_DATABAG_BREADTH = 10
73-
CYCLE_MARKER = u"<cyclic>"
73+
CYCLE_MARKER = "<cyclic>"
7474

7575

7676
global_repr_processors = [] # type: List[ReprProcessor]
@@ -228,7 +228,7 @@ def _serialize_node(
228228
capture_internal_exception(sys.exc_info())
229229

230230
if is_databag:
231-
return u"<failed to serialize, use init(debug=True) to see error logs>"
231+
return "<failed to serialize, use init(debug=True) to see error logs>"
232232

233233
return None
234234
finally:

sentry_sdk/tracing.py

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -132,14 +132,17 @@ def init_span_recorder(self, maxlen):
132132

133133
def __repr__(self):
134134
# type: () -> str
135-
return "<%s(op=%r, description:%r, trace_id=%r, span_id=%r, parent_span_id=%r, sampled=%r)>" % (
136-
self.__class__.__name__,
137-
self.op,
138-
self.description,
139-
self.trace_id,
140-
self.span_id,
141-
self.parent_span_id,
142-
self.sampled,
135+
return (
136+
"<%s(op=%r, description:%r, trace_id=%r, span_id=%r, parent_span_id=%r, sampled=%r)>"
137+
% (
138+
self.__class__.__name__,
139+
self.op,
140+
self.description,
141+
self.trace_id,
142+
self.span_id,
143+
self.parent_span_id,
144+
self.sampled,
145+
)
143146
)
144147

145148
def __enter__(self):
@@ -515,14 +518,17 @@ def __init__(
515518

516519
def __repr__(self):
517520
# type: () -> str
518-
return "<%s(name=%r, op=%r, trace_id=%r, span_id=%r, parent_span_id=%r, sampled=%r)>" % (
519-
self.__class__.__name__,
520-
self.name,
521-
self.op,
522-
self.trace_id,
523-
self.span_id,
524-
self.parent_span_id,
525-
self.sampled,
521+
return (
522+
"<%s(name=%r, op=%r, trace_id=%r, span_id=%r, parent_span_id=%r, sampled=%r)>"
523+
% (
524+
self.__class__.__name__,
525+
self.name,
526+
self.op,
527+
self.trace_id,
528+
self.span_id,
529+
self.parent_span_id,
530+
self.sampled,
531+
)
526532
)
527533

528534
@property

sentry_sdk/utils.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ def __init__(self, value):
161161
return
162162
parts = urlparse.urlsplit(text_type(value))
163163

164-
if parts.scheme not in (u"http", u"https"):
164+
if parts.scheme not in ("http", "https"):
165165
raise BadDsn("Unsupported scheme %r" % parts.scheme)
166166
self.scheme = parts.scheme
167167

@@ -280,7 +280,7 @@ def to_header(self, timestamp=None):
280280
rv.append(("sentry_client", self.client))
281281
if self.secret_key is not None:
282282
rv.append(("sentry_secret", self.secret_key))
283-
return u"Sentry " + u", ".join("%s=%s" % (key, value) for key, value in rv)
283+
return "Sentry " + ", ".join("%s=%s" % (key, value) for key, value in rv)
284284

285285

286286
class AnnotatedValue(object):
@@ -440,8 +440,7 @@ def safe_repr(value):
440440
return rv
441441
except Exception:
442442
# If e.g. the call to `repr` already fails
443-
return u"<broken repr>"
444-
443+
return "<broken repr>"
445444

446445
else:
447446

@@ -606,7 +605,6 @@ def walk_exception_chain(exc_info):
606605
exc_value = cause
607606
tb = getattr(cause, "__traceback__", None)
608607

609-
610608
else:
611609

612610
def walk_exception_chain(exc_info):
@@ -772,7 +770,7 @@ def strip_string(value, max_length=None):
772770

773771
if length > max_length:
774772
return AnnotatedValue(
775-
value=value[: max_length - 3] + u"...",
773+
value=value[: max_length - 3] + "...",
776774
metadata={
777775
"len": length,
778776
"rem": [["!limit", "x", max_length - 3, max_length]],

0 commit comments

Comments
 (0)