Refactor and add types for Python files from root and infra folder
This PR:
- add typing;
- reorganize import;
- replace string format by f-string;
- replace string format and f-string by lazy formatting for log.
It may be the last MR of the series of typing.