Info |
---|
Note, these are guidelines used by the SCD Cloud Operations Group. They are being presented externally as they may be useful for those developing their own software, they are not being provided with the intention of the Cloud Team reviewing your code - unless you are contributing to one of our repositories. |
Style guides refer to a set of standards for writing and formatting code. Having a consistent style guide makes it much easier to understand a large codebase. We recommend using the following style guides.
Python
Python code should follow Generic coding conventions as specified in the Style Guide for Python Code (PEP 8).
...
CapWords
convention for Class namesUse
lowercase
orlowercase_with_underscores
for function, method, and variable names.For short names, joined lowercase may be used (e.g. "tagname"). Choose what is most readable.
No single-character variable names, except indices in loops that encompass a very small number of lines
Use
'single quotes'
for string literals, and"""triple double quotes"""
for docstrings.Use double quotes for strings when necessary like
"don't"
.
When using dataclasses - it should belong to the module using it
Guidelines
When contributing code, you should use a Linter.
A Linter is a tool that performs static source code analysis. The tool can check your code syntax and provide instructions on how to improve it.
For Python, recommend flake8
pylint
: https://pypi.org/project/pylint/
Flake 8 is another linter: https://flake8.pycqa.org/en/latest/index.html
For Python, code can be automatically formatted to match PEP8 style guide using black
.: https://black.readthedocs.io/en/stable/
Black is an opinionated code formatter, it can take your Python code and automatically reformat it to adhere to a strict set of style guidelines. Its a good idea to run black
just before you commit and push your code to githubGitHub.