pythongoogle-style-guide

What is a code repository sub-package imports?


Looking at the Google Python Style Guide under 3.13 it says order of imports should be:

  1. Python Future Imports
  2. Python Standard imports
  3. Third Party module or package import
  4. Code repository sub-package imports

What exactly is Code repository sub-package imports ? If there is a library written by another team in the company is that Third Party or is it Code Repository?


Solution

  • "Code repository sub-package imports" means a package that lives in the projects' directory.

    If you have main.py and utils.py, you will do from utils import magic_algorithm last.

    So, following that logic the entire thing might look like

    from __future__ import braces       # future import
    import re                           # python built-in import
    from requests import Session        # third-party import
    from utils import magic_algorithm   # code repository import