For the complete documentation index, see llms.txt. This page is also available as Markdown.

Style Guide

The Ion code base generally follows the guidelines as set forth by PEP8.

Main Points

  • Indent using 4 spaces.

  • Use underscores in favor of camel case for all names except the names of classes.

  • Limit all lines to a maximum of 79 characters.

  • Limit the line length of docstrings or comments to 72 characters.

  • Separate top-level functions and class definitions with two blank lines.

  • Separate method definitions inside a class with a single blank line.

  • Use two spaces before inline comment and one space between the pound sign and comment/

  • Use a plugin for your text editor to check for/remind you of PEP8 conventions.

  • Capitalize and punctuate comments and git commit messages properly.

Imports

  • Group imports in the following order:

    1. Standard library imports

    2. Imports from core Django

    3. Related third-party imports

    4. Local application or library specific imports, imports from Django apps

  • Avoid using import *

  • Explicitly import each module used

Examples

Standard library imports:

Core Django imports:

Third-party app imports

Imports from your apps

Explicit relative imports:

Used to avoid hardcoding a module's package. This greatly improves portability. Use these when importing from another module in the current app.

Absolute imports:

Used when importing outside the current app.

Implicit relative imports:

Don't use these. Using them makes it very difficult to change the name of the app, reducing portability.

Good:

Bad:

References

Last updated