Skip to content

Prefix AsyncNonConcurrentMethodChecker methods with underscore #1099

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
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
16 changes: 8 additions & 8 deletions src/neo4j/_async/_debug/_concurrency_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,17 @@ def __make_error(self, tbs):
return NonConcurrentMethodError(msg)

@classmethod
def non_concurrent_method(cls, f: _TWrapped) -> _TWrapped:
def _non_concurrent_method(cls, f: _TWrapped) -> _TWrapped:
if AsyncUtil.is_async_code:
if not inspect.iscoroutinefunction(f):
raise TypeError(
"cannot decorate non-coroutine function with "
"AsyncNonConcurrentMethodChecked.non_concurrent_method"
"AsyncNonConcurrentMethodChecked._non_concurrent_method"
)
elif not callable(f):
raise TypeError(
"cannot decorate non-callable object with "
"NonConcurrentMethodChecked.non_concurrent_method"
"NonConcurrentMethodChecked._non_concurrent_method"
)

@copy_signature(f)
Expand Down Expand Up @@ -100,17 +100,17 @@ async def inner(*args, **kwargs):
return inner

@classmethod
def non_concurrent_iter(cls, f: _TWrappedIter) -> _TWrappedIter:
def _non_concurrent_iter(cls, f: _TWrappedIter) -> _TWrappedIter:
if AsyncUtil.is_async_code:
if not inspect.isasyncgenfunction(f):
raise TypeError(
"cannot decorate non-async-generator function with "
"AsyncNonConcurrentMethodChecked.non_concurrent_iter"
"AsyncNonConcurrentMethodChecked._non_concurrent_iter"
)
elif not inspect.isgeneratorfunction(f):
raise TypeError(
"cannot decorate non-generator function with "
"NonConcurrentMethodChecked.non_concurrent_iter"
"NonConcurrentMethodChecked._non_concurrent_iter"
)

@copy_signature(f)
Expand Down Expand Up @@ -145,9 +145,9 @@ async def inner(*args, **kwargs):
else:

@classmethod
def non_concurrent_method(cls, f: _TWrapped) -> _TWrapped:
def _non_concurrent_method(cls, f: _TWrapped) -> _TWrapped:
return f

@classmethod
def non_concurrent_iter(cls, f: _TWrappedIter) -> _TWrappedIter:
def _non_concurrent_iter(cls, f: _TWrappedIter) -> _TWrappedIter:
return f
24 changes: 12 additions & 12 deletions src/neo4j/_async/work/result.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ def _creation_frame(self) -> t.Literal[False] | inspect.FrameInfo:
assert self._creation_frame_cache is not None # help mypy a little
return self._creation_frame_cache

@AsyncNonConcurrentMethodChecker.non_concurrent_iter
@AsyncNonConcurrentMethodChecker._non_concurrent_iter
async def __aiter__(self) -> t.AsyncIterator[Record]:
"""
Create an iterator returning records.
Expand Down Expand Up @@ -408,7 +408,7 @@ async def __aiter__(self) -> t.AsyncIterator[Record]:
if self._consumed:
raise ResultConsumedError(self, _RESULT_CONSUMED_ERROR)

@AsyncNonConcurrentMethodChecker.non_concurrent_method
@AsyncNonConcurrentMethodChecker._non_concurrent_method
async def __anext__(self) -> Record:
"""
Advance the result stream and return the record.
Expand Down Expand Up @@ -498,7 +498,7 @@ def _tx_failure(self, exc):
self._attached = False
self._exception = exc

@AsyncNonConcurrentMethodChecker.non_concurrent_method
@AsyncNonConcurrentMethodChecker._non_concurrent_method
async def consume(self) -> ResultSummary:
"""
Consume the remainder of this result and return the summary.
Expand Down Expand Up @@ -565,7 +565,7 @@ async def single(
@t.overload
async def single(self, strict: te.Literal[True]) -> Record: ...

@AsyncNonConcurrentMethodChecker.non_concurrent_method
@AsyncNonConcurrentMethodChecker._non_concurrent_method
async def single(self, strict: bool = False) -> Record | None:
"""
Obtain the next and only remaining record or None.
Expand Down Expand Up @@ -631,7 +631,7 @@ async def single(self, strict: bool = False) -> Record | None:
)
return buffer.popleft()

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

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

@AsyncNonConcurrentMethodChecker.non_concurrent_method
@AsyncNonConcurrentMethodChecker._non_concurrent_method
async def graph(self) -> Graph:
"""
Turn the result into a :class:`.Graph`.
Expand All @@ -701,7 +701,7 @@ async def graph(self) -> Graph:
await self._buffer_all()
return self._hydration_scope.get_graph()

@AsyncNonConcurrentMethodChecker.non_concurrent_method
@AsyncNonConcurrentMethodChecker._non_concurrent_method
async def value(
self, key: _TResultKey = 0, default: object = None
) -> list[t.Any]:
Expand All @@ -725,7 +725,7 @@ async def value(
"""
return [record.value(key, default) async for record in self]

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

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

@AsyncNonConcurrentMethodChecker.non_concurrent_method
@AsyncNonConcurrentMethodChecker._non_concurrent_method
async def to_eager_result(self) -> EagerResult:
"""
Convert this result to an :class:`.EagerResult`.
Expand All @@ -801,7 +801,7 @@ async def to_eager_result(self) -> EagerResult:
summary=await self.consume(),
)

@AsyncNonConcurrentMethodChecker.non_concurrent_method
@AsyncNonConcurrentMethodChecker._non_concurrent_method
async def to_df(
self, expand: bool = False, parse_dates: bool = False
) -> pandas.DataFrame:
Expand Down
18 changes: 9 additions & 9 deletions src/neo4j/_async/work/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ async def _verify_authentication(self):
await self._connect(READ_ACCESS, force_auth=True)
await self._disconnect()

@AsyncNonConcurrentMethodChecker.non_concurrent_method
@AsyncNonConcurrentMethodChecker._non_concurrent_method
async def close(self) -> None:
"""
Close the session.
Expand Down Expand Up @@ -253,7 +253,7 @@ def cancel(self) -> None:
"""
self._handle_cancellation(message="manual cancel")

@AsyncNonConcurrentMethodChecker.non_concurrent_method
@AsyncNonConcurrentMethodChecker._non_concurrent_method
async def run(
self,
query: te.LiteralString | Query,
Expand Down Expand Up @@ -334,7 +334,7 @@ async def run(
"`last_bookmark` has been deprecated in favor of `last_bookmarks`. "
"This method can lead to unexpected behaviour."
)
@AsyncNonConcurrentMethodChecker.non_concurrent_method
@AsyncNonConcurrentMethodChecker._non_concurrent_method
async def last_bookmark(self) -> str | None:
"""
Get the bookmark received following the last completed transaction.
Expand Down Expand Up @@ -365,7 +365,7 @@ async def last_bookmark(self) -> str | None:
return self._bookmarks[-1]
return None

@AsyncNonConcurrentMethodChecker.non_concurrent_method
@AsyncNonConcurrentMethodChecker._non_concurrent_method
async def last_bookmarks(self) -> Bookmarks:
"""
Return most recent bookmarks of the session.
Expand Down Expand Up @@ -455,7 +455,7 @@ async def _open_transaction(
pipelined=self._pipelined_begin,
)

@AsyncNonConcurrentMethodChecker.non_concurrent_method
@AsyncNonConcurrentMethodChecker._non_concurrent_method
async def begin_transaction(
self,
metadata: dict[str, t.Any] | None = None,
Expand Down Expand Up @@ -614,7 +614,7 @@ def api_success_cb(meta):
else:
raise ServiceUnavailable("Transaction failed")

@AsyncNonConcurrentMethodChecker.non_concurrent_method
@AsyncNonConcurrentMethodChecker._non_concurrent_method
async def execute_read(
self,
transaction_function: t.Callable[
Expand Down Expand Up @@ -695,7 +695,7 @@ async def get_two_tx(tx):

# TODO: 6.0 - Remove this method
@deprecated("read_transaction has been renamed to execute_read")
@AsyncNonConcurrentMethodChecker.non_concurrent_method
@AsyncNonConcurrentMethodChecker._non_concurrent_method
async def read_transaction(
self,
transaction_function: t.Callable[
Expand Down Expand Up @@ -738,7 +738,7 @@ async def read_transaction(
kwargs,
)

@AsyncNonConcurrentMethodChecker.non_concurrent_method
@AsyncNonConcurrentMethodChecker._non_concurrent_method
async def execute_write(
self,
transaction_function: t.Callable[
Expand Down Expand Up @@ -801,7 +801,7 @@ async def create_node_tx(tx, name):

# TODO: 6.0 - Remove this method
@deprecated("write_transaction has been renamed to execute_write")
@AsyncNonConcurrentMethodChecker.non_concurrent_method
@AsyncNonConcurrentMethodChecker._non_concurrent_method
async def write_transaction(
self,
transaction_function: t.Callable[
Expand Down
12 changes: 6 additions & 6 deletions src/neo4j/_async/work/transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def __init__(
async def _enter(self) -> te.Self:
return self

@AsyncNonConcurrentMethodChecker.non_concurrent_method
@AsyncNonConcurrentMethodChecker._non_concurrent_method
async def _exit(self, exception_type, exception_value, traceback):
if self._closed_flag:
return
Expand All @@ -79,7 +79,7 @@ async def _exit(self, exception_type, exception_value, traceback):
return
await self._close()

@AsyncNonConcurrentMethodChecker.non_concurrent_method
@AsyncNonConcurrentMethodChecker._non_concurrent_method
async def _begin(
self,
database,
Expand Down Expand Up @@ -124,7 +124,7 @@ async def _consume_results(self):
await result._tx_end()
self._results = []

@AsyncNonConcurrentMethodChecker.non_concurrent_method
@AsyncNonConcurrentMethodChecker._non_concurrent_method
async def run(
self,
query: te.LiteralString,
Expand Down Expand Up @@ -196,7 +196,7 @@ async def run(

return result

@AsyncNonConcurrentMethodChecker.non_concurrent_method
@AsyncNonConcurrentMethodChecker._non_concurrent_method
async def _commit(self):
if self._closed_flag:
raise TransactionError(self, "Transaction closed")
Expand All @@ -223,7 +223,7 @@ async def _commit(self):

return self._bookmark

@AsyncNonConcurrentMethodChecker.non_concurrent_method
@AsyncNonConcurrentMethodChecker._non_concurrent_method
async def _rollback(self):
if self._closed_flag:
raise TransactionError(self, "Transaction closed")
Expand All @@ -247,7 +247,7 @@ async def _rollback(self):
self._closed_flag = True
await AsyncUtil.callback(self._on_closed)

@AsyncNonConcurrentMethodChecker.non_concurrent_method
@AsyncNonConcurrentMethodChecker._non_concurrent_method
async def _close(self):
if self._closed_flag:
return
Expand Down
2 changes: 1 addition & 1 deletion src/neo4j/_async/work/workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ async def _disconnect(self, sync=False):
self._connection = None
self._connection_access_mode = None

@AsyncNonConcurrentMethodChecker.non_concurrent_method
@AsyncNonConcurrentMethodChecker._non_concurrent_method
async def close(self) -> None:
if self._closed:
return
Expand Down
16 changes: 8 additions & 8 deletions src/neo4j/_sync/_debug/_concurrency_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,17 @@ def __make_error(self, tbs):
return NonConcurrentMethodError(msg)

@classmethod
def non_concurrent_method(cls, f: _TWrapped) -> _TWrapped:
def _non_concurrent_method(cls, f: _TWrapped) -> _TWrapped:
if Util.is_async_code:
if not inspect.iscoroutinefunction(f):
raise TypeError(
"cannot decorate non-coroutine function with "
"NonConcurrentMethodChecked.non_concurrent_method"
"NonConcurrentMethodChecked._non_concurrent_method"
)
elif not callable(f):
raise TypeError(
"cannot decorate non-callable object with "
"NonConcurrentMethodChecked.non_concurrent_method"
"NonConcurrentMethodChecked._non_concurrent_method"
)

@copy_signature(f)
Expand Down Expand Up @@ -100,17 +100,17 @@ def inner(*args, **kwargs):
return inner

@classmethod
def non_concurrent_iter(cls, f: _TWrappedIter) -> _TWrappedIter:
def _non_concurrent_iter(cls, f: _TWrappedIter) -> _TWrappedIter:
if Util.is_async_code:
if not inspect.isasyncgenfunction(f):
raise TypeError(
"cannot decorate non-async-generator function with "
"NonConcurrentMethodChecked.non_concurrent_iter"
"NonConcurrentMethodChecked._non_concurrent_iter"
)
elif not inspect.isgeneratorfunction(f):
raise TypeError(
"cannot decorate non-generator function with "
"NonConcurrentMethodChecked.non_concurrent_iter"
"NonConcurrentMethodChecked._non_concurrent_iter"
)

@copy_signature(f)
Expand Down Expand Up @@ -145,9 +145,9 @@ def inner(*args, **kwargs):
else:

@classmethod
def non_concurrent_method(cls, f: _TWrapped) -> _TWrapped:
def _non_concurrent_method(cls, f: _TWrapped) -> _TWrapped:
return f

@classmethod
def non_concurrent_iter(cls, f: _TWrappedIter) -> _TWrappedIter:
def _non_concurrent_iter(cls, f: _TWrappedIter) -> _TWrappedIter:
return f
Loading