From 884dd9e51ffde6299ae8c585f303f70970976750 Mon Sep 17 00:00:00 2001 From: KasukabeDefenceForce Date: Fri, 11 Oct 2024 16:51:01 +0530 Subject: [PATCH] Remove black and update with ruff --- README_TEMPLATE.rst | 3 --- docs/contributing/development/code_quality.rst | 16 +--------------- docs/contributing/development/developer_faq.rst | 2 +- 3 files changed, 2 insertions(+), 19 deletions(-) diff --git a/README_TEMPLATE.rst b/README_TEMPLATE.rst index 2310b633728..07374893d7b 100644 --- a/README_TEMPLATE.rst +++ b/README_TEMPLATE.rst @@ -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 | diff --git a/docs/contributing/development/code_quality.rst b/docs/contributing/development/code_quality.rst index 0bac7873b95..b7e336ce716 100644 --- a/docs/contributing/development/code_quality.rst +++ b/docs/contributing/development/code_quality.rst @@ -16,16 +16,6 @@ Code Style Conventions TARDIS follows the `PEP 8 `_ 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 `_ 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 `_ 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 `_ 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: :: @@ -37,12 +27,8 @@ To run Ruff, use the following command: :: ruff check # Lints the code ruff check --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 `_ 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: @@ -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 `_. 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 `_. 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). diff --git a/docs/contributing/development/developer_faq.rst b/docs/contributing/development/developer_faq.rst index da321570894..90b46a30c22 100644 --- a/docs/contributing/development/developer_faq.rst +++ b/docs/contributing/development/developer_faq.rst @@ -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.