Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable style checking for entire code base #620

Merged
merged 9 commits into from
Jul 7, 2024
Prev Previous commit
Next Next commit
Document new code style
padix-key committed Jul 6, 2024
commit 3d4b77fc1391fac13f567cddca4a54d3b6d5610a
22 changes: 14 additions & 8 deletions doc/contribution/development.rst
Original file line number Diff line number Diff line change
@@ -53,13 +53,19 @@ Official support for PyPy might be added someday.

Code style
----------
*Biotite* is in compliance with PEP 8.
The maximum line length is 79 for code lines and 72 for docstring and
comment lines.
*Biotite* is compliant with :pep:`8` and uses `Ruff <https://docs.astral.sh/ruff/>`_ for
code formatting and linting.
The maximum line length is 88 characters.
An exception is made for docstring lines, if it is not possible to use a
maximum of 72 characters (e.g. tables), and for
`doctest <https://docs.python.org/3/library/doctest.html>`_ lines,
where the actual code may take up to 79 characters.
maximum of 88 characters (e.g. tables and parameter type descriptions).
To make code changes ready for a pull request, simply run

.. code-block:: console

$ ruff format
$ ruff check --fix

and fix the remaining linter complaints.

Dependencies
------------
@@ -124,14 +130,14 @@ accessible, in a relative manner.
Import statements should be the only statements in a ``__init__.py`` file.

In case a module needs functionality from another subpackage of *Biotite*,
use a relative import.
use an absolute import as suggested by PEP 8.
This import should target the module directly and not the package to avoid
circular imports and thus an ``ImportError``.
So import statements like the following are totally OK:

.. code-block:: python

from ...package.subpackage.module import foo
from biotite.subpackage.module import foo

In order to prevent namespace pollution, all modules must define the `__all__`
variable with all publicly accessible attributes of the module.