I would rather have:
 * remove the `import tarfile` from line 6
 * add:
    *  `from .lib import xtarfile`
    *  `tarfile = xtarfile.tarfile`

It makes it more clear what happens and where things come from. (and you can remove your flake F401 workaround).

The same goes for the other files below.