Question: How do I delete a file or folder?

Answer: 
shutil.rmtree is the asynchronous function, 
so if you want to check when it complete, you can use while...loop

```
import os
import shutil

shutil.rmtree(path)

while os.path.exists(path):
  pass

print('done')

```
To avoid the [TOCTOU](http://en.wikipedia.org/wiki/Time_of_check_to_time_of_use) issue highlighted by [Éric Araujo's comment](https://stackoverflow.com/questions/6996603/how-to-delete-a-file-or-folder#comment99147016_42641792), you can catch an exception to call the correct method:

```
def remove_file_or_dir(path: str) -> None:
    """ Remove a file or directory """
    try:
        shutil.rmtree(path)
    except NotADirectoryError:
        os.remove(path)

```

Since `shutil.rmtree()` will only remove directories and `os.remove()` or `os.unlink()` will only remove files.