Skip to content

Commit d418d2b

Browse files
authored
Merge pull request #1099 from robsdedude/fix/prefix-debugging-helper-methods-with-underscore
Prefix AsyncNonConcurrentMethodChecker methods with underscore
2 parents a6a8bbf + df3ef62 commit d418d2b

File tree

10 files changed

+72
-72
lines changed

10 files changed

+72
-72
lines changed

src/neo4j/_async/_debug/_concurrency_check.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -62,17 +62,17 @@ def __make_error(self, tbs):
6262
return NonConcurrentMethodError(msg)
6363

6464
@classmethod
65-
def non_concurrent_method(cls, f: _TWrapped) -> _TWrapped:
65+
def _non_concurrent_method(cls, f: _TWrapped) -> _TWrapped:
6666
if AsyncUtil.is_async_code:
6767
if not inspect.iscoroutinefunction(f):
6868
raise TypeError(
6969
"cannot decorate non-coroutine function with "
70-
"AsyncNonConcurrentMethodChecked.non_concurrent_method"
70+
"AsyncNonConcurrentMethodChecked._non_concurrent_method"
7171
)
7272
elif not callable(f):
7373
raise TypeError(
7474
"cannot decorate non-callable object with "
75-
"NonConcurrentMethodChecked.non_concurrent_method"
75+
"NonConcurrentMethodChecked._non_concurrent_method"
7676
)
7777

7878
@copy_signature(f)
@@ -100,17 +100,17 @@ async def inner(*args, **kwargs):
100100
return inner
101101

102102
@classmethod
103-
def non_concurrent_iter(cls, f: _TWrappedIter) -> _TWrappedIter:
103+
def _non_concurrent_iter(cls, f: _TWrappedIter) -> _TWrappedIter:
104104
if AsyncUtil.is_async_code:
105105
if not inspect.isasyncgenfunction(f):
106106
raise TypeError(
107107
"cannot decorate non-async-generator function with "
108-
"AsyncNonConcurrentMethodChecked.non_concurrent_iter"
108+
"AsyncNonConcurrentMethodChecked._non_concurrent_iter"
109109
)
110110
elif not inspect.isgeneratorfunction(f):
111111
raise TypeError(
112112
"cannot decorate non-generator function with "
113-
"NonConcurrentMethodChecked.non_concurrent_iter"
113+
"NonConcurrentMethodChecked._non_concurrent_iter"
114114
)
115115

116116
@copy_signature(f)
@@ -145,9 +145,9 @@ async def inner(*args, **kwargs):
145145
else:
146146

147147
@classmethod
148-
def non_concurrent_method(cls, f: _TWrapped) -> _TWrapped:
148+
def _non_concurrent_method(cls, f: _TWrapped) -> _TWrapped:
149149
return f
150150

151151
@classmethod
152-
def non_concurrent_iter(cls, f: _TWrappedIter) -> _TWrappedIter:
152+
def _non_concurrent_iter(cls, f: _TWrappedIter) -> _TWrappedIter:
153153
return f

src/neo4j/_async/work/result.py

+12-12
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ def _creation_frame(self) -> t.Literal[False] | inspect.FrameInfo:
375375
assert self._creation_frame_cache is not None # help mypy a little
376376
return self._creation_frame_cache
377377

378-
@AsyncNonConcurrentMethodChecker.non_concurrent_iter
378+
@AsyncNonConcurrentMethodChecker._non_concurrent_iter
379379
async def __aiter__(self) -> t.AsyncIterator[Record]:
380380
"""
381381
Create an iterator returning records.
@@ -408,7 +408,7 @@ async def __aiter__(self) -> t.AsyncIterator[Record]:
408408
if self._consumed:
409409
raise ResultConsumedError(self, _RESULT_CONSUMED_ERROR)
410410

411-
@AsyncNonConcurrentMethodChecker.non_concurrent_method
411+
@AsyncNonConcurrentMethodChecker._non_concurrent_method
412412
async def __anext__(self) -> Record:
413413
"""
414414
Advance the result stream and return the record.
@@ -498,7 +498,7 @@ def _tx_failure(self, exc):
498498
self._attached = False
499499
self._exception = exc
500500

501-
@AsyncNonConcurrentMethodChecker.non_concurrent_method
501+
@AsyncNonConcurrentMethodChecker._non_concurrent_method
502502
async def consume(self) -> ResultSummary:
503503
"""
504504
Consume the remainder of this result and return the summary.
@@ -565,7 +565,7 @@ async def single(
565565
@t.overload
566566
async def single(self, strict: te.Literal[True]) -> Record: ...
567567

568-
@AsyncNonConcurrentMethodChecker.non_concurrent_method
568+
@AsyncNonConcurrentMethodChecker._non_concurrent_method
569569
async def single(self, strict: bool = False) -> Record | None:
570570
"""
571571
Obtain the next and only remaining record or None.
@@ -631,7 +631,7 @@ async def single(self, strict: bool = False) -> Record | None:
631631
)
632632
return buffer.popleft()
633633

634-
@AsyncNonConcurrentMethodChecker.non_concurrent_method
634+
@AsyncNonConcurrentMethodChecker._non_concurrent_method
635635
async def fetch(self, n: int) -> list[Record]:
636636
"""
637637
Obtain up to n records from this result.
@@ -655,7 +655,7 @@ async def fetch(self, n: int) -> list[Record]:
655655
for _ in range(min(n, len(self._record_buffer)))
656656
]
657657

658-
@AsyncNonConcurrentMethodChecker.non_concurrent_method
658+
@AsyncNonConcurrentMethodChecker._non_concurrent_method
659659
async def peek(self) -> Record | None:
660660
"""
661661
Obtain the next record from this result without consuming it.
@@ -677,7 +677,7 @@ async def peek(self) -> Record | None:
677677
return self._record_buffer[0]
678678
return None
679679

680-
@AsyncNonConcurrentMethodChecker.non_concurrent_method
680+
@AsyncNonConcurrentMethodChecker._non_concurrent_method
681681
async def graph(self) -> Graph:
682682
"""
683683
Turn the result into a :class:`.Graph`.
@@ -701,7 +701,7 @@ async def graph(self) -> Graph:
701701
await self._buffer_all()
702702
return self._hydration_scope.get_graph()
703703

704-
@AsyncNonConcurrentMethodChecker.non_concurrent_method
704+
@AsyncNonConcurrentMethodChecker._non_concurrent_method
705705
async def value(
706706
self, key: _TResultKey = 0, default: object = None
707707
) -> list[t.Any]:
@@ -725,7 +725,7 @@ async def value(
725725
"""
726726
return [record.value(key, default) async for record in self]
727727

728-
@AsyncNonConcurrentMethodChecker.non_concurrent_method
728+
@AsyncNonConcurrentMethodChecker._non_concurrent_method
729729
async def values(self, *keys: _TResultKey) -> list[list[t.Any]]:
730730
"""
731731
Return the remainder of the result as a list of values lists.
@@ -746,7 +746,7 @@ async def values(self, *keys: _TResultKey) -> list[list[t.Any]]:
746746
"""
747747
return [record.values(*keys) async for record in self]
748748

749-
@AsyncNonConcurrentMethodChecker.non_concurrent_method
749+
@AsyncNonConcurrentMethodChecker._non_concurrent_method
750750
async def data(self, *keys: _TResultKey) -> list[dict[str, t.Any]]:
751751
"""
752752
Return the remainder of the result as a list of dictionaries.
@@ -776,7 +776,7 @@ async def data(self, *keys: _TResultKey) -> list[dict[str, t.Any]]:
776776
"""
777777
return [record.data(*keys) async for record in self]
778778

779-
@AsyncNonConcurrentMethodChecker.non_concurrent_method
779+
@AsyncNonConcurrentMethodChecker._non_concurrent_method
780780
async def to_eager_result(self) -> EagerResult:
781781
"""
782782
Convert this result to an :class:`.EagerResult`.
@@ -801,7 +801,7 @@ async def to_eager_result(self) -> EagerResult:
801801
summary=await self.consume(),
802802
)
803803

804-
@AsyncNonConcurrentMethodChecker.non_concurrent_method
804+
@AsyncNonConcurrentMethodChecker._non_concurrent_method
805805
async def to_df(
806806
self, expand: bool = False, parse_dates: bool = False
807807
) -> pandas.DataFrame:

src/neo4j/_async/work/session.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ async def _verify_authentication(self):
184184
await self._connect(READ_ACCESS, force_auth=True)
185185
await self._disconnect()
186186

187-
@AsyncNonConcurrentMethodChecker.non_concurrent_method
187+
@AsyncNonConcurrentMethodChecker._non_concurrent_method
188188
async def close(self) -> None:
189189
"""
190190
Close the session.
@@ -253,7 +253,7 @@ def cancel(self) -> None:
253253
"""
254254
self._handle_cancellation(message="manual cancel")
255255

256-
@AsyncNonConcurrentMethodChecker.non_concurrent_method
256+
@AsyncNonConcurrentMethodChecker._non_concurrent_method
257257
async def run(
258258
self,
259259
query: te.LiteralString | Query,
@@ -334,7 +334,7 @@ async def run(
334334
"`last_bookmark` has been deprecated in favor of `last_bookmarks`. "
335335
"This method can lead to unexpected behaviour."
336336
)
337-
@AsyncNonConcurrentMethodChecker.non_concurrent_method
337+
@AsyncNonConcurrentMethodChecker._non_concurrent_method
338338
async def last_bookmark(self) -> str | None:
339339
"""
340340
Get the bookmark received following the last completed transaction.
@@ -365,7 +365,7 @@ async def last_bookmark(self) -> str | None:
365365
return self._bookmarks[-1]
366366
return None
367367

368-
@AsyncNonConcurrentMethodChecker.non_concurrent_method
368+
@AsyncNonConcurrentMethodChecker._non_concurrent_method
369369
async def last_bookmarks(self) -> Bookmarks:
370370
"""
371371
Return most recent bookmarks of the session.
@@ -455,7 +455,7 @@ async def _open_transaction(
455455
pipelined=self._pipelined_begin,
456456
)
457457

458-
@AsyncNonConcurrentMethodChecker.non_concurrent_method
458+
@AsyncNonConcurrentMethodChecker._non_concurrent_method
459459
async def begin_transaction(
460460
self,
461461
metadata: dict[str, t.Any] | None = None,
@@ -614,7 +614,7 @@ def api_success_cb(meta):
614614
else:
615615
raise ServiceUnavailable("Transaction failed")
616616

617-
@AsyncNonConcurrentMethodChecker.non_concurrent_method
617+
@AsyncNonConcurrentMethodChecker._non_concurrent_method
618618
async def execute_read(
619619
self,
620620
transaction_function: t.Callable[
@@ -695,7 +695,7 @@ async def get_two_tx(tx):
695695

696696
# TODO: 6.0 - Remove this method
697697
@deprecated("read_transaction has been renamed to execute_read")
698-
@AsyncNonConcurrentMethodChecker.non_concurrent_method
698+
@AsyncNonConcurrentMethodChecker._non_concurrent_method
699699
async def read_transaction(
700700
self,
701701
transaction_function: t.Callable[
@@ -738,7 +738,7 @@ async def read_transaction(
738738
kwargs,
739739
)
740740

741-
@AsyncNonConcurrentMethodChecker.non_concurrent_method
741+
@AsyncNonConcurrentMethodChecker._non_concurrent_method
742742
async def execute_write(
743743
self,
744744
transaction_function: t.Callable[
@@ -801,7 +801,7 @@ async def create_node_tx(tx, name):
801801

802802
# TODO: 6.0 - Remove this method
803803
@deprecated("write_transaction has been renamed to execute_write")
804-
@AsyncNonConcurrentMethodChecker.non_concurrent_method
804+
@AsyncNonConcurrentMethodChecker._non_concurrent_method
805805
async def write_transaction(
806806
self,
807807
transaction_function: t.Callable[

src/neo4j/_async/work/transaction.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def __init__(
6767
async def _enter(self) -> te.Self:
6868
return self
6969

70-
@AsyncNonConcurrentMethodChecker.non_concurrent_method
70+
@AsyncNonConcurrentMethodChecker._non_concurrent_method
7171
async def _exit(self, exception_type, exception_value, traceback):
7272
if self._closed_flag:
7373
return
@@ -79,7 +79,7 @@ async def _exit(self, exception_type, exception_value, traceback):
7979
return
8080
await self._close()
8181

82-
@AsyncNonConcurrentMethodChecker.non_concurrent_method
82+
@AsyncNonConcurrentMethodChecker._non_concurrent_method
8383
async def _begin(
8484
self,
8585
database,
@@ -124,7 +124,7 @@ async def _consume_results(self):
124124
await result._tx_end()
125125
self._results = []
126126

127-
@AsyncNonConcurrentMethodChecker.non_concurrent_method
127+
@AsyncNonConcurrentMethodChecker._non_concurrent_method
128128
async def run(
129129
self,
130130
query: te.LiteralString,
@@ -196,7 +196,7 @@ async def run(
196196

197197
return result
198198

199-
@AsyncNonConcurrentMethodChecker.non_concurrent_method
199+
@AsyncNonConcurrentMethodChecker._non_concurrent_method
200200
async def _commit(self):
201201
if self._closed_flag:
202202
raise TransactionError(self, "Transaction closed")
@@ -223,7 +223,7 @@ async def _commit(self):
223223

224224
return self._bookmark
225225

226-
@AsyncNonConcurrentMethodChecker.non_concurrent_method
226+
@AsyncNonConcurrentMethodChecker._non_concurrent_method
227227
async def _rollback(self):
228228
if self._closed_flag:
229229
raise TransactionError(self, "Transaction closed")
@@ -247,7 +247,7 @@ async def _rollback(self):
247247
self._closed_flag = True
248248
await AsyncUtil.callback(self._on_closed)
249249

250-
@AsyncNonConcurrentMethodChecker.non_concurrent_method
250+
@AsyncNonConcurrentMethodChecker._non_concurrent_method
251251
async def _close(self):
252252
if self._closed_flag:
253253
return

src/neo4j/_async/work/workspace.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ async def _disconnect(self, sync=False):
197197
self._connection = None
198198
self._connection_access_mode = None
199199

200-
@AsyncNonConcurrentMethodChecker.non_concurrent_method
200+
@AsyncNonConcurrentMethodChecker._non_concurrent_method
201201
async def close(self) -> None:
202202
if self._closed:
203203
return

src/neo4j/_sync/_debug/_concurrency_check.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -62,17 +62,17 @@ def __make_error(self, tbs):
6262
return NonConcurrentMethodError(msg)
6363

6464
@classmethod
65-
def non_concurrent_method(cls, f: _TWrapped) -> _TWrapped:
65+
def _non_concurrent_method(cls, f: _TWrapped) -> _TWrapped:
6666
if Util.is_async_code:
6767
if not inspect.iscoroutinefunction(f):
6868
raise TypeError(
6969
"cannot decorate non-coroutine function with "
70-
"NonConcurrentMethodChecked.non_concurrent_method"
70+
"NonConcurrentMethodChecked._non_concurrent_method"
7171
)
7272
elif not callable(f):
7373
raise TypeError(
7474
"cannot decorate non-callable object with "
75-
"NonConcurrentMethodChecked.non_concurrent_method"
75+
"NonConcurrentMethodChecked._non_concurrent_method"
7676
)
7777

7878
@copy_signature(f)
@@ -100,17 +100,17 @@ def inner(*args, **kwargs):
100100
return inner
101101

102102
@classmethod
103-
def non_concurrent_iter(cls, f: _TWrappedIter) -> _TWrappedIter:
103+
def _non_concurrent_iter(cls, f: _TWrappedIter) -> _TWrappedIter:
104104
if Util.is_async_code:
105105
if not inspect.isasyncgenfunction(f):
106106
raise TypeError(
107107
"cannot decorate non-async-generator function with "
108-
"NonConcurrentMethodChecked.non_concurrent_iter"
108+
"NonConcurrentMethodChecked._non_concurrent_iter"
109109
)
110110
elif not inspect.isgeneratorfunction(f):
111111
raise TypeError(
112112
"cannot decorate non-generator function with "
113-
"NonConcurrentMethodChecked.non_concurrent_iter"
113+
"NonConcurrentMethodChecked._non_concurrent_iter"
114114
)
115115

116116
@copy_signature(f)
@@ -145,9 +145,9 @@ def inner(*args, **kwargs):
145145
else:
146146

147147
@classmethod
148-
def non_concurrent_method(cls, f: _TWrapped) -> _TWrapped:
148+
def _non_concurrent_method(cls, f: _TWrapped) -> _TWrapped:
149149
return f
150150

151151
@classmethod
152-
def non_concurrent_iter(cls, f: _TWrappedIter) -> _TWrappedIter:
152+
def _non_concurrent_iter(cls, f: _TWrappedIter) -> _TWrappedIter:
153153
return f

0 commit comments

Comments
 (0)