I think it is PEP8 that suggest to import system libraries first, then third party libraries. I think markupsafe is not in the standard library.