-
Notifications
You must be signed in to change notification settings - Fork 232
Coding style
Leopold Talirz edited this page Oct 29, 2019
·
3 revisions
If you follow the instructions to set up your development environment, the AiiDA coding style is largely enforced automatically using pre-commit hooks.
This document mainly acts as a reference.
- Code should conform to the PEP8 guidelines (https://www.python.org/dev/peps/pep-0008/).
- When compatible, adhere to the Google Python Styleguide
- Concerning documentation, see Writing documentation
- Concerning tests, see Writing tests
- Opening files: In order to prepare for the end of Python 2 support
- When opening a general file for reading or writing, use io.open, and specify UTF-8 encoding for formatted files ( e.g. io.open(path, 'w', encoding='utf8').
- When opening a file from the AiiDA repository, use aiida.common.folders.Folder.open().
Each source file should start with a common header (will be added automatically by helper scripts that are run just before a new release):
- Optional she-bang line e.g. #!/usr/bin/env python
- Coding declaration conforming to PEP 263: e.g. # -*- coding: utf-8 -*-
- A copyright header defined below
- Linter directives e.g. # pylint: disable=too-many-arguments
- Module docstrings
The copyright header is currently defined to be:
###########################################################################
# Copyright (c), The AiiDA team. All rights reserved. #
# This file is part of the AiiDA code. #
# #
# The code is hosted on GitHub at https://github.com/aiidateam/aiida_core #
# For further information on the license, see the LICENSE.txt file #
# For further information please visit http://www.aiida.net #
###########################################################################