diff --git a/docs/contributing/code-review.rst b/docs/contributing/code-review.rst index f64964e..e299203 100644 --- a/docs/contributing/code-review.rst +++ b/docs/contributing/code-review.rst @@ -1,51 +1,51 @@ .. _code-review: Code Review =========== -This page documents code review practices used for [[Software Heritage]] development. +This page documents code review practices used for Software Heritage development. Guidelines ---------- Please adhere to the following guidelines to perform and obtain code reviews (CRs) in the context of Software Heritage development: 1. **CRs are strongly recommended** for any non-trivial code change, but not mandatory (nor enforced at the VCS level). 2. The CR `workflow `_ is implemented using Phabricator/Differential. 3. Explicitly **suggest reviewer(s)** when submitting new CR requests: either the most knowledgeable person(s) for the target code or the general `reviewers `_ (which is the `default `_). 4. **Review anything you want**: no matter the suggested reviewer(s), feel free to review any outstanding CR. 5. **One LGTM is enough**: feel free to approve any outstanding CR. 6. **Review every day**: CRs should be timely as fellow developers will wait for them. To make CRs sustainable each developer should strive to dedicate a fixed minimum amount of CR time every (work) day. For more detailed suggestions (and much more) on the motivational and practical aspects of code reviews see Good reads below. Good reads ---------- Good reads on various angles of code review: * `Best practices `_ (Palantir) ← comprehensive and recommended read, especially if you're short on time * `Best practices `_ (Thoughtbot) * `Best practices `_ (Smart Bear) * `Review checklist `_ (Code Project) * `Motivation: code quality `_ (Coding Horror) * `Motivation: team culture `_ (Google & FullStory) * `Motivation: humanizing peer reviews `_ (Wiegers) * `Motivation: sharing knowledge `_ (Atlassian) See also -------- * :ref:`phabricator-arcanist` * :ref:`coding-guidelines` diff --git a/docs/contributing/python-style-guide.rst b/docs/contributing/python-style-guide.rst index 7c3180d..5ec963e 100644 --- a/docs/contributing/python-style-guide.rst +++ b/docs/contributing/python-style-guide.rst @@ -1,67 +1,67 @@ .. _python-style-guide: Python style guide ================== -Coding style and best practices for writing Python code for [[Software Heritage]]. +Coding style and best practices for writing Python code for Software Heritage. General rules ------------- * As a general rule, follow the `Google Python Style Guide `_. * Target **Python 3**. Do not care about backward compatibility with Python 2. Black +++++ As of April 2020, we use `Black `_ as automated code formatter for all Software Heritage Python code. CI, tox, and other linting tools are configured to fail if code is not formatted as black would. Note that, as part of this, *maximum line length is 88 characters*, rather than the default of 79. Specific rules -------------- As supplement/overrides to the above general rules, follow the additional recommendations below. Lint ++++ * Make sure your code is `flake8 `_ and `Black `_ clean. Tests +++++ * use ``pytest`` as test runner * put ``tests/`` dir down deep in the module hierarchy, near to the code being tested * naming conventions: ** ``tests/test_mymodule.py`` ** ``class TestMyEntity(unittest.TestCase)`` ** ``def behavior(self):`` *** do *not* prepend ``test_`` to all test methods; use nose's ``@istest`` decorator instead Classes +++++++ * Since we target Python 3, there is no need to `inherit from 'object' explicitly `_ Docstrings --------- * docstrings should produce a nice API documentation when run through `Sphinx `_ * docstrings should use the `Napoleon style `_ (Google variant) to document arguments, return values, etc. ** see also: a `comprehensive style example `_ ** see also: :ref:`sphinx-gotchas`