In an effort to decrease the context switching/learning barrier between the different projects within the Conda org, a standard set of code styles is defined. The intention of these guidelines is not to overburden or complicate the contribution process; if any style starts to become a burden, its inherent benefit should be reevaluated.
Policy | Tooling | |
---|---|---|
Use black (or darker for preexisting projects). |
black darker |
|
Use isort . |
isort |
|
Prefer f-strings over all other string formatting styles (e.g. str.format , c-style). |
flake8-use-fstring |
|
Prefer pathlib over os.path . |
flake8-use-pathlib |
|
Use typing (or gradually enforce for preexisting projects). | flake8-annotations |
|
Define typing aliases at the top of files. | ||
Use TYPE_CHECKING import guard. |
flake8-typing-imports |
|
Define loggers at the top of files. | ||
Only use assert in tests. |
flake8-useless-assert |
|
Use American English. | flake8-spellcheck |
|
Use inclusive language. See these other great resources for details: | ||
Use descriptive variable names:
|
flake8-variables-names |
|
When indicating a change that requires a future version of Python (or dropping a currently-supported version), use the following format:# FUTURE: <minimum Python requirement>, <details> e.g.: # FUTURE: Python 3.9+, replace with ... |
||
All public functions and module constants must include a docstring. | flake8-docstrings docformatter |
|
Module constants are documented using Sphinx autodoc syntax:# before constant |
sphinx.ext.autodoc |
Other Tooling |
---|
flake8-bugbear |
flake8-simplify |