Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[nc-time-axis] QA refresh linter hooks #293

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
4b37793
Updated pre-commit-config.yaml with:
ukmo-ccbunney Nov 20, 2024
e765304
Added blacken-docs hook.
ukmo-ccbunney Nov 20, 2024
696a76d
small update to tpyes in codespell hook
ukmo-ccbunney Nov 20, 2024
01d78a4
Added Ruff linter to replace black, flake8 and isort.
ukmo-ccbunney Nov 20, 2024
12bdf3a
Ignores for Ruff linter
ukmo-ccbunney Nov 20, 2024
12cc421
Autofixes
ukmo-ccbunney Nov 20, 2024
4efd098
Added mypy linter and exceptions
ukmo-ccbunney Nov 20, 2024
0096af3
Added numpydoc and exceptions
ukmo-ccbunney Nov 20, 2024
754f073
Reorder hooks alphabetically
ukmo-ccbunney Nov 20, 2024
dce0db9
Added sort-all hook
ukmo-ccbunney Nov 20, 2024
d362f73
Added validate-pyproject hook
ukmo-ccbunney Nov 20, 2024
8347ea8
Added sp-repo-review hook and excludes.
ukmo-ccbunney Nov 20, 2024
0b3dbdb
Added references to SciTools linters Wiki
ukmo-ccbunney Nov 21, 2024
3970ef5
Fixed repo-review "PP304" [Sets the log level in pytest]
ukmo-ccbunney Nov 21, 2024
6e3db2b
Fixed sp-repo-review: "GH212" [Require GHA update grouping]
ukmo-ccbunney Nov 21, 2024
43bac01
Removed wheel from build (Fixes sp-repo-review "PP003")
ukmo-ccbunney Nov 21, 2024
de7d178
Alphabetised pyproject.toml sections (manually)
ukmo-ccbunney Nov 21, 2024
4428be5
Try to fix brocken docs build
ukmo-ccbunney Nov 21, 2024
1c6f9f6
Fixed docs build (had to make `.. blacken-docs:off` apply to whole co…
ukmo-ccbunney Nov 21, 2024
b0dcb83
Merge branch 'main' into qa_refresh_pre-commit_hooks
ukmo-ccbunney Nov 21, 2024
f40532e
Better comment on ruff select list
ukmo-ccbunney Nov 21, 2024
9e31436
Added annotations to ruff ignore list
ukmo-ccbunney Nov 21, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ ignore =
W503,
# W504: line break after binary operator
W504
exclude =
exclude =
.eggs
build
docs/conf.py
8 changes: 4 additions & 4 deletions .github/ISSUE_TEMPLATE/bug-report.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ assignees: ''
## How to Reproduce
Steps to reproduce the behaviour:

1.
2.
3.
1.
2.
3.

## Expected Behaviour
<!-- A clear and concise description of what you expected to happen -->

## Environment
## Environment
- OS & Version: [e.g., Ubuntu 20.04 LTS]
- nc-time-axis Version: [e.g., From the command line run `python -c "import nc_time_axis; print(nc_time_axis.__version__)"`]

Expand Down
4 changes: 4 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ updates:
day: "thursday"
time: "01:00"
timezone: "Europe/London"
groups:
dependencies:
patterns:
- "*"
labels:
- "New: Pull Request"
- "Bot"
87 changes: 69 additions & 18 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,26 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
# See https://pre-commit.ci/#configuration
# See https://github.com/scientific-python/cookie#sp-repo-review
# See https://github.com/SciTools/.github/wiki/Linting for common linter rules

ci:
autofix_prs: false
autoupdate_commit_msg: "chore: update pre-commit hooks"

# Alphabetised, for lack of a better order.
files: |
(?x)(
docs\/.+\.(py|rst)|
pyproject\.toml|
setup\.py|
src\/.+\.py
)
minimum_pre_commit_version: 1.21.0

repos:

# Hook for pre-commit's built-in checks:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: 'v5.0.0'
hooks:
Expand All @@ -19,37 +38,69 @@ repos:
- id: check-toml
# Check YAML file syntax.
- id: check-yaml
# Makes sure files end in a newline and only a newline
# Makes sure files end in a newline and only a newline.
# Duplicates Ruff W292 but also works on non-Python files.
- id: end-of-file-fixer
# Replaces or checks mixed line ending
- id: mixed-line-ending
# Don't commit to main branch.
- id: no-commit-to-branch
# Trims trailing whitespace.
# Duplicates Ruff W291 but also works on non-Python files.
- id: trailing-whitespace

- repo: https://github.com/psf/black
rev: '24.10.0'
# Hooks for all other repos.
# Keep these alphabetised by hook (aka 'id') order.

- repo: https://github.com/adamchainz/blacken-docs
rev: 1.19.1
hooks:
- id: black
- id: blacken-docs
types: [file, rst]

- repo: https://github.com/codespell-project/codespell
rev: 'v2.3.0'
hooks:
- id: codespell
types_or: [asciidoc, python, markdown, rst]
additional_dependencies: [tomli]

- repo: https://github.com/pre-commit/mirrors-mypy
rev: 'v1.13.0'
hooks:
- id: mypy
exclude: 'noxfile\.py|docs/conf\.py'

- repo: https://github.com/numpy/numpydoc
rev: v1.8.0
hooks:
- id: numpydoc-validation
types: [file, python]
args: [--config=./pyproject.toml, .]

- repo: https://github.com/PyCQA/flake8
rev: '7.1.1'
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.7.4"
hooks:
- id: flake8
- id: ruff
types: [file, python]
args: [--fix, --show-fixes]
- id: ruff-format
types: [file, python]
args: [--config=./.flake8]

- repo: https://github.com/pycqa/isort
rev: '5.13.2'
- repo: https://github.com/aio-libs/sort-all
rev: v1.3.0
hooks:
- id: isort
- id: sort-all
types: [file, python]
args: ["--profile", "black", "--filter-files"]

- repo: https://github.com/codespell-project/codespell
rev: 'v2.3.0'
- repo: https://github.com/scientific-python/cookie
rev: 2024.08.19
hooks:
- id: codespell
types_or: [python, markdown, rst]
additional_dependencies: [tomli]
- id: sp-repo-review
additional_dependencies: ["repo-review[cli]"]
args: ["--show=errskip"]

- repo: https://github.com/abravalheri/validate-pyproject
# More exhaustive than Ruff RUF200.
rev: "v0.23"
hooks:
- id: validate-pyproject
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ We would love to hear from you!
- [View/discuss existing pull requests](https://github.com/SciTools/nc-time-axis/pulls)
- [Raise a new pull request](https://github.com/SciTools/nc-time-axis/compare)

Note that all authors on pull requests will automatically be asked to sign the
Note that all authors on pull requests will automatically be asked to sign the
[SciTools Contributor Licence Agreement](https://cla-assistant.io/SciTools/)
(CLA), if they have not already done so.
(CLA), if they have not already done so.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
BSD 3-Clause License
Copyright (c) 2016, Met Office.
Copyright (c) 2016, Met Office.
All rights reserved.

Redistribution and use in source and binary forms, with or without
Expand Down
21 changes: 18 additions & 3 deletions docs/examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ Basic Usage
`matplotlib`_. To register its converters, simply ``import nc_time_axis``. Then you
will be able to make plots with :py:class:`cftime.datetime` axes.

..
comment: @savefig causes blacken-docs to fail

.. blacken-docs:off

.. ipython:: python
:okwarning:

Expand All @@ -30,6 +35,8 @@ will be able to make plots with :py:class:`cftime.datetime` axes.
@savefig basic.png
fig.show()

.. blacken-docs:on

Setting the Axes Ticks and Tick Format
--------------------------------------

Expand All @@ -43,14 +50,22 @@ documentation
for acceptable format codes) and the calendar type of the axis (see
the :py:class:`cftime.datetime` documentation for valid calendar strings).

..
@savefig causes blacken-docs to fail

.. blacken-docs:off

.. ipython:: python
:okwarning:

fig, ax = plt.subplots(1, 1)
ax.plot(times, y);
ax.set_xticks([cftime.datetime(2000, 1, day, calendar="noleap") for day in range(2, 19, 4)]);
ax.plot(times, y)
ax.set_xticks(
[cftime.datetime(2000, 1, day, calendar="noleap") for day in range(2, 19, 4)]
)
formatter = nc_time_axis.CFTimeFormatter("%m-%d %H:%M", "noleap")
ax.xaxis.set_major_formatter(formatter)

@savefig set_ticks.png
fig.show()

.. blacken-docs:on
2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ nc-time-axis
============

``nc-time-axis`` is a package that enables making plots in `matplotlib`_ with axes made
up of :py:class:`cftime.datetime` dates with any calendar type.
up of :py:class:`cftime.datetime` dates with any calendar type.

.. toctree::
:caption: Getting started
Expand Down
6 changes: 3 additions & 3 deletions docs/release-notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ v1.4.0 (October 23rd, 2021)
---------------------------

Deprecations
~~~~~~~~~~~~
~~~~~~~~~~~~

* The :py:class:`CalendarDateTime` class has been deprecated and will be removed
in ``nc-time-axis`` version 1.5.0. Please switch to plotting instances or
Expand Down Expand Up @@ -122,10 +122,10 @@ Bug Fixes
:py:meth:`matplotlib.axes.Axes.fill_between` to work properly with `cftime`_
values (:issue:`47`, :issue:`74`, :pull:`78`).
By `Pascal Bourgault`_.
* Fixed a bug that resulted in the resolution of tick labels being inconsistent
* Fixed a bug that resulted in the resolution of tick labels being inconsistent
with the resolution of tick values (:issue:`48`, :pull:`79`).
By `Spencer Clark`_.
* Fixed a bug that prevented users from being able to explicitly set the ticks
* Fixed a bug that prevented users from being able to explicitly set the ticks
along axes using :py:meth:`matplotlib.axes.Axes.set_xticks` or
:py:meth:`matplotlib.axes.Axes.set_yticks` (:issue:`41`, :pull:`84`).
By `Spencer Clark`_.
Expand Down
Loading
Loading