Skip to content

Commit 177ab1c

Browse files
committed
Use BufferedIOBase, not TextIOWrapper
1 parent 0fb52a4 commit 177ab1c

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

pypgstac/pypgstac/pypgstac.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import asyncio
2-
from io import TextIOWrapper
2+
from io import BufferedIOBase
33
import os
44
import time
55
from typing import Any, AsyncGenerator, Dict, Iterable, Optional, TypeVar
@@ -110,7 +110,7 @@ async def run_migration(dsn: Optional[str] = None) -> str:
110110
)
111111

112112
open_migration_file = open(migration_file)
113-
if isinstance(open_migration_file, TextIOWrapper):
113+
if isinstance(open_migration_file, BufferedIOBase):
114114
with open_migration_file as f:
115115
migration_sql = f.read()
116116
logging.debug(migration_sql)
@@ -170,6 +170,7 @@ async def aiter(list: T) -> AsyncGenerator[bytes, None]:
170170
line = "\n".join(
171171
[item_str.rstrip().replace(r"\n", r"\\n").replace(r"\t", r"\\t")]
172172
).encode("utf-8")
173+
173174
yield line
174175

175176

@@ -292,7 +293,7 @@ async def load_ndjson(
292293
) -> None:
293294
print(f"loading {file} into {table} using {method}")
294295
open_file = open(file, "rb")
295-
if isinstance(open_file, TextIOWrapper):
296+
if isinstance(open_file, BufferedIOBase):
296297
with open_file as f:
297298
async with DB(dsn) as conn:
298299
await load_iterator(f, table, conn, method)

0 commit comments

Comments
 (0)