-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Use ruff for code linting and formatting close #429 - Update contributing documentation - Remove sphinx pin
- Loading branch information
Showing
37 changed files
with
531 additions
and
571 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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``. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.