Skip to content

Commit

Permalink
Remove black and update with ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
KasukabeDefenceForce committed Oct 11, 2024
1 parent b3af245 commit 884dd9e
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 19 deletions.
3 changes: 0 additions & 3 deletions README_TEMPLATE.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ stars (*supernovae*).

.. image:: https://github.com/tardis-sn/tardis/actions/workflows/build-docs.yml/badge.svg
:target: https://tardis-sn.github.io/tardis/index.html

.. image:: https://img.shields.io/badge/code%20style-black-000000.svg
:target: https://github.com/psf/black
|

Expand Down
16 changes: 1 addition & 15 deletions docs/contributing/development/code_quality.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,6 @@ Code Style Conventions

TARDIS follows the `PEP 8 <https://www.python.org/dev/peps/pep-0008/>`_ style guide written by the author of the Python programming language. It defines a consistent way to write your code making, it easier to read and maintain.

Black
-----
`Black <https://black.readthedocs.io/en/stable/index.html>`_ is a PEP 8 compliant opinionated code formatter. At TARDIS. we use Black to automatically conform to PEP 8. It is already installed in the TARDIS conda environment, so all you have to do is to run Black before committing your changes: ::

black {source_file_or_directory}

A better method is to run Black automatically - first `integrate it within the code editor <https://black.readthedocs.io/en/stable/editor_integration.html>`_ you use and then enable the "format on save" or "format on type" option in your editor settings.

.. warning :: If your code doesn't follow the Black code style, then the Black-check action on your PR will fail.
Ruff
----
`Ruff <https://docs.astral.sh/ruff/>`_ is a code linter and formatter that checks for common mistakes and automatically fixes them. It is currently not installed in the TARDIS conda environment, so you will have to install it manually: ::
Expand All @@ -37,12 +27,8 @@ To run Ruff, use the following command: ::
ruff check <source_file_or_directory> # Lints the code
ruff check <source_file_or_directory> --fix # Lints and fixes any fixable errors

Currently, Ruff is not integrated with the TARDIS CI and is not a requirement for merging a PR. However, it is recommended to run Ruff on your code before committing it to ensure that new code already follows these rules.

.. note :: We adopt the linting rules utilized by astropy. Permanent rules are defined in the ``pyproject.toml``, non-permanent rules are defined in the ``.ruff.toml`` file. If you want to add a new rule, please add it to the ``.ruff.toml`` file. If you want to add a permanent rule, please open a PR to the ``pyproject.toml``.
.. note :: Ruff can also be used for formatting code, but for now we recommend using Black for this purpose as the CI is configured to run Black on all PRs.
Pre-commit (Optional)
----
`Pre-commit <https://pre-commit.com/>`_ hooks are tools that help enforce quality standards by running checks on your code before you commit. If you choose to use pre-commit on your local machine, please follow these steps:
Expand All @@ -60,7 +46,7 @@ This needs to be done only once per repository. The pre-commit hooks will now au
Naming Conventions
------------------

While Black automatically conforms your code to a majority of the PEP 8 style guide (like whitespace usage, string quotes, code layout, etc.), your code still needs to conform to the `PEP 8 naming conventions <https://www.python.org/dev/peps/pep-0008/#naming-conventions>`_. The main things to keep in mind are:
While Ruff automatically conforms your code to a majority of the PEP 8 style guide (like whitespace usage, string quotes, code layout, etc.), your code still needs to conform to the `PEP 8 naming conventions <https://www.python.org/dev/peps/pep-0008/#naming-conventions>`_. The main things to keep in mind are:

- Function names should be lowercase, with words separated by underscores as necessary to improve readability (i.e. snake_case).

Expand Down
2 changes: 1 addition & 1 deletion docs/contributing/development/developer_faq.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ Class design and inheritance:
* If only constructor changed -> use classmethod
* if overriding other methods -> subclass

We use black to check PEP8 compliances.
We use ruff to check PEP8 compliances.

0 comments on commit 884dd9e

Please sign in to comment.