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

Fix lint task in CI #2141

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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 .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
- uses: prefix-dev/setup-pixi@v0.8.2
with:
environments: lint
- run: pixi run --environment lint lint
- run: pixi run --environment lint lint --all-files --show-diff-on-failure

test-linux:
runs-on: ubuntu-latest
Expand Down
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ repos:
language: system
types: [text]

- id: ruff check
- id: ruff-check
name: Lint with ruff
entry: pixi run -e lint ruff check --force-exclude --fix
language: system
types_or: [python, pyi, jupyter]
require_serial: true

- id: ruff format
- id: ruff-format
name: Format with ruff
entry: pixi run -e lint ruff format --force-exclude
language: system
Expand Down
2 changes: 1 addition & 1 deletion docs/user/numpy.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"Q_ = ureg.Quantity\n",
"\n",
"# Silence NEP 18 warning\n",
"import warnings\n",
"import warnings # noqa: E402\n",
"\n",
"with warnings.catch_warnings():\n",
" warnings.simplefilter(\"ignore\")\n",
Expand Down
8 changes: 4 additions & 4 deletions downstream_status.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ if you need a template.

Then, add your project badges to this file so it can be used as a Dashboard (always putting the stable first)

| Project | stable | pre-release | nightly |
| Project | stable | pre-release | nightly |
| ----------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [Pint Downstream Demo](https://github.com/hgrecco/pint-downstream-demo) | [![CI](https://github.com/hgrecco/pint-downstream-demo/actions/workflows/ci.yml/badge.svg)](https://github.com/hgrecco/pint-downstream-demo/actions/workflows/ci.yml) | [![CI-pint-pre](https://github.com/hgrecco/pint-downstream-demo/actions/workflows/ci-pint-pre.yml/badge.svg)](https://github.com/hgrecco/pint-downstream-demo/actions/workflows/ci-pint-pre.yml) | [![CI-pint-master](https://github.com/hgrecco/pint-downstream-demo/actions/workflows/ci-pint-master.yml/badge.svg)](https://github.com/hgrecco/pint-downstream-demo/actions/workflows/ci-pint-master.yml) |
| [Pint Pandas](https://github.com/hgrecco/pint-pandas) | [![CI](https://github.com/hgrecco/pint-pandas/actions/workflows/ci.yml/badge.svg)](https://github.com/hgrecco/pint-pandas/actions/workflows/ci.yml) | [![CI-pint-pre](https://github.com/hgrecco/pint-pandas/actions/workflows/ci-pint-pre.yml/badge.svg)](https://github.com/hgrecco/pint-pandas/actions/workflows/ci-pint-pre.yml) | [![CI-pint-master](https://github.com/hgrecco/pint-pandas/actions/workflows/ci-pint-master.yml/badge.svg)](https://github.com/hgrecco/pint-pandas/actions/workflows/ci-pint-master.yml) |
| [MetPy](https://github.com/Unidata/MetPy) | [![CI](https://github.com/Unidata/MetPy/actions/workflows/tests-pypi.yml/badge.svg)](https://github.com/Unidata/MetPy/actions/workflows/tests-pypi.yml) | | [![CI-pint-master](https://github.com/Unidata/MetPy/actions/workflows/nightly-builds.yml/badge.svg)](https://github.com/Unidata/MetPy/actions/workflows/nightly-builds.yml) |
| [pint-xarray](https://github.com/xarray-contrib/pint-xarray) | [![CI](https://github.com/xarray-contrib/pint-xarray/actions/workflows/ci.yml/badge.svg)](https://github.com/xarray-contrib/pint-xarray/actions/workflows/ci.yml) | | [![CI-pint-master](https://github.com/xarray-contrib/pint-xarray/actions/workflows/nightly.yml/badge.svg)](https://github.com/xarray-contrib/pint-xarray/actions/workflows/nightly.yml) |
| [Pint Pandas](https://github.com/hgrecco/pint-pandas) | [![CI](https://github.com/hgrecco/pint-pandas/actions/workflows/ci.yml/badge.svg)](https://github.com/hgrecco/pint-pandas/actions/workflows/ci.yml) | [![CI-pint-pre](https://github.com/hgrecco/pint-pandas/actions/workflows/ci-pint-pre.yml/badge.svg)](https://github.com/hgrecco/pint-pandas/actions/workflows/ci-pint-pre.yml) | [![CI-pint-master](https://github.com/hgrecco/pint-pandas/actions/workflows/ci-pint-master.yml/badge.svg)](https://github.com/hgrecco/pint-pandas/actions/workflows/ci-pint-master.yml) |
| [MetPy](https://github.com/Unidata/MetPy) | [![CI](https://github.com/Unidata/MetPy/actions/workflows/tests-pypi.yml/badge.svg)](https://github.com/Unidata/MetPy/actions/workflows/tests-pypi.yml) | | [![CI-pint-master](https://github.com/Unidata/MetPy/actions/workflows/nightly-builds.yml/badge.svg)](https://github.com/Unidata/MetPy/actions/workflows/nightly-builds.yml) |
| [pint-xarray](https://github.com/xarray-contrib/pint-xarray) | [![CI](https://github.com/xarray-contrib/pint-xarray/actions/workflows/ci.yml/badge.svg)](https://github.com/xarray-contrib/pint-xarray/actions/workflows/ci.yml) | | [![CI-pint-master](https://github.com/xarray-contrib/pint-xarray/actions/workflows/nightly.yml/badge.svg)](https://github.com/xarray-contrib/pint-xarray/actions/workflows/nightly.yml) |
16 changes: 8 additions & 8 deletions pint/__init__.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
"""
pint
~~~~
pint
~~~~

Pint is Python module/package to define, operate and manipulate
**physical quantities**: the product of a numerical value and a
unit of measurement. It allows arithmetic operations between them
and conversions from and to different units.
Pint is Python module/package to define, operate and manipulate
**physical quantities**: the product of a numerical value and a
unit of measurement. It allows arithmetic operations between them
and conversions from and to different units.

:copyright: 2016 by Pint Authors, see AUTHORS for more details.
:license: BSD, see LICENSE for more details.
:copyright: 2016 by Pint Authors, see AUTHORS for more details.
:license: BSD, see LICENSE for more details.
"""

from __future__ import annotations
Expand Down
3 changes: 1 addition & 2 deletions pint/_typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,4 @@


class Handler(Protocol):
def __getitem__(self, item: type[T]) -> Callable[[T], None]:
...
def __getitem__(self, item: type[T]) -> Callable[[T], None]: ...
8 changes: 4 additions & 4 deletions pint/babel_names.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
"""
pint.babel
~~~~~~~~~~
pint.babel
~~~~~~~~~~

:copyright: 2016 by Pint Authors, see AUTHORS for more details.
:license: BSD, see LICENSE for more details.
:copyright: 2016 by Pint Authors, see AUTHORS for more details.
:license: BSD, see LICENSE for more details.
"""

from __future__ import annotations
Expand Down
10 changes: 5 additions & 5 deletions pint/converters.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
"""
pint.converters
~~~~~~~~~~~~~~~
pint.converters
~~~~~~~~~~~~~~~

Functions and classes related to unit conversions.
Functions and classes related to unit conversions.

:copyright: 2016 by Pint Authors, see AUTHORS for more details.
:license: BSD, see LICENSE for more details.
:copyright: 2016 by Pint Authors, see AUTHORS for more details.
:license: BSD, see LICENSE for more details.
"""

from __future__ import annotations
Expand Down
10 changes: 5 additions & 5 deletions pint/definitions.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
"""
pint.definitions
~~~~~~~~~~~~~~~~
pint.definitions
~~~~~~~~~~~~~~~~

Kept for backwards compatibility
Kept for backwards compatibility

:copyright: 2022 by Pint Authors, see AUTHORS for more details.
:license: BSD, see LICENSE for more details.
:copyright: 2022 by Pint Authors, see AUTHORS for more details.
:license: BSD, see LICENSE for more details.
"""

from __future__ import annotations
Expand Down
11 changes: 6 additions & 5 deletions pint/delegates/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
"""
pint.delegates
~~~~~~~~~~~~~~
pint.delegates
~~~~~~~~~~~~~~

Defines methods and classes to handle autonomous tasks.
Defines methods and classes to handle autonomous tasks.

:copyright: 2022 by Pint Authors, see AUTHORS for more details.
:license: BSD, see LICENSE for more details.
:copyright: 2022 by Pint Authors, see AUTHORS for more details.
:license: BSD, see LICENSE for more details.
"""

from __future__ import annotations

from . import txt_defparser
Expand Down
10 changes: 5 additions & 5 deletions pint/delegates/base_defparser.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
"""
pint.delegates.base_defparser
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
pint.delegates.base_defparser
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Common class and function for all parsers.
Common class and function for all parsers.

:copyright: 2022 by Pint Authors, see AUTHORS for more details.
:license: BSD, see LICENSE for more details.
:copyright: 2022 by Pint Authors, see AUTHORS for more details.
:license: BSD, see LICENSE for more details.
"""

from __future__ import annotations
Expand Down
15 changes: 8 additions & 7 deletions pint/delegates/formatter/__init__.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
"""
pint.delegates.formatter
~~~~~~~~~~~~~~~~~~~~~~~~
pint.delegates.formatter
~~~~~~~~~~~~~~~~~~~~~~~~

Easy to replace and extend string formatting.
Easy to replace and extend string formatting.

See pint.delegates.formatter.plain.DefaultFormatter for a
description of a formatter.
See pint.delegates.formatter.plain.DefaultFormatter for a
description of a formatter.

:copyright: 2022 by Pint Authors, see AUTHORS for more details.
:license: BSD, see LICENSE for more details.
:copyright: 2022 by Pint Authors, see AUTHORS for more details.
:license: BSD, see LICENSE for more details.
"""

from __future__ import annotations

from .full import FullFormatter
Expand Down
11 changes: 5 additions & 6 deletions pint/delegates/formatter/_compound_unit_helpers.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
"""
pint.delegates.formatter._compound_unit_helpers
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
pint.delegates.formatter._compound_unit_helpers
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Convenient functions to help organize compount units.
Convenient functions to help organize compount units.

:copyright: 2022 by Pint Authors, see AUTHORS for more details.
:license: BSD, see LICENSE for more details.
:copyright: 2022 by Pint Authors, see AUTHORS for more details.
:license: BSD, see LICENSE for more details.
"""


from __future__ import annotations

import functools
Expand Down
15 changes: 7 additions & 8 deletions pint/delegates/formatter/_format_helpers.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
"""
pint.delegates.formatter._format_helpers
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
pint.delegates.formatter._format_helpers
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Convenient functions to help string formatting operations.
Convenient functions to help string formatting operations.

:copyright: 2022 by Pint Authors, see AUTHORS for more details.
:license: BSD, see LICENSE for more details.
:copyright: 2022 by Pint Authors, see AUTHORS for more details.
:license: BSD, see LICENSE for more details.
"""


from __future__ import annotations

import re
Expand Down Expand Up @@ -101,7 +100,7 @@ def override_locale(
def pretty_fmt_exponent(num: Number) -> str:
"""Format an number into a pretty printed exponent."""
# unicode dot operator (U+22C5) looks like a superscript decimal
ret = f"{num:n}".replace("-", "⁻").replace(".", "\u22C5")
ret = f"{num:n}".replace("-", "⁻").replace(".", "\u22c5")
for n in range(10):
ret = ret.replace(str(n), _PRETTY_EXPONENTS[n])
return ret
Expand Down Expand Up @@ -194,7 +193,7 @@ def formatter(
"""

if as_ratio:
fun = lambda x: exp_call(abs(x))
fun = lambda x: exp_call(abs(x)) # noqa: E731
else:
fun = exp_call

Expand Down
10 changes: 5 additions & 5 deletions pint/delegates/formatter/_to_register.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
"""
pint.delegates.formatter.base_formatter
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Common class and function for all formatters.
:copyright: 2022 by Pint Authors, see AUTHORS for more details.
:license: BSD, see LICENSE for more details.
pint.delegates.formatter.base_formatter
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Common class and function for all formatters.
:copyright: 2022 by Pint Authors, see AUTHORS for more details.
:license: BSD, see LICENSE for more details.
"""

from __future__ import annotations
Expand Down
12 changes: 6 additions & 6 deletions pint/delegates/formatter/full.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
"""
pint.delegates.formatter.full
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
pint.delegates.formatter.full
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Implements:
- Full: dispatch to other formats, accept defaults.
Implements:
- Full: dispatch to other formats, accept defaults.

:copyright: 2022 by Pint Authors, see AUTHORS for more details.
:license: BSD, see LICENSE for more details.
:copyright: 2022 by Pint Authors, see AUTHORS for more details.
:license: BSD, see LICENSE for more details.
"""

from __future__ import annotations
Expand Down
14 changes: 7 additions & 7 deletions pint/delegates/formatter/html.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
"""
pint.delegates.formatter.html
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
pint.delegates.formatter.html
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Implements:
- HTML: suitable for web/jupyter notebook outputs.
Implements:
- HTML: suitable for web/jupyter notebook outputs.

:copyright: 2022 by Pint Authors, see AUTHORS for more details.
:license: BSD, see LICENSE for more details.
:copyright: 2022 by Pint Authors, see AUTHORS for more details.
:license: BSD, see LICENSE for more details.
"""

from __future__ import annotations
Expand Down Expand Up @@ -77,7 +77,7 @@ def format_magnitude(
)

m = _EXP_PATTERN.match(mstr)
_exp_formatter = lambda s: f"<sup>{s}</sup>"
_exp_formatter = lambda s: f"<sup>{s}</sup>" # noqa: E731

if m:
exp = int(m.group(2) + m.group(3))
Expand Down
15 changes: 7 additions & 8 deletions pint/delegates/formatter/latex.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
"""
pint.delegates.formatter.latex
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
pint.delegates.formatter.latex
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Implements:
- Latex: uses vainilla latex.
- SIunitx: uses latex siunitx package format.
Implements:
- Latex: uses vainilla latex.
- SIunitx: uses latex siunitx package format.

:copyright: 2022 by Pint Authors, see AUTHORS for more details.
:license: BSD, see LICENSE for more details.
:copyright: 2022 by Pint Authors, see AUTHORS for more details.
:license: BSD, see LICENSE for more details.
"""


from __future__ import annotations

import functools
Expand Down
18 changes: 9 additions & 9 deletions pint/delegates/formatter/plain.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
"""
pint.delegates.formatter.plain
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
pint.delegates.formatter.plain
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Implements plain text formatters:
- Raw: as simple as it gets (no locale aware, no unit formatter.)
- Default: used when no string spec is given.
- Compact: like default but with less spaces.
- Pretty: pretty printed formatter.
Implements plain text formatters:
- Raw: as simple as it gets (no locale aware, no unit formatter.)
- Default: used when no string spec is given.
- Compact: like default but with less spaces.
- Pretty: pretty printed formatter.

:copyright: 2022 by Pint Authors, see AUTHORS for more details.
:license: BSD, see LICENSE for more details.
:copyright: 2022 by Pint Authors, see AUTHORS for more details.
:license: BSD, see LICENSE for more details.
"""

from __future__ import annotations
Expand Down
11 changes: 6 additions & 5 deletions pint/delegates/txt_defparser/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
"""
pint.delegates.txt_defparser
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
pint.delegates.txt_defparser
~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Parser for the original textual Pint Definition file.
Parser for the original textual Pint Definition file.

:copyright: 2022 by Pint Authors, see AUTHORS for more details.
:license: BSD, see LICENSE for more details.
:copyright: 2022 by Pint Authors, see AUTHORS for more details.
:license: BSD, see LICENSE for more details.
"""

from __future__ import annotations

from .defparser import DefParser
Expand Down
Loading
Loading