Skip to content

Commit c811f96

Browse files
committed
fixup! Clean-up: lift code base to Python 3.10
1 parent 8623a2d commit c811f96

File tree

9 files changed

+64
-55
lines changed

9 files changed

+64
-55
lines changed

bin/make-unasync

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -302,16 +302,15 @@ def apply_isort(paths):
302302

303303
def apply_changes(paths):
304304
def files_equal(path1, path2):
305-
with open(path1, "rb") as f1:
306-
with open(path2, "rb") as f2:
305+
with open(path1, "rb") as f1, open(path2, "rb") as f2:
306+
data1 = f1.read(1024)
307+
data2 = f2.read(1024)
308+
while data1 or data2:
309+
if data1 != data2:
310+
changed_paths[path1] = path2
311+
return False
307312
data1 = f1.read(1024)
308313
data2 = f2.read(1024)
309-
while data1 or data2:
310-
if data1 != data2:
311-
changed_paths[path1] = path2
312-
return False
313-
data1 = f1.read(1024)
314-
data2 = f2.read(1024)
315314
return True
316315

317316
changed_paths = {}

pyproject.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,7 @@ extend-exclude = [
144144
preview = true # to get CPY lints
145145
extend-ignore = [
146146
"RUF002", # allow ’ (RIGHT SINGLE QUOTATION MARK) to be used as an apostrophe (e.g. "it’s")
147-
"SIM117", # TODO: when Python 3.10+ is the minimum,
148-
# we can start to use multi-item `with` statements
147+
149148
# pydocstyle
150149
"D1", # disable check for undocumented items (way too noisy)
151150
"D203", # `one-blank-line-before-class`

src/neo4j/api.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,6 @@ def protocol_version(self) -> tuple[int, int]:
385385
This is returned as a 2-tuple:class:`tuple` (subclass) of
386386
``(major, minor)`` integers.
387387
"""
388-
# TODO: 6.0 - remove cast when support for Python 3.7 is dropped
389388
return self._protocol_version
390389

391390
@property

tests/integration/async_/test_custom_ssl_context.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,14 @@ def wrap_fail(*_, **__):
3838
fake_ssl_context.wrap_socket.side_effect = wrap_fail
3939
fake_ssl_context.wrap_bio.side_effect = wrap_fail
4040

41-
async with neo4j.AsyncGraphDatabase.driver(
42-
uri, auth=auth, ssl_context=fake_ssl_context
43-
) as driver:
44-
async with driver.session() as session:
45-
with pytest.raises(NoNeedToGoFurtherError):
46-
await session.run("RETURN 1")
41+
async with (
42+
neo4j.AsyncGraphDatabase.driver(
43+
uri, auth=auth, ssl_context=fake_ssl_context
44+
) as driver,
45+
driver.session() as session,
46+
):
47+
with pytest.raises(NoNeedToGoFurtherError):
48+
await session.run("RETURN 1")
4749

4850
assert (
4951
fake_ssl_context.wrap_socket.call_count

tests/integration/sync/test_custom_ssl_context.py

Lines changed: 8 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/unit/async_/test_driver.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -764,11 +764,11 @@ async def test_warn_notification_severity_driver_config(
764764
) -> None:
765765
if inspect.isclass(expected) and issubclass(expected, Exception):
766766
assert min_sev is not ... # makes no sense to test
767-
with pytest.raises(expected):
768-
with pytest.warns(PreviewWarning, match="notification warnings"):
769-
AsyncGraphDatabase.driver(
770-
uri, warn_notification_severity=min_sev
771-
)
767+
with (
768+
pytest.raises(expected),
769+
pytest.warns(PreviewWarning, match="notification warnings"),
770+
):
771+
AsyncGraphDatabase.driver(uri, warn_notification_severity=min_sev)
772772
return
773773
if min_sev is ...:
774774
driver = AsyncGraphDatabase.driver(uri)

tests/unit/async_/work/test_session.py

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -135,11 +135,13 @@ async def test_opens_connection_on_tx_begin(async_fake_pool):
135135
async def test_keeps_connection_on_tx_run(
136136
async_fake_pool, test_run_args, repetitions
137137
):
138-
async with AsyncSession(async_fake_pool, SessionConfig()) as session:
139-
async with await session.begin_transaction() as tx:
140-
for _ in range(repetitions):
141-
await tx.run(*test_run_args)
142-
assert session._connection is not None
138+
async with (
139+
AsyncSession(async_fake_pool, SessionConfig()) as session,
140+
await session.begin_transaction() as tx,
141+
):
142+
for _ in range(repetitions):
143+
await tx.run(*test_run_args)
144+
assert session._connection is not None
143145

144146

145147
@pytest.mark.parametrize(
@@ -150,12 +152,14 @@ async def test_keeps_connection_on_tx_run(
150152
async def test_keeps_connection_on_tx_consume(
151153
async_fake_pool, test_run_args, repetitions
152154
):
153-
async with AsyncSession(async_fake_pool, SessionConfig()) as session:
154-
async with await session.begin_transaction() as tx:
155-
for _ in range(repetitions):
156-
result = await tx.run(*test_run_args)
157-
await result.consume()
158-
assert session._connection is not None
155+
async with (
156+
AsyncSession(async_fake_pool, SessionConfig()) as session,
157+
await session.begin_transaction() as tx,
158+
):
159+
for _ in range(repetitions):
160+
result = await tx.run(*test_run_args)
161+
await result.consume()
162+
assert session._connection is not None
159163

160164

161165
@pytest.mark.parametrize(

tests/unit/sync/test_driver.py

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/unit/sync/work/test_session.py

Lines changed: 15 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)