Skip to content

Commit 50a979b

Browse files
committed
Fix lint error
1 parent dc9947a commit 50a979b

File tree

1 file changed

+23
-23
lines changed

1 file changed

+23
-23
lines changed

sqlite_utils/utils.py

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -8,33 +8,12 @@
88
import json
99
import os
1010
import sys
11-
from . import recipes
1211
from typing import Dict, cast, BinaryIO, Iterable, Iterator, Optional, Tuple, Type
1312

14-
15-
class _CloseableIterator(Iterator[dict]):
16-
"""Iterator wrapper that closes a file when iteration is complete."""
17-
18-
def __init__(self, iterator: Iterator[dict], closeable: io.IOBase):
19-
self._iterator = iterator
20-
self._closeable = closeable
21-
22-
def __iter__(self) -> "_CloseableIterator":
23-
return self
24-
25-
def __next__(self) -> dict:
26-
try:
27-
return next(self._iterator)
28-
except StopIteration:
29-
self._closeable.close()
30-
raise
31-
32-
def close(self) -> None:
33-
self._closeable.close()
34-
35-
3613
import click
3714

15+
from . import recipes
16+
3817
try:
3918
import pysqlite3 as sqlite3 # noqa: F401
4019
from pysqlite3 import dbapi2 # noqa: F401
@@ -65,6 +44,27 @@ def close(self) -> None:
6544
ORIGINAL_CSV_FIELD_SIZE_LIMIT = csv.field_size_limit()
6645

6746

47+
class _CloseableIterator(Iterator[dict]):
48+
"""Iterator wrapper that closes a file when iteration is complete."""
49+
50+
def __init__(self, iterator: Iterator[dict], closeable: io.IOBase):
51+
self._iterator = iterator
52+
self._closeable = closeable
53+
54+
def __iter__(self) -> "_CloseableIterator":
55+
return self
56+
57+
def __next__(self) -> dict:
58+
try:
59+
return next(self._iterator)
60+
except StopIteration:
61+
self._closeable.close()
62+
raise
63+
64+
def close(self) -> None:
65+
self._closeable.close()
66+
67+
6868
def maximize_csv_field_size_limit():
6969
"""
7070
Increase the CSV field size limit to the maximum possible.

0 commit comments

Comments
 (0)