Skip to content

Upgraded linting tooling #2026

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: 3.9
python-version: 3.11

- run: |
pip install tox
Expand Down
2 changes: 1 addition & 1 deletion linter-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
mypy==0.971
mypy==1.2.0
black==22.12.0
flake8==5.0.4
types-certifi
Expand Down
2 changes: 1 addition & 1 deletion mypy.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[mypy]
python_version = 3.7
python_version = 3.11
allow_redefinition = True
check_untyped_defs = True
; disallow_any_decorated = True
Expand Down
2 changes: 1 addition & 1 deletion sentry_sdk/integrations/asyncio.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ async def _coro_creating_hub_and_span():

# Trying to use user set task factory (if there is one)
if orig_task_factory:
return orig_task_factory(loop, _coro_creating_hub_and_span()) # type: ignore
return orig_task_factory(loop, _coro_creating_hub_and_span())

# The default task factory in `asyncio` does not have its own function
# but is just a couple of lines in `asyncio.base_events.create_task()`
Expand Down
2 changes: 1 addition & 1 deletion sentry_sdk/integrations/celery.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@


try:
from celery import VERSION as CELERY_VERSION
from celery import VERSION as CELERY_VERSION # type: ignore
from celery import Task, Celery
from celery.app.trace import task_has_custom
from celery.beat import Scheduler # type: ignore
Expand Down
4 changes: 2 additions & 2 deletions sentry_sdk/integrations/django/signals_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ def _get_receiver_name(receiver):
elif hasattr(
receiver, "func"
): # certain functions (like partials) dont have a name
if hasattr(receiver, "func") and hasattr(receiver.func, "__name__"): # type: ignore
name = "partial(<function " + receiver.func.__name__ + ">)" # type: ignore
if hasattr(receiver, "func") and hasattr(receiver.func, "__name__"):
name = "partial(<function " + receiver.func.__name__ + ">)"

if (
name == ""
Expand Down
4 changes: 2 additions & 2 deletions sentry_sdk/integrations/socket.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def create_connection(
address=address, timeout=timeout, source_address=source_address
)

socket.create_connection = create_connection
socket.create_connection = create_connection # type: ignore


def _patch_getaddrinfo():
Expand All @@ -86,4 +86,4 @@ def getaddrinfo(host, port, family=0, type=0, proto=0, flags=0):

return real_getaddrinfo(host, port, family, type, proto, flags)

socket.getaddrinfo = getaddrinfo
socket.getaddrinfo = getaddrinfo # type: ignore
2 changes: 1 addition & 1 deletion sentry_sdk/integrations/tornado.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ async def sentry_execute_request_handler(self, *args, **kwargs):
else:

@coroutine # type: ignore
def sentry_execute_request_handler(self, *args, **kwargs): # type: ignore
def sentry_execute_request_handler(self, *args, **kwargs):
# type: (RequestHandler, *Any, **Any) -> Any
with _handle_request_impl(self):
result = yield from old_execute(self, *args, **kwargs)
Expand Down
4 changes: 2 additions & 2 deletions sentry_sdk/integrations/wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
WsgiExcInfo = TypeVar("WsgiExcInfo")

class StartResponse(Protocol):
def __call__(self, status, response_headers, exc_info=None):
def __call__(self, status, response_headers, exc_info=None): # type: ignore
# type: (str, WsgiResponseHeaders, Optional[WsgiExcInfo]) -> WsgiResponseIter
pass

Expand Down Expand Up @@ -119,7 +119,7 @@ def __call__(self, environ, start_response):
return _ScopedResponse(hub, rv)


def _sentry_start_response(
def _sentry_start_response( # type: ignore
old_start_response, # type: StartResponse
transaction, # type: Transaction
status, # type: str
Expand Down
2 changes: 1 addition & 1 deletion sentry_sdk/profiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ def extract_frame(frame, cwd):

def get_frame_name(frame):
# type: (FrameType) -> str
return frame.f_code.co_qualname # type: ignore
return frame.f_code.co_qualname

else:

Expand Down
2 changes: 1 addition & 1 deletion sentry_sdk/tracing.py
Original file line number Diff line number Diff line change
Expand Up @@ -781,7 +781,7 @@ def start_child(self, instrumenter=INSTRUMENTER.SENTRY, **kwargs):

def new_span(self, **kwargs):
# type: (**Any) -> NoOpSpan
pass
return self.start_child(**kwargs)

def set_tag(self, key, value):
# type: (str, Any) -> None
Expand Down
4 changes: 2 additions & 2 deletions sentry_sdk/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1077,10 +1077,10 @@ def qualname_from_function(func):
if (
_PARTIALMETHOD_AVAILABLE
and hasattr(func, "_partialmethod")
and isinstance(func._partialmethod, partialmethod) # type: ignore
and isinstance(func._partialmethod, partialmethod)
):
prefix, suffix = "partialmethod(<function ", ">)"
func = func._partialmethod.func # type: ignore
func = func._partialmethod.func
elif isinstance(func, partial) and hasattr(func.func, "__name__"):
prefix, suffix = "partial(<function ", ">)"
func = func.func
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ basepython =
# some random Python 3 binary, but then you get guaranteed mismatches with
# CI. Other tools such as mypy and black have options that pin the Python
# version.
linters: python3.9
linters: python3.11

commands =
; https://github.com/pytest-dev/pytest/issues/5532
Expand Down