Skip to content

Commit

Permalink
Switch to ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
alifbe committed Jan 29, 2024
1 parent 2a8cfa8 commit 846350c
Show file tree
Hide file tree
Showing 37 changed files with 530 additions and 571 deletions.
3 changes: 0 additions & 3 deletions .codacy.yml

This file was deleted.

5 changes: 0 additions & 5 deletions .flake8

This file was deleted.

17 changes: 6 additions & 11 deletions .github/workflows/pyscal.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,25 +58,20 @@ jobs:
if: ${{ always() }}
run: pip freeze

- name: Lint with black
- name: Ruff check
if: ${{ always() }}
run: |
black --check --force-exclude="pyscal/version.py" pyscal tests docs
- name: Lint with flake8
if: ${{ always() }}
run: |
flake8 pyscal tests
- name: Lint with isort
ruff check .
- name: Ruff format
if: ${{ always() }}
run: |
isort --check-only --profile black pyscal tests
ruff format . --check
- name: Check typing with mypy
if: ${{ always() }}
run: |
mypy pyscal
mypy ./pyscal
- name: Run tests
if: ${{ always() }}
Expand Down
23 changes: 0 additions & 23 deletions .pylintrc

This file was deleted.

30 changes: 0 additions & 30 deletions .travis.yml

This file was deleted.

83 changes: 60 additions & 23 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,42 +5,79 @@ Contributing to pyscal
* Submit bugs on github
* Pull requests are welcome!

Code style
----------

* Use the black formatter to format your code
Create pull request
-------------------

* ``pip install black``
* ``black <modulename.py>`` -- must be done prior to any pull request.
1. Fork the pyscal repository from the Equinor repository to your GitHub
user account.

* Use flake8 code checker
2. Clone your fork locally:

.. code-block:: bash
git clone [email protected]:your_name_here/pyscal
cd pyscal
git remote add upstream [email protected]:equinor/pyscal
git remote -v
# origin [email protected]:your_name_here/pyscal (fetch)
# origin [email protected]:your_name_here/pyscal (push)
# upstream [email protected]:equinor/pyscal (fetch)
# upstream [email protected]:equinor/pyscal (push)
* ``pip install flake8``
* ``flake8 src tests`` must pass before any pull request is accepted
* Exceptions are listed in ``setup.cfg``
4. Install your forked copy into a local venv:

* Use pylint to improve coding
.. code-block:: bash
python -m venv ~/venv/pyscal
source ~/venv/pyscal/bin/activate
pip install -U pip
pip install -e ".[tests,docs]"
5. Run the tests to ensure everything works:

* ``pip install pylint``
* Then run ``pylint pyscal``
* Deviations from default (strict) pylint are stored in ``.pylintrc`` at root level,
or as comments in the file e.g. ``# pylint: disable=broad-except``.
* Only use deviations when e.g. black and pylint are in conflict, or if conformity with
pylint would clearly make the code worse or not work at all. Do not use it to
increase pylint score.
.. code-block:: bash
pytest -n auto
6. Create a branch for local development:

.. code-block:: bash
git checkout -b name-of-your-bugfix-or-feature
Now you can make your changes locally.

7. When you're done making changes, check that your changes pass ruff, mypy and the
tests:

.. code-block:: bash
ruff check .
ruff format .
mypy ./pyscal
pytest -n auto
8. Commit your changes and push your branch to GitHub:

.. code-block:: bash
git add file1.py file2.py
git commit -m "Add some feature"
git push origin name-of-your-bugfix-or-feature
9. Submit a pull request through GitHub.

* All code must be throroughly tested with ``pytest``.

Building documentation
----------------------

Install the development requirements::

pip install .[tests]
To build the documentation for pyscal run the following command:

Then, to build the documentation for pyscal run the following command::
.. code-block:: bash
python setup.py build_sphinx
python docs/make_plots.py
sphinx-build -b html docs ./build/sphinx/html
And now you can find the start page of the documentation in the
build folder: ``build/sphinx/html/index.html``.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[![Build Status](https://github.com/equinor/pyscal/actions/workflows/pyscal.yml/badge.svg)](https://github.com/equinor/pyscal/actions?query=workflow%3Apyscal)
[![codecov](https://codecov.io/gh/equinor/pyscal/branch/master/graph/badge.svg)](https://codecov.io/gh/equinor/pyscal)
[![Python 3.8-3.11](https://img.shields.io/badge/python-3.8%20|%203.9%20|%203.10|%203.11-blue.svg)](https://www.python.org)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://black.readthedocs.io/)
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
[![PyPI version](https://badge.fury.io/py/pyscal.svg)](https://badge.fury.io/py/pyscal)
[![Downloads](https://pepy.tech/badge/pyscal)](https://pepy.tech/project/pyscal)
[![License: GPL v3](https://img.shields.io/badge/License-LGPLv3-blue.svg)](https://www.gnu.org/licenses/lgpl-3.0)
Expand Down
5 changes: 2 additions & 3 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,11 @@
# import os
# import sys
# sys.path.insert(0, os.path.abspath('.'))
import pkg_resources
import datetime

# -- Project information -----------------------------------------------------
import pkg_resources

import pyscal
# -- Project information -----------------------------------------------------

project = "pyscal"
author = "Håvard Berland"
Expand Down
Loading

0 comments on commit 846350c

Please sign in to comment.