Skip to content

Commit 3096b40

Browse files
ref: upgrade linters to flake8 5.x (getsentry#1610)
1 parent 19720e6 commit 3096b40

15 files changed

Lines changed: 53 additions & 54 deletions

File tree

.flake8

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
[flake8]
2-
ignore =
3-
E203, // Handled by black (Whitespace before ':' -- handled by black)
4-
E266, // Handled by black (Too many leading '#' for block comment)
5-
E501, // Handled by black (Line too long)
6-
W503, // Handled by black (Line break occured before a binary operator)
7-
E402, // Sometimes not possible due to execution order (Module level import is not at top of file)
8-
E731, // I don't care (Do not assign a lambda expression, use a def)
9-
B950, // Handled by black (Line too long by flake8-bugbear)
10-
B011, // I don't care (Do not call assert False)
11-
B014, // does not apply to Python 2 (redundant exception types by flake8-bugbear)
12-
N812, // I don't care (Lowercase imported as non-lowercase by pep8-naming)
13-
N804 // is a worse version of and conflicts with B902 (first argument of a classmethod should be named cls)
14-
max-line-length = 80
15-
select = N,B,C,E,F,W,T4,B9
16-
exclude=checkouts,lol*,.tox
2+
extend-ignore =
3+
# Handled by black (Whitespace before ':' -- handled by black)
4+
E203,
5+
# Handled by black (Line too long)
6+
E501,
7+
# Sometimes not possible due to execution order (Module level import is not at top of file)
8+
E402,
9+
# I don't care (Do not assign a lambda expression, use a def)
10+
E731,
11+
# does not apply to Python 2 (redundant exception types by flake8-bugbear)
12+
B014,
13+
# I don't care (Lowercase imported as non-lowercase by pep8-naming)
14+
N812,
15+
# is a worse version of and conflicts with B902 (first argument of a classmethod should be named cls)
16+
N804,
17+
extend-exclude=checkouts,lol*

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ repos:
1212
hooks:
1313
- id: black
1414

15-
- repo: https://gitlab.com/pycqa/flake8
16-
rev: 3.9.2
15+
- repo: https://github.com/pycqa/flake8
16+
rev: 5.0.4
1717
hooks:
1818
- id: flake8
1919

linter-requirements.txt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
black==22.3.0
2-
flake8==3.9.2
3-
flake8-import-order==0.18.1
2+
flake8==5.0.4
43
mypy==0.961
54
types-certifi
65
types-redis
76
types-setuptools
8-
flake8-bugbear==21.4.3
9-
pep8-naming==0.13.0
7+
flake8-bugbear==22.9.11
8+
pep8-naming==0.13.2
109
pre-commit # local linting

sentry_sdk/_compat.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
PY2 = sys.version_info[0] == 2
1616

1717
if PY2:
18-
import urlparse # noqa
18+
import urlparse
1919

2020
text_type = unicode # noqa
2121

@@ -39,7 +39,7 @@ def implements_str(cls):
3939
text_type = str
4040
string_types = (text_type,) # type: Tuple[type]
4141
number_types = (int, float) # type: Tuple[type, type]
42-
int_types = (int,) # noqa
42+
int_types = (int,)
4343
iteritems = lambda x: x.items()
4444

4545
def implements_str(x):

sentry_sdk/api.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ def add_breadcrumb(
108108

109109

110110
@overload
111-
def configure_scope(): # noqa: F811
111+
def configure_scope():
112112
# type: () -> ContextManager[Scope]
113113
pass
114114

@@ -130,7 +130,7 @@ def configure_scope( # noqa: F811
130130

131131

132132
@overload
133-
def push_scope(): # noqa: F811
133+
def push_scope():
134134
# type: () -> ContextManager[Scope]
135135
pass
136136

@@ -151,31 +151,31 @@ def push_scope( # noqa: F811
151151
return Hub.current.push_scope(callback)
152152

153153

154-
@scopemethod # noqa
154+
@scopemethod
155155
def set_tag(key, value):
156156
# type: (str, Any) -> None
157157
return Hub.current.scope.set_tag(key, value)
158158

159159

160-
@scopemethod # noqa
160+
@scopemethod
161161
def set_context(key, value):
162162
# type: (str, Dict[str, Any]) -> None
163163
return Hub.current.scope.set_context(key, value)
164164

165165

166-
@scopemethod # noqa
166+
@scopemethod
167167
def set_extra(key, value):
168168
# type: (str, Any) -> None
169169
return Hub.current.scope.set_extra(key, value)
170170

171171

172-
@scopemethod # noqa
172+
@scopemethod
173173
def set_user(value):
174174
# type: (Optional[Dict[str, Any]]) -> None
175175
return Hub.current.scope.set_user(value)
176176

177177

178-
@scopemethod # noqa
178+
@scopemethod
179179
def set_level(value):
180180
# type: (str) -> None
181181
return Hub.current.scope.set_level(value)

sentry_sdk/hub.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ def start_transaction(
546546
return transaction
547547

548548
@overload
549-
def push_scope( # noqa: F811
549+
def push_scope(
550550
self, callback=None # type: Optional[None]
551551
):
552552
# type: (...) -> ContextManager[Scope]
@@ -595,7 +595,7 @@ def pop_scope_unsafe(self):
595595
return rv
596596

597597
@overload
598-
def configure_scope( # noqa: F811
598+
def configure_scope(
599599
self, callback=None # type: Optional[None]
600600
):
601601
# type: (...) -> ContextManager[Scope]
@@ -610,7 +610,7 @@ def configure_scope( # noqa: F811
610610

611611
def configure_scope( # noqa
612612
self, callback=None # type: Optional[Callable[[Scope], None]]
613-
): # noqa
613+
):
614614
# type: (...) -> Optional[ContextManager[Scope]]
615615

616616
"""

sentry_sdk/integrations/serverless.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def overload(x):
2727

2828

2929
@overload
30-
def serverless_function(f, flush=True): # noqa: F811
30+
def serverless_function(f, flush=True):
3131
# type: (F, bool) -> F
3232
pass
3333

sentry_sdk/integrations/starlette.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848

4949
try:
5050
# Optional dependency of Starlette to parse form data.
51-
import multipart # type: ignore # noqa: F401
51+
import multipart # type: ignore
5252
except ImportError:
5353
multipart = None
5454

sentry_sdk/profiler.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626

2727
import sentry_sdk
2828
from sentry_sdk._compat import PY2
29-
3029
from sentry_sdk._types import MYPY
3130

3231
if MYPY:

sentry_sdk/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -861,7 +861,7 @@ def _get_contextvars():
861861
# `aiocontextvars` is absolutely required for functional
862862
# contextvars on Python 3.6.
863863
try:
864-
from aiocontextvars import ContextVar # noqa
864+
from aiocontextvars import ContextVar
865865

866866
return True, ContextVar
867867
except ImportError:

0 commit comments

Comments
 (0)