diff --git a/airbyte/sources/base.py b/airbyte/sources/base.py index 26ed1a0f..7ce37070 100644 --- a/airbyte/sources/base.py +++ b/airbyte/sources/base.py @@ -46,12 +46,12 @@ @contextmanager -def as_temp_files(files_contents: list[Any]) -> Generator[list[str], Any, None]: +def as_temp_files(files_contents: list[dict | str]) -> Generator[list[str], Any, None]: """Write the given contents to temporary files and yield the file paths as strings.""" temp_files: list[Any] = [] try: for content in files_contents: - temp_file = tempfile.NamedTemporaryFile(mode="w+t", delete=True) + temp_file = tempfile.NamedTemporaryFile(mode="w+t", delete=False) temp_file.write( json.dumps(content) if isinstance(content, dict) else content, ) @@ -61,7 +61,7 @@ def as_temp_files(files_contents: list[Any]) -> Generator[list[str], Any, None]: finally: for temp_file in temp_files: with suppress(Exception): - temp_file.close() + temp_file.unlink() class Source: