From 5dd42f86d2d75622b4040ced3992b45cc757f15a Mon Sep 17 00:00:00 2001 From: Geir Arne Hjelle Date: Wed, 7 Aug 2024 09:38:19 +0200 Subject: [PATCH] Final QA (#564) --- python-async-iterators/async_csv.py | 5 ++--- python-async-iterators/compress.py | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/python-async-iterators/async_csv.py b/python-async-iterators/async_csv.py index 67d64df3ad..9280547693 100644 --- a/python-async-iterators/async_csv.py +++ b/python-async-iterators/async_csv.py @@ -7,17 +7,16 @@ class AsyncCSVIterator: def __init__(self, path): self.path = path - self.file_was_read = False + self.reader = None def __aiter__(self): return self async def __anext__(self): - if not self.file_was_read: + if self.reader is None: async with aiofiles.open(self.path, mode="r") as file: lines = await file.readlines() self.reader = csv.reader(lines) - self.file_was_read = True try: return next(self.reader) except StopIteration: diff --git a/python-async-iterators/compress.py b/python-async-iterators/compress.py index 361da4a59f..3edbc31eba 100644 --- a/python-async-iterators/compress.py +++ b/python-async-iterators/compress.py @@ -18,5 +18,5 @@ async def main(directory, zip_name="output.zip"): await archive.write(chunk) -directory = Path() +directory = Path.cwd() asyncio.run(main(directory))