diff --git a/CHANGELOG.md b/CHANGELOG.md index 4d971f81a..c591d17d7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## Version 5.3 - Python 3.11 support added +- Removed undocumented, unused `neo4j.data.map_type` - Query strings are now typed `LiteralString` instead of `str` to help mitigate accidental Cypher injections. There are rare use-cases where a computed string is necessary. Please use `# type: ignore`, or `typing.cast` to diff --git a/neo4j/_async/bookmark_manager.py b/neo4j/_async/bookmark_manager.py index 8fc5d0930..627b0fd4a 100644 --- a/neo4j/_async/bookmark_manager.py +++ b/neo4j/_async/bookmark_manager.py @@ -29,9 +29,9 @@ ) -T_BmSupplier = t.Callable[[t.Optional[str]], - t.Union[Bookmarks, t.Awaitable[Bookmarks]]] -T_BmConsumer = t.Callable[[str, Bookmarks], t.Union[None, t.Awaitable[None]]] +TBmSupplier = t.Callable[[t.Optional[str]], + t.Union[Bookmarks, t.Awaitable[Bookmarks]]] +TBmConsumer = t.Callable[[str, Bookmarks], t.Union[None, t.Awaitable[None]]] def _bookmarks_to_set( @@ -47,8 +47,8 @@ def __init__( self, initial_bookmarks: t.Optional[t.Mapping[str, t.Union[Bookmarks, t.Iterable[str]]]] = None, - bookmarks_supplier: t.Optional[T_BmSupplier] = None, - bookmarks_consumer: t.Optional[T_BmConsumer] = None + bookmarks_supplier: t.Optional[TBmSupplier] = None, + bookmarks_consumer: t.Optional[TBmConsumer] = None ) -> None: super().__init__() self._bookmarks_supplier = bookmarks_supplier diff --git a/neo4j/_async/driver.py b/neo4j/_async/driver.py index d77de374b..44130deef 100644 --- a/neo4j/_async/driver.py +++ b/neo4j/_async/driver.py @@ -68,8 +68,8 @@ ) from .bookmark_manager import ( AsyncNeo4jBookmarkManager, - T_BmConsumer as _T_BmConsumer, - T_BmSupplier as _T_BmSupplier, + TBmConsumer as _TBmConsumer, + TBmSupplier as _TBmSupplier, ) from .work import AsyncSession @@ -137,7 +137,7 @@ def driver(cls, uri, *, auth=None, **config) -> AsyncDriver: TRUST_ALL_CERTIFICATES, TRUST_SYSTEM_CA_SIGNED_CERTIFICATES ): - from neo4j.exceptions import ConfigurationError + from ..exceptions import ConfigurationError raise ConfigurationError( "The config setting `trust` values are {!r}" .format( @@ -164,7 +164,7 @@ def driver(cls, uri, *, auth=None, **config) -> AsyncDriver: or "trust" in config.keys() or "trusted_certificates" in config.keys() or "ssl_context" in config.keys())): - from neo4j.exceptions import ConfigurationError + from ..exceptions import ConfigurationError # TODO: 6.0 remove "trust" from error message raise ConfigurationError( @@ -222,8 +222,8 @@ def bookmark_manager( cls, initial_bookmarks: t.Optional[t.Mapping[str, t.Union[Bookmarks, t.Iterable[str]]]] = None, - bookmarks_supplier: t.Optional[_T_BmSupplier] = None, - bookmarks_consumer: t.Optional[_T_BmConsumer] = None + bookmarks_supplier: t.Optional[_TBmSupplier] = None, + bookmarks_consumer: t.Optional[_TBmConsumer] = None ) -> AsyncBookmarkManager: """Create a :class:`.AsyncBookmarkManager` with default implementation. @@ -306,7 +306,7 @@ def bolt_driver(cls, target, *, auth=None, **config): try: return AsyncBoltDriver.open(target, auth=auth, **config) except (BoltHandshakeError, BoltSecurityError) as error: - from neo4j.exceptions import ServiceUnavailable + from ..exceptions import ServiceUnavailable raise ServiceUnavailable(str(error)) from error @classmethod @@ -314,7 +314,7 @@ def neo4j_driver(cls, *targets, auth=None, routing_context=None, **config): """ Create a driver for routing-capable Neo4j service access that uses socket I/O and thread-based concurrency. """ - from neo4j._exceptions import ( + from .._exceptions import ( BoltHandshakeError, BoltSecurityError, ) @@ -322,7 +322,7 @@ def neo4j_driver(cls, *targets, auth=None, routing_context=None, **config): try: return AsyncNeo4jDriver.open(*targets, auth=auth, routing_context=routing_context, **config) except (BoltHandshakeError, BoltSecurityError) as error: - from neo4j.exceptions import ServiceUnavailable + from ..exceptions import ServiceUnavailable raise ServiceUnavailable(str(error)) from error diff --git a/neo4j/_async/io/_bolt.py b/neo4j/_async/io/_bolt.py index ffa2d6d2b..8865e09cf 100644 --- a/neo4j/_async/io/_bolt.py +++ b/neo4j/_async/io/_bolt.py @@ -20,7 +20,6 @@ import abc import asyncio -import socket from collections import deque from logging import getLogger from time import perf_counter @@ -139,7 +138,7 @@ def __init__(self, unresolved_address, sock, max_connection_lifetime, *, if not auth: self.auth_dict = {} elif isinstance(auth, tuple) and 2 <= len(auth) <= 3: - from neo4j import Auth + from ...api import Auth self.auth_dict = vars(Auth("basic", *auth)) else: try: diff --git a/neo4j/_async/io/_pool.py b/neo4j/_async/io/_pool.py index e578a6f8d..7749d01d2 100644 --- a/neo4j/_async/io/_pool.py +++ b/neo4j/_async/io/_pool.py @@ -698,7 +698,7 @@ async def ensure_routing_table_is_fresh( :returns: `True` if an update was required, `False` otherwise. """ - from neo4j.api import READ_ACCESS + from ...api import READ_ACCESS async with self.refresh_lock: for database_ in list(self.routing_tables.keys()): # Remove unused databases in the routing table @@ -766,7 +766,7 @@ async def acquire( .format(timeout)) - from neo4j.api import check_access_mode + from ...api import check_access_mode access_mode = check_access_mode(access_mode) # await self.ensure_routing_table_is_fresh( # access_mode=access_mode, database=database, imp_user=None, diff --git a/neo4j/_async/work/result.py b/neo4j/_async/work/result.py index 3f34721fd..ffcf18679 100644 --- a/neo4j/_async/work/result.py +++ b/neo4j/_async/work/result.py @@ -54,7 +54,7 @@ _T = t.TypeVar("_T") -_T_ResultKey = t.Union[int, str] +_TResultKey = t.Union[int, str] _RESULT_OUT_OF_SCOPE_ERROR = ( @@ -534,7 +534,7 @@ async def graph(self) -> Graph: return self._hydration_scope.get_graph() async def value( - self, key: _T_ResultKey = 0, default: t.Optional[object] = None + self, key: _TResultKey = 0, default: t.Optional[object] = None ) -> t.List[t.Any]: """Return the remainder of the result as a list of values. @@ -555,7 +555,7 @@ async def value( return [record.value(key, default) async for record in self] async def values( - self, *keys: _T_ResultKey + self, *keys: _TResultKey ) -> t.List[t.List[t.Any]]: """Return the remainder of the result as a list of values lists. @@ -574,7 +574,7 @@ async def values( """ return [record.values(*keys) async for record in self] - async def data(self, *keys: _T_ResultKey) -> t.List[t.Dict[str, t.Any]]: + async def data(self, *keys: _TResultKey) -> t.List[t.Dict[str, t.Any]]: """Return the remainder of the result as a list of dictionaries. This function provides a convenient but opinionated way to obtain the diff --git a/neo4j/_async_compat/concurrency.py b/neo4j/_async_compat/concurrency.py index 6c6145438..a4751a982 100644 --- a/neo4j/_async_compat/concurrency.py +++ b/neo4j/_async_compat/concurrency.py @@ -28,7 +28,7 @@ if t.TYPE_CHECKING: import typing_extensions as te -from neo4j._async_compat.shims import wait_for +from .shims import wait_for __all__ = [ diff --git a/neo4j/_async_compat/network/_bolt_socket.py b/neo4j/_async_compat/network/_bolt_socket.py index 768ebe28b..cdbe28524 100644 --- a/neo4j/_async_compat/network/_bolt_socket.py +++ b/neo4j/_async_compat/network/_bolt_socket.py @@ -39,13 +39,6 @@ SSLSocket, ) - -if t.TYPE_CHECKING: - import typing_extensions as te - - from ..._async.io import AsyncBolt - from ..._sync.io import Bolt - from ... import addressing from ..._deadline import Deadline from ..._exceptions import ( @@ -65,6 +58,13 @@ ) +if t.TYPE_CHECKING: + import typing_extensions as te + + from ..._async.io import AsyncBolt + from ..._sync.io import Bolt + + log = logging.getLogger("neo4j") diff --git a/neo4j/_data.py b/neo4j/_data.py index 3d2081626..9a680f77d 100644 --- a/neo4j/_data.py +++ b/neo4j/_data.py @@ -43,7 +43,7 @@ _T = t.TypeVar("_T") -_T_K = t.Union[int, str] +_K = t.Union[int, str] class Record(tuple, Mapping): @@ -119,7 +119,7 @@ def __iter__(self) -> t.Iterator[t.Any]: yield v def __getitem__( # type: ignore[override] - self, key: t.Union[_T_K, slice] + self, key: t.Union[_K, slice] ) -> t.Any: if isinstance(key, slice): keys = self.__keys[key] @@ -158,7 +158,7 @@ def get(self, key: str, default: t.Optional[object] = None) -> t.Any: else: return default - def index(self, key: _T_K) -> int: # type: ignore[override] + def index(self, key: _K) -> int: # type: ignore[override] """ Return the index of the given item. :param key: a key @@ -172,13 +172,13 @@ def index(self, key: _T_K) -> int: # type: ignore[override] elif isinstance(key, str): try: return self.__keys.index(key) - except ValueError: - raise KeyError(key) + except ValueError as exc: + raise KeyError(key) from exc else: raise TypeError(key) def value( - self, key: _T_K = 0, default: t.Optional[object] = None + self, key: _K = 0, default: t.Optional[object] = None ) -> t.Any: """ Obtain a single value from the record by index or key. If no index or key is specified, the first value is returned. If the @@ -203,7 +203,7 @@ def keys(self) -> t.List[str]: # type: ignore[override] """ return list(self.__keys) - def values(self, *keys: _T_K) -> t.List[t.Any]: # type: ignore[override] + def values(self, *keys: _K) -> t.List[t.Any]: # type: ignore[override] """ Return the values of the record, optionally filtering to include only certain values by index or key. @@ -242,7 +242,7 @@ def items(self, *keys): return list((self.__keys[i], self._super_getitem_single(i)) for i in range(len(self))) - def data(self, *keys: _T_K) -> t.Dict[str, t.Any]: + def data(self, *keys: _K) -> t.Dict[str, t.Any]: """ Return the keys and values of this record as a dictionary, optionally including only certain values by index or key. Keys provided in the items that are not in the record will be @@ -293,14 +293,14 @@ def transform(self, x): elif isinstance(x, str): return x elif isinstance(x, Sequence): - t = type(x) - return t(map(self.transform, x)) + typ = type(x) + return typ(map(self.transform, x)) elif isinstance(x, Set): - t = type(x) - return t(map(self.transform, x)) + typ = type(x) + return typ(map(self.transform, x)) elif isinstance(x, Mapping): - t = type(x) - return t((k, self.transform(v)) for k, v in x.items()) + typ = type(x) + return typ((k, self.transform(v)) for k, v in x.items()) else: return x @@ -310,12 +310,12 @@ class RecordTableRowExporter(DataTransformer): def transform(self, x): assert isinstance(x, Mapping) - t = type(x) - return t(item - for k, v in x.items() - for item in self._transform( - v, prefix=k.replace("\\", "\\\\").replace(".", "\\.") - ).items()) + typ = type(x) + return typ(item + for k, v in x.items() + for item in self._transform( + v, prefix=k.replace("\\", "\\\\").replace(".", "\\.") + ).items()) def _transform(self, x, prefix): if isinstance(x, Node): @@ -345,8 +345,8 @@ def _transform(self, x, prefix): ).items() ) elif isinstance(x, Mapping): - t = type(x) - return t( + typ = type(x) + return typ( item for k, v in x.items() for item in self._transform( diff --git a/neo4j/_routing.py b/neo4j/_routing.py index 86d31a730..7d0a020e9 100644 --- a/neo4j/_routing.py +++ b/neo4j/_routing.py @@ -64,7 +64,7 @@ def remove(self, element): try: del self._elements[element] except KeyError: - raise ValueError(element) + raise ValueError(element) from None def update(self, elements=()): self._elements.update(dict.fromkeys(elements)) @@ -97,8 +97,8 @@ def parse_routing_info(cls, *, database, servers, ttl): readers.extend(addresses) elif role == "WRITE": writers.extend(addresses) - except (KeyError, TypeError): - raise ValueError("Cannot parse routing info") + except (KeyError, TypeError) as exc: + raise ValueError("Cannot parse routing info") from exc else: return cls(database=database, routers=routers, readers=readers, writers=writers, ttl=ttl) @@ -147,7 +147,7 @@ def should_be_purged_from_memory(self): :returns: Returns true if it is old and not used for a while. :rtype: bool """ - from neo4j._conf import RoutingConfig + from ._conf import RoutingConfig perf_time = perf_counter() res = self.last_updated_time + self.ttl + RoutingConfig.routing_table_purge_delay <= perf_time log.debug("[#0000] _: purge check: " diff --git a/neo4j/_sync/bookmark_manager.py b/neo4j/_sync/bookmark_manager.py index 49212d531..740041bfc 100644 --- a/neo4j/_sync/bookmark_manager.py +++ b/neo4j/_sync/bookmark_manager.py @@ -29,9 +29,9 @@ ) -T_BmSupplier = t.Callable[[t.Optional[str]], - t.Union[Bookmarks, t.Union[Bookmarks]]] -T_BmConsumer = t.Callable[[str, Bookmarks], t.Union[None, t.Union[None]]] +TBmSupplier = t.Callable[[t.Optional[str]], + t.Union[Bookmarks, t.Union[Bookmarks]]] +TBmConsumer = t.Callable[[str, Bookmarks], t.Union[None, t.Union[None]]] def _bookmarks_to_set( @@ -47,8 +47,8 @@ def __init__( self, initial_bookmarks: t.Optional[t.Mapping[str, t.Union[Bookmarks, t.Iterable[str]]]] = None, - bookmarks_supplier: t.Optional[T_BmSupplier] = None, - bookmarks_consumer: t.Optional[T_BmConsumer] = None + bookmarks_supplier: t.Optional[TBmSupplier] = None, + bookmarks_consumer: t.Optional[TBmConsumer] = None ) -> None: super().__init__() self._bookmarks_supplier = bookmarks_supplier diff --git a/neo4j/_sync/driver.py b/neo4j/_sync/driver.py index c06491f8f..304837bfd 100644 --- a/neo4j/_sync/driver.py +++ b/neo4j/_sync/driver.py @@ -65,8 +65,8 @@ ) from .bookmark_manager import ( Neo4jBookmarkManager, - T_BmConsumer as _T_BmConsumer, - T_BmSupplier as _T_BmSupplier, + TBmConsumer as _TBmConsumer, + TBmSupplier as _TBmSupplier, ) from .work import Session @@ -134,7 +134,7 @@ def driver(cls, uri, *, auth=None, **config) -> Driver: TRUST_ALL_CERTIFICATES, TRUST_SYSTEM_CA_SIGNED_CERTIFICATES ): - from neo4j.exceptions import ConfigurationError + from ..exceptions import ConfigurationError raise ConfigurationError( "The config setting `trust` values are {!r}" .format( @@ -161,7 +161,7 @@ def driver(cls, uri, *, auth=None, **config) -> Driver: or "trust" in config.keys() or "trusted_certificates" in config.keys() or "ssl_context" in config.keys())): - from neo4j.exceptions import ConfigurationError + from ..exceptions import ConfigurationError # TODO: 6.0 remove "trust" from error message raise ConfigurationError( @@ -219,8 +219,8 @@ def bookmark_manager( cls, initial_bookmarks: t.Optional[t.Mapping[str, t.Union[Bookmarks, t.Iterable[str]]]] = None, - bookmarks_supplier: t.Optional[_T_BmSupplier] = None, - bookmarks_consumer: t.Optional[_T_BmConsumer] = None + bookmarks_supplier: t.Optional[_TBmSupplier] = None, + bookmarks_consumer: t.Optional[_TBmConsumer] = None ) -> BookmarkManager: """Create a :class:`.BookmarkManager` with default implementation. @@ -303,7 +303,7 @@ def bolt_driver(cls, target, *, auth=None, **config): try: return BoltDriver.open(target, auth=auth, **config) except (BoltHandshakeError, BoltSecurityError) as error: - from neo4j.exceptions import ServiceUnavailable + from ..exceptions import ServiceUnavailable raise ServiceUnavailable(str(error)) from error @classmethod @@ -311,7 +311,7 @@ def neo4j_driver(cls, *targets, auth=None, routing_context=None, **config): """ Create a driver for routing-capable Neo4j service access that uses socket I/O and thread-based concurrency. """ - from neo4j._exceptions import ( + from .._exceptions import ( BoltHandshakeError, BoltSecurityError, ) @@ -319,7 +319,7 @@ def neo4j_driver(cls, *targets, auth=None, routing_context=None, **config): try: return Neo4jDriver.open(*targets, auth=auth, routing_context=routing_context, **config) except (BoltHandshakeError, BoltSecurityError) as error: - from neo4j.exceptions import ServiceUnavailable + from ..exceptions import ServiceUnavailable raise ServiceUnavailable(str(error)) from error diff --git a/neo4j/_sync/io/_bolt.py b/neo4j/_sync/io/_bolt.py index 57fb780d2..9980b8c71 100644 --- a/neo4j/_sync/io/_bolt.py +++ b/neo4j/_sync/io/_bolt.py @@ -20,7 +20,6 @@ import abc import asyncio -import socket from collections import deque from logging import getLogger from time import perf_counter @@ -139,7 +138,7 @@ def __init__(self, unresolved_address, sock, max_connection_lifetime, *, if not auth: self.auth_dict = {} elif isinstance(auth, tuple) and 2 <= len(auth) <= 3: - from neo4j import Auth + from ...api import Auth self.auth_dict = vars(Auth("basic", *auth)) else: try: diff --git a/neo4j/_sync/io/_pool.py b/neo4j/_sync/io/_pool.py index c0c8842e1..5f256aa58 100644 --- a/neo4j/_sync/io/_pool.py +++ b/neo4j/_sync/io/_pool.py @@ -698,7 +698,7 @@ def ensure_routing_table_is_fresh( :returns: `True` if an update was required, `False` otherwise. """ - from neo4j.api import READ_ACCESS + from ...api import READ_ACCESS with self.refresh_lock: for database_ in list(self.routing_tables.keys()): # Remove unused databases in the routing table @@ -766,7 +766,7 @@ def acquire( .format(timeout)) - from neo4j.api import check_access_mode + from ...api import check_access_mode access_mode = check_access_mode(access_mode) # await self.ensure_routing_table_is_fresh( # access_mode=access_mode, database=database, imp_user=None, diff --git a/neo4j/_sync/work/result.py b/neo4j/_sync/work/result.py index 8702b84c6..0f467d6b2 100644 --- a/neo4j/_sync/work/result.py +++ b/neo4j/_sync/work/result.py @@ -54,7 +54,7 @@ _T = t.TypeVar("_T") -_T_ResultKey = t.Union[int, str] +_TResultKey = t.Union[int, str] _RESULT_OUT_OF_SCOPE_ERROR = ( @@ -534,7 +534,7 @@ def graph(self) -> Graph: return self._hydration_scope.get_graph() def value( - self, key: _T_ResultKey = 0, default: t.Optional[object] = None + self, key: _TResultKey = 0, default: t.Optional[object] = None ) -> t.List[t.Any]: """Return the remainder of the result as a list of values. @@ -555,7 +555,7 @@ def value( return [record.value(key, default) for record in self] def values( - self, *keys: _T_ResultKey + self, *keys: _TResultKey ) -> t.List[t.List[t.Any]]: """Return the remainder of the result as a list of values lists. @@ -574,7 +574,7 @@ def values( """ return [record.values(*keys) for record in self] - def data(self, *keys: _T_ResultKey) -> t.List[t.Dict[str, t.Any]]: + def data(self, *keys: _TResultKey) -> t.List[t.Dict[str, t.Any]]: """Return the remainder of the result as a list of dictionaries. This function provides a convenient but opinionated way to obtain the diff --git a/neo4j/addressing.py b/neo4j/addressing.py index 21257df2f..6e26fc6d7 100644 --- a/neo4j/addressing.py +++ b/neo4j/addressing.py @@ -82,19 +82,19 @@ class Address(tuple, metaclass=_AddressMeta): @classmethod def from_socket( - cls: t.Type[_T_Address], + cls: t.Type[_TAddress], socket: _WithPeerName - ) -> _T_Address: + ) -> _TAddress: address = socket.getpeername() return cls(address) @classmethod def parse( - cls: t.Type[_T_Address], + cls: t.Type[_TAddress], s: str, default_host: t.Optional[str] = None, default_port: t.Optional[int] = None - ) -> _T_Address: + ) -> _TAddress: if not isinstance(s, str): raise TypeError("Address.parse requires a string argument") if s.startswith("["): @@ -120,11 +120,11 @@ def parse( @classmethod def parse_list( - cls: t.Type[_T_Address], + cls: t.Type[_TAddress], *s: str, default_host: t.Optional[str] = None, default_port: t.Optional[int] = None - ) -> t.List[_T_Address]: + ) -> t.List[_TAddress]: """ Parse a string containing one or more socket addresses, each separated by whitespace. """ @@ -182,7 +182,7 @@ def port_number(self) -> int: raise type(e)("Unknown port value %r" % self[1]) -_T_Address = t.TypeVar("_T_Address", bound=Address) +_TAddress = t.TypeVar("_TAddress", bound=Address) class IPv4Address(Address): diff --git a/neo4j/api.py b/neo4j/api.py index a5e7471f8..811f6c663 100644 --- a/neo4j/api.py +++ b/neo4j/api.py @@ -27,19 +27,15 @@ urlparse, ) - -if t.TYPE_CHECKING: - import typing_extensions as te - from .addressing import Address - - - from ._meta import deprecated from .exceptions import ConfigurationError if t.TYPE_CHECKING: + import typing_extensions as te from typing_extensions import Protocol as _Protocol + + from .addressing import Address else: _Protocol = object diff --git a/neo4j/data.py b/neo4j/data.py index 0713ed460..c7b869636 100644 --- a/neo4j/data.py +++ b/neo4j/data.py @@ -27,10 +27,7 @@ from ._meta import deprecation_warn -map_type = type(map(str, range(0))) - __all__ = [ - "map_type", "Record", "DataTransformer", "RecordExporter", diff --git a/neo4j/exceptions.py b/neo4j/exceptions.py index 6feea3642..c49a7cdf6 100644 --- a/neo4j/exceptions.py +++ b/neo4j/exceptions.py @@ -72,6 +72,8 @@ import typing as t +from ._meta import deprecated + if t.TYPE_CHECKING: import typing_extensions as te @@ -89,20 +91,15 @@ Transaction, ) - _T_Transaction = t.Union[AsyncManagedTransaction, AsyncTransaction, - ManagedTransaction, Transaction] - _T_Result = t.Union[AsyncResult, Result] - _T_Session = t.Union[AsyncSession, Session] + _TTransaction = t.Union[AsyncManagedTransaction, AsyncTransaction, + ManagedTransaction, Transaction] + _TResult = t.Union[AsyncResult, Result] + _TSession = t.Union[AsyncSession, Session] else: - _T_Transaction = t.Union["AsyncManagedTransaction", "AsyncTransaction", - "ManagedTransaction", "Transaction"] - _T_Result = t.Union["AsyncResult", "Result"] - _T_Session = t.Union["AsyncSession", "Session"] - - - - -from ._meta import deprecated + _TTransaction = t.Union["AsyncManagedTransaction", "AsyncTransaction", + "ManagedTransaction", "Transaction"] + _TResult = t.Union["AsyncResult", "Result"] + _TSession = t.Union["AsyncSession", "Session"] CLASSIFICATION_CLIENT: te.Final[str] = "ClientError" @@ -401,7 +398,7 @@ class SessionError(DriverError): """ Raised when an error occurs while using a session. """ - session: _T_Session + session: _TSession def __init__(self, session_, *args, **kwargs): super().__init__(*args, **kwargs) @@ -413,7 +410,7 @@ class TransactionError(DriverError): """ Raised when an error occurs while using a transaction. """ - transaction: _T_Transaction + transaction: _TTransaction def __init__(self, transaction_, *args, **kwargs): super().__init__(*args, **kwargs) @@ -430,7 +427,7 @@ class TransactionNestingError(TransactionError): class ResultError(DriverError): """Raised when an error occurs while using a result object.""" - result: _T_Result + result: _TResult def __init__(self, result_, *args, **kwargs): super().__init__(*args, **kwargs) diff --git a/neo4j/time/__main__.py b/neo4j/time/__main__.py index ec3469a07..4a5869515 100644 --- a/neo4j/time/__main__.py +++ b/neo4j/time/__main__.py @@ -19,7 +19,7 @@ def main(): - from neo4j.time import ( + from . import ( Clock, DateTime, UnixEpoch, diff --git a/neo4j/time/_arithmetic.py b/neo4j/time/_arithmetic.py index 6b93a6a6a..70256061c 100644 --- a/neo4j/time/_arithmetic.py +++ b/neo4j/time/_arithmetic.py @@ -88,12 +88,12 @@ def nano_divmod(x, y): return int(q), number(r / 1000000000) -_T_dividend = TypeVar("_T_dividend", int, float) +_TDividend = TypeVar("_TDividend", int, float) def symmetric_divmod( - dividend: _T_dividend, divisor: float -) -> Tuple[int, _T_dividend]: + dividend: _TDividend, divisor: float +) -> Tuple[int, _TDividend]: number = type(dividend) if dividend >= 0: quotient, remainder = divmod(dividend, divisor)