I don't think there is any solution for that but "fix your broken linter".
Probably because PEP 8 says
> Imports are always put at the top of the file, just after any module comments and docstrings, and before module globals and constants
I banished the worst/heaviest libraries to this list at my workplace and it's been really helpful at keeping startup times from regressing.