Skip to content

Commit 58e5b0d

Browse files
committed
Clean up neo4j.time public exports
Make undocumented internal constants, helper functions, and other items in `neo4j.time` private: * `DATE_ISO_PATTERN` * `TIME_ISO_PATTERN` * `DURATION_ISO_PATTERN` * `NANO_SECONDS` * `AVERAGE_SECONDS_IN_MONTH` * `AVERAGE_SECONDS_IN_DAY` * `FORMAT_F_REPLACE` * `IS_LEAP_YEAR` * `DAYS_IN_YEAR` * `DAYS_IN_MONTH` * `round_half_to_even` * `symmetric_divmod` * `DateTimeType` * `DateType` * `TimeType` * all other indirectly exposed items from imports (e.g. `re` as `neo4j.time.re`)
1 parent 0e4d772 commit 58e5b0d

File tree

14 files changed

+581
-339
lines changed

14 files changed

+581
-339
lines changed

CHANGELOG.md

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ See also https://github.com/neo4j/neo4j-python-driver/wiki for a full changelog.
7272
- Remove `ExperimentalWarning` and turn the few left instances of it into `PreviewWarning`.
7373
- Deprecate importing `PreviewWarning` from `neo4j`.
7474
Import it from `neo4j.warnings` instead.
75-
- Make undocumented internal constants private:
75+
- Make undocumented internal constants, helper functions, and other items private:
7676
- `neo4j.api`
7777
- `DRIVER_BOLT`
7878
- `DRIVER_NEO4J`
@@ -86,6 +86,27 @@ See also https://github.com/neo4j/neo4j-python-driver/wiki for a full changelog.
8686
- `ERROR_REWRITE_MAP`
8787
- `client_errors`
8888
- `transient_errors`
89+
- `neo4j.time`
90+
- `DATE_ISO_PATTERN`
91+
- `TIME_ISO_PATTERN`
92+
- `DURATION_ISO_PATTERN`
93+
- `NANO_SECONDS`
94+
- `AVERAGE_SECONDS_IN_MONTH`
95+
- `AVERAGE_SECONDS_IN_DAY`
96+
- `FORMAT_F_REPLACE`
97+
- `IS_LEAP_YEAR`
98+
- `DAYS_IN_YEAR`
99+
- `DAYS_IN_MONTH`
100+
- `round_half_to_even`
101+
- `symmetric_divmod`
102+
- `DateTimeType`
103+
- `DateType`
104+
- `TimeType`
105+
- all other indirectly exposed items from imports (e.g. `re` as `neo4j.time.re`)
106+
- Deprecate ClockTime and its accessors
107+
- For each `neo4j.time.Date`, `neo4j.time.DateTime`, `neo4j.time.Time`
108+
- `from_clock_time` and `to_clock_time` methods
109+
- `neo4j.time.ClockTime` itself
89110
- Raise `ConfigurationError` instead of ignoring the routing context (URI query parameters) when creating a direct
90111
driver ("bolt[+s[sc]]://" scheme).
91112
- Change behavior of closed drivers:

docs/source/conf.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,12 +124,13 @@
124124
autodoc_typehints = "description"
125125

126126
autodoc_type_aliases = {
127-
# The code-base uses `import typing_extensions as te`.
127+
# The code-base uses `import typing_extensions as te` / `as _te`.
128128
# Re-write these to use `typing` instead, as Sphinx always resolves against
129129
# the latest version of the `typing` module.
130130
# This is a work-around to make Sphinx resolve type hints correctly, even
131131
# though we're using `from __future__ import annotations`.
132132
"te": typing,
133+
"_te": typing,
133134
# Type alias that's only defined and imported if `typing.TYPE_CHECKING`
134135
# is `True`.
135136
"_TAuth": "typing.Tuple[typing.Any, typing.Any] | Auth | None",

src/neo4j/_codec/hydration/v1/temporal.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@
2525
pd,
2626
)
2727
from ....time import (
28+
_NANO_SECONDS,
2829
Date,
2930
DateTime,
3031
Duration,
3132
MAX_YEAR,
3233
MIN_YEAR,
33-
NANO_SECONDS,
3434
Time,
3535
)
3636
from ...packstream import Structure
@@ -170,8 +170,8 @@ def seconds_and_nanoseconds(dt):
170170
if isinstance(dt, datetime):
171171
dt = DateTime.from_native(dt)
172172
zone_epoch = DateTime(1970, 1, 1, tzinfo=dt.tzinfo)
173-
dt_clock_time = dt.to_clock_time()
174-
zone_epoch_clock_time = zone_epoch.to_clock_time()
173+
dt_clock_time = dt._to_clock_time()
174+
zone_epoch_clock_time = zone_epoch._to_clock_time()
175175
t = dt_clock_time - zone_epoch_clock_time
176176
return t.seconds, t.nanoseconds
177177

@@ -226,7 +226,8 @@ def dehydrate_np_datetime(value):
226226
)
227227
seconds = value.astype(np.dtype("datetime64[s]")).astype(int)
228228
nanoseconds = (
229-
value.astype(np.dtype("datetime64[ns]")).astype(int) % NANO_SECONDS
229+
value.astype(np.dtype("datetime64[ns]")).astype(int)
230+
% _NANO_SECONDS
230231
)
231232
return Structure(b"d", seconds, nanoseconds)
232233

src/neo4j/_codec/hydration/v2/temporal.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@
2121

2222
from ...._optional_deps import pd
2323
from ....time import (
24+
_NANO_SECONDS,
2425
Date,
2526
DateTime,
26-
NANO_SECONDS,
2727
Time,
2828
)
2929
from ...packstream import Structure
@@ -119,7 +119,7 @@ def dehydrate_pandas_datetime(value):
119119
:type value: pandas.Timestamp
120120
:returns:
121121
"""
122-
seconds, nanoseconds = divmod(value.value, NANO_SECONDS)
122+
seconds, nanoseconds = divmod(value.value, _NANO_SECONDS)
123123

124124
tz = value.tzinfo
125125
if tz is None:

0 commit comments

Comments
 (0)