Skip to content

Commit

Permalink
chore: update formatting and pre-commit config
Browse files Browse the repository at this point in the history
  • Loading branch information
kmnhan committed Dec 17, 2024
1 parent f173a50 commit 3c7b4f0
Show file tree
Hide file tree
Showing 9 changed files with 330 additions and 32 deletions.
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
version: 2
updates:
# Maintain dependencies for GitHub Actions
# Maintain dependencies for GitHub Actions
- package-ecosystem: "github-actions"
directory: "/"
schedule:
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Test

on:
push:
branches: [ "main" ]
branches: ["main"]
pull_request:
workflow_dispatch:
schedule:
Expand All @@ -19,7 +19,7 @@ jobs:
name: Test Python ${{ matrix.python-version }} [${{ matrix.qt-api }}]
runs-on: ubuntu-latest
env:
DISPLAY: ':99.0'
DISPLAY: ":99.0"
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -75,7 +75,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.12'
python-version: "3.12"

- name: Install mypy and dependencies
run: |
Expand Down Expand Up @@ -105,7 +105,7 @@ jobs:

- uses: actions/setup-python@v5
with:
python-version: '3.12'
python-version: "3.12"

- name: Install dependencies
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
changelog_increment_filename: body.md
extra_requirements : "cz-changeup"
extra_requirements: "cz-changeup"

- name: Build package distributions
id: build
Expand Down
17 changes: 13 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ ci:
default_install_hook_types: [pre-commit, commit-msg]

repos:

# Meta hooks
- repo: meta
hooks:
Expand All @@ -30,14 +29,24 @@ repos:
- id: mixed-line-ending
- id: trailing-whitespace

# Pygrep hooks
- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.10.0
hooks:
- id: rst-backticks
- id: rst-directive-colons
- id: rst-inline-touching-normal
- id: text-unicode-replacement-char
- id: python-use-type-annotations

# Lint and format with ruff
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.8.1
hooks:
# Run the linter.
- id: ruff
args: [ --fix, --show-fixes ]
args: [--fix, --show-fixes]
# Run the formatter.
- id: ruff-format

Expand All @@ -46,7 +55,7 @@ repos:
rev: v4.0.0
hooks:
- id: commitizen
additional_dependencies: [ cz-changeup ]
additional_dependencies: [cz-changeup]
- id: commitizen-branch
additional_dependencies: [ cz-changeup ]
additional_dependencies: [cz-changeup]
stages: [pre-push]
285 changes: 285 additions & 0 deletions CHANGELOG.md

Large diffs are not rendered by default.

7 changes: 5 additions & 2 deletions docs/source/_static/custom.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
dl[class]:not(.option-list):not(.field-list):not(.footnote):not(.glossary):not(.simple) .field-list>dt {
dl[class]:not(.option-list):not(.field-list):not(.footnote):not(.glossary):not(
.simple
)
.field-list
> dt {
font-size: var(--font-size--small);
text-transform: uppercase;
background-color: var(--color-background-secondary);
Expand All @@ -8,7 +12,6 @@ span.default_value {
font-weight: normal;
}


/* Fix for xarray dark mode */
/* https://github.com/pradyunsg/furo/discussions/790#discussioncomment-9298183 */
html,
Expand Down
1 change: 1 addition & 0 deletions docs/source/changelog.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Changelog

```{include} ../../CHANGELOG.md
```
18 changes: 9 additions & 9 deletions docs/source/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ report <https://stackoverflow.com/help/mcve>`_, and this `article on minimal bug
Creating a development environment
==================================

First, you will need to install `git` and `conda` (or `mamba`).
First, you will need to install ``git`` and ``conda`` (or ``mamba``).

Installing git
--------------
Expand Down Expand Up @@ -80,7 +80,7 @@ Cloning the repository
cd erlabpy
git remote add upstream https://github.com/kmnhan/erlabpy.git

This creates the directory `erlabpy` and connects your repository to the upstream
This creates the directory ``erlabpy`` and connects your repository to the upstream
(main project) *erlabpy* repository.


Expand Down Expand Up @@ -297,25 +297,25 @@ add tests, follow these steps:
return, and use this as a reference in the tests. See preexisting directories and
tests for examples.

4. Set the environment variable `ERLAB_TEST_DATA_DIR` to the path of the cloned
4. Set the environment variable ``ERLAB_TEST_DATA_DIR`` to the path of the cloned
`erlabpy-data <https://github.com/kmnhan/erlabpy-data>`_ repository in your
development environment. This will allow the tests to access the test data.

5. Now, we can work with the original `erlabpy <https://github.com/kmnhan/erlabpy>`_
repository to write and run tests for the plugin. Add your tests in
`tests/io/plugins/test_<plugin_name>.py`. You can use the `test_data_dir` fixture to
access the test data directory. See other modules in the folder for examples.
``tests/io/plugins/test_<plugin_name>.py``. You can use the ``test_data_dir`` fixture
to access the test data directory. See other modules in the folder for examples.

6. Run the tests using `pytest <https://docs.pytest.org/>`_ and make sure they pass.

7. Now, it's time to apply your changes. First, push your changes to `erlabpy-data
<https://github.com/kmnhan/erlabpy-data>`_ and create a pull request.

8. Once your pull request to `erlabpy-data <https://github.com/kmnhan/erlabpy-data>`_ is
merged, update the `DATA_COMMIT_HASH` and `DATA_KNOWN_HASH` attributes in
`tests/conftest.py`.
merged, update the ``DATA_COMMIT_HASH`` and ``DATA_KNOWN_HASH`` attributes in
``tests/conftest.py``.

- `DATA_COMMIT_HASH` should be the commit hash of `erlabpy-data
- ``DATA_COMMIT_HASH`` should be the commit hash of `erlabpy-data
<https://github.com/kmnhan/erlabpy-data>`_ that contains your test data. This will
ensure that the version of the test data used in the tests is consistent.

Expand All @@ -325,7 +325,7 @@ add tests, follow these steps:
<https://github.com/kmnhan/erlabpy-data/commits/main/>`_ page will copy the full
hash to your clipboard.

- `DATA_KNOWN_HASH` is the file hash of the test data tarball. This will ensure that
- ``DATA_KNOWN_HASH`` is the file hash of the test data tarball. This will ensure that
the test data has not been modified or corrupted since the last time the tests were
run.

Expand Down
22 changes: 11 additions & 11 deletions docs/source/reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ Subpackages
======================== ========================
Subpackage Description
======================== ========================
`erlab.analysis` Routines for analyzing ARPES data.
`erlab.io` Reading and writing data.
`erlab.plotting` Functions related to static plotting with matplotlib.
`erlab.interactive` Interactive tools and widgets based on Qt and pyqtgraph
`erlab.accessors` `xarray accessors <https://docs.xarray.dev/en/stable/internals/extending-xarray.html>`_. You will not need to import this module directly.
`erlab.utils` Utility functions and classes, typically used internally.
``erlab.analysis`` Routines for analyzing ARPES data.
``erlab.io`` Reading and writing data.
``erlab.plotting`` Functions related to static plotting with matplotlib.
``erlab.interactive`` Interactive tools and widgets based on Qt and pyqtgraph
``erlab.accessors`` `xarray accessors <https://docs.xarray.dev/en/stable/internals/extending-xarray.html>`_. You will not need to import this module directly.
``erlab.utils`` Utility functions and classes, typically used internally.
======================== ========================

.. currentmodule:: erlab
Expand All @@ -33,12 +33,12 @@ Subpackage Description
Submodules
==========

================== ==================
=================== ==================
Submodule Description
================== ==================
`erlab.lattice` Tools for working with real and reciprocal lattices.
`erlab.constants` Physical constants and functions for unit conversion.
================== ==================
=================== ==================
``erlab.lattice`` Tools for working with real and reciprocal lattices.
``erlab.constants`` Physical constants and functions for unit conversion.
=================== ==================

.. toctree::
:hidden:
Expand Down

0 comments on commit 3c7b4f0

Please sign in to comment.