Skip to content

Commit fa3808f

Browse files
committed
fix existing ruff & mypy errors
1 parent 910fbcd commit fa3808f

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

otlp_psqlpy/__init__.py

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import re
22
import typing as t
3+
from collections.abc import Awaitable, Mapping, Sequence
34

45
import psqlpy
56
import wrapt # type: ignore[import-untyped]
@@ -171,7 +172,13 @@ def _uninstrument(self, **__: t.Any) -> None:
171172
for method_name in methods:
172173
unwrap(cls, method_name)
173174

174-
async def _do_execute(self, func, instance, args, kwargs):
175+
async def _do_execute(
176+
self,
177+
func: t.Callable[..., Awaitable[t.Any]],
178+
instance: t.Union[psqlpy.Connection, psqlpy.Transaction, psqlpy.Cursor],
179+
args: Sequence[t.Any],
180+
kwargs: Mapping[str, t.Any],
181+
) -> t.Any:
175182
exception = None
176183
params = getattr(instance, "_params", {})
177184
name = args[0] if args else params.get("database", "postgresql")
@@ -182,20 +189,20 @@ async def _do_execute(self, func, instance, args, kwargs):
182189
except IndexError:
183190
name = ""
184191

185-
with self._tracer.start_as_current_span(
192+
with self._tracer.start_as_current_span( # type: ignore[union-attr]
186193
name,
187194
kind=SpanKind.CLIENT,
188195
) as span:
189196
if span.is_recording():
190197
span_attributes = _construct_span(
191198
instance,
192-
_retrieve_parameter_from_args_or_kwargs(
199+
_retrieve_parameter_from_args_or_kwargs( # type: ignore[arg-type]
193200
parameter_name="querystring",
194201
parameter_index=0,
195202
args=args,
196203
kwargs=kwargs,
197204
),
198-
_retrieve_parameter_from_args_or_kwargs(
205+
_retrieve_parameter_from_args_or_kwargs( # type: ignore[arg-type]
199206
parameter_name="parameters",
200207
parameter_index=1,
201208
args=args,
@@ -222,12 +229,18 @@ async def _do_execute(self, func, instance, args, kwargs):
222229

223230
return result
224231

225-
async def _do_cursor_execute(self, func, instance, args, kwargs):
232+
async def _do_cursor_execute(
233+
self,
234+
func: t.Callable[..., Awaitable[t.Any]],
235+
instance: psqlpy.Cursor,
236+
args: Sequence[t.Any],
237+
kwargs: Mapping[str, t.Any],
238+
) -> t.Any:
226239
"""Wrap cursor based functions. For every call this will generate a new span."""
227240
exception = None
228241

229242
stop = False
230-
with self._tracer.start_as_current_span(
243+
with self._tracer.start_as_current_span( # type: ignore[union-attr]
231244
"CURSOR",
232245
kind=SpanKind.CLIENT,
233246
) as span:

0 commit comments

Comments
 (0)