From dfd0cb630010de53a1cf6e3f69bf2a5cd8c016d7 Mon Sep 17 00:00:00 2001 From: Hassan Kibirige Date: Wed, 27 Mar 2024 13:17:04 +0300 Subject: [PATCH] LINT: Updated linter --- .pre-commit-config.yaml | 4 ++-- Makefile | 2 +- mizani/_colors/_palettes/_palette.py | 1 + mizani/_colors/hsluv.py | 3 ++- mizani/_core/dates.py | 6 ++---- mizani/bounds.py | 7 +++---- mizani/breaks.py | 1 + mizani/labels.py | 1 + mizani/palettes.py | 1 + mizani/scale.py | 1 + mizani/transforms.py | 1 + mizani/typing.py | 9 +++------ mizani/utils.py | 6 ++---- tools/gha_check_semver.py | 1 + 14 files changed, 22 insertions(+), 22 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 080c185..7372d6c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - - repo: https://github.com/charliermarsh/ruff-pre-commit - rev: v0.1.8 + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.3.4 hooks: - id: ruff args: [--select=I001, --fix] diff --git a/Makefile b/Makefile index edc2c2a..cd61fa8 100644 --- a/Makefile +++ b/Makefile @@ -30,7 +30,7 @@ clean-test: rm -fr htmlcov/ ruff: - ruff . $(args) + ruff check . $(args) format: ruff format . --check diff --git a/mizani/_colors/_palettes/_palette.py b/mizani/_colors/_palettes/_palette.py index 6fa0762..1016c9f 100644 --- a/mizani/_colors/_palettes/_palette.py +++ b/mizani/_colors/_palettes/_palette.py @@ -9,6 +9,7 @@ All swatches of a palette have different lengths, are listed shortest to longest and each swatch is longer than the previous by one color. """ + from __future__ import annotations import typing diff --git a/mizani/_colors/hsluv.py b/mizani/_colors/hsluv.py index a9cc841..450083e 100644 --- a/mizani/_colors/hsluv.py +++ b/mizani/_colors/hsluv.py @@ -1,4 +1,5 @@ -""" This module is generated by transpiling Haxe into Python and cleaning +""" +This module is generated by transpiling Haxe into Python and cleaning the resulting code by hand, e.g. removing unused Haxe classes. To try it yourself, clone https://github.com/hsluv/hsluv and run: diff --git a/mizani/_core/dates.py b/mizani/_core/dates.py index 8dbf7ab..e4cd2db 100644 --- a/mizani/_core/dates.py +++ b/mizani/_core/dates.py @@ -97,13 +97,11 @@ def get_tzinfo(tz: Optional[str | TzInfo] = None) -> TzInfo | None: @overload -def datetime_to_num(x: SeqDatetime) -> NDArrayFloat: - ... +def datetime_to_num(x: SeqDatetime) -> NDArrayFloat: ... @overload -def datetime_to_num(x: Datetime) -> float: - ... +def datetime_to_num(x: Datetime) -> float: ... def datetime_to_num(x: SeqDatetime | Datetime) -> NDArrayFloat | float: diff --git a/mizani/bounds.py b/mizani/bounds.py index 9117a92..50546fe 100644 --- a/mizani/bounds.py +++ b/mizani/bounds.py @@ -18,6 +18,7 @@ e.g. :math:`[0.1, 1]`. Similarly you can restrict the upper bound -- using these functions. """ + from __future__ import annotations import datetime @@ -284,15 +285,13 @@ def censor( x: NDArrayFloat | Sequence[float], range: TupleFloat2 = (0, 1), only_finite: bool = True, -) -> NDArrayFloat: - ... +) -> NDArrayFloat: ... @overload def censor( x: FloatSeries, range: TupleFloat2 = (0, 1), only_finite: bool = True -) -> FloatSeries: - ... +) -> FloatSeries: ... def censor( diff --git a/mizani/breaks.py b/mizani/breaks.py index ae0cddd..dbc6b34 100644 --- a/mizani/breaks.py +++ b/mizani/breaks.py @@ -10,6 +10,7 @@ breaks make interpretation straight forward. These functions provide ways to calculate good(hopefully) breaks. """ + from __future__ import annotations import sys diff --git a/mizani/labels.py b/mizani/labels.py index 2780fe3..98c0469 100644 --- a/mizani/labels.py +++ b/mizani/labels.py @@ -9,6 +9,7 @@ representations of those values. Manipulating the string representation of a value helps improve readability of the guide. """ + from __future__ import annotations import re diff --git a/mizani/palettes.py b/mizani/palettes.py index c91b0af..c12f1a6 100644 --- a/mizani/palettes.py +++ b/mizani/palettes.py @@ -13,6 +13,7 @@ enforce such restrictions. This is the reason for the ``*_pal`` functions that create and return the actual palette functions. """ + from __future__ import annotations import colorsys diff --git a/mizani/scale.py b/mizani/scale.py index 774a3e2..f13035c 100644 --- a/mizani/scale.py +++ b/mizani/scale.py @@ -27,6 +27,7 @@ The **apply** methods are simple examples of how to put it all together. """ + from __future__ import annotations from typing import TYPE_CHECKING, cast diff --git a/mizani/transforms.py b/mizani/transforms.py index d81d8bd..b99a3fc 100644 --- a/mizani/transforms.py +++ b/mizani/transforms.py @@ -18,6 +18,7 @@ plot. The :class:`trans` is aimed at being useful for *scale* and *coordinate* transformations. """ + from __future__ import annotations import sys diff --git a/mizani/typing.py b/mizani/typing.py index d47356b..d9d308b 100644 --- a/mizani/typing.py +++ b/mizani/typing.py @@ -186,14 +186,11 @@ class PComparison(Protocol): Objects that can be compaired """ - def __eq__(self, other, /) -> bool: - ... + def __eq__(self, other, /) -> bool: ... - def __lt__(self, other, /) -> bool: - ... + def __lt__(self, other, /) -> bool: ... - def __gt__(self, other, /) -> bool: - ... + def __gt__(self, other, /) -> bool: ... DomainType: TypeAlias = TupleT2[PComparison] diff --git a/mizani/utils.py b/mizani/utils.py index d7bd364..34d9bd6 100644 --- a/mizani/utils.py +++ b/mizani/utils.py @@ -80,15 +80,13 @@ @overload def round_any( x: FloatArrayLike, accuracy: float, f: NumericUFunction = np.round -) -> NDArrayFloat: - ... +) -> NDArrayFloat: ... @overload def round_any( x: float, accuracy: float, f: NumericUFunction = np.round -) -> float: - ... +) -> float: ... def round_any( diff --git a/tools/gha_check_semver.py b/tools/gha_check_semver.py index 8b1205d..1b60099 100644 --- a/tools/gha_check_semver.py +++ b/tools/gha_check_semver.py @@ -20,6 +20,7 @@ The output of this script should tell you whether to publish a release and to what index. """ + import os import re from pathlib import Path