From a4c86fc004f1a66b3a49430023436addc049a2cc Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Wed, 5 Oct 2022 07:46:12 +0200 Subject: [PATCH 1/2] Use aiofiles typeshed definitions instead of ignoring the package. --- mypy.ini | 3 --- pyproject.toml | 1 + 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/mypy.ini b/mypy.ini index b5aaf80..172d757 100644 --- a/mypy.ini +++ b/mypy.ini @@ -7,8 +7,5 @@ [mypy-sh.*] ignore_missing_imports = True -[mypy-aiofiles.*] -ignore_missing_imports = True - [mypy-semantic_version.*] ignore_missing_imports = True diff --git a/pyproject.toml b/pyproject.toml index b169bc0..0936ee3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -56,6 +56,7 @@ pylint = "^2.12.0" pytest = "*" pytest-asyncio = ">= 0.12" pytest-cov = "*" +types-aiofiles = "*" types-PyYAML = "*" [tool.isort] From fe6ab965e15bfb53d9efae726db5adb3a7ce7044 Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Wed, 5 Oct 2022 08:12:52 +0200 Subject: [PATCH 2/2] Fix async file copying. --- changelogs/fragments/11-copy-fix.yml | 2 ++ src/antsibull_core/utils/io.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/11-copy-fix.yml diff --git a/changelogs/fragments/11-copy-fix.yml b/changelogs/fragments/11-copy-fix.yml new file mode 100644 index 0000000..f5c0730 --- /dev/null +++ b/changelogs/fragments/11-copy-fix.yml @@ -0,0 +1,2 @@ +bugfixes: + - "Fix async file copying helper (https://github.com/ansible-community/antsibull-core/pull/11)." diff --git a/src/antsibull_core/utils/io.py b/src/antsibull_core/utils/io.py index ba48f68..8ec2aa6 100644 --- a/src/antsibull_core/utils/io.py +++ b/src/antsibull_core/utils/io.py @@ -47,7 +47,7 @@ async def copy_file(source_path: str, dest_path: str) -> None: # Since we already read the contents of the file to copy, simply write it to # the destination instead of reading it again async with aiofiles.open(dest_path, 'wb') as f_out: - f_out.write(content_to_copy) + await f_out.write(content_to_copy) return except FileNotFoundError: # Destination (or source) file does not exist