From 683751b941bd477218f8892d2ed96bef67304bfe Mon Sep 17 00:00:00 2001 From: Hassan Kibirige Date: Mon, 4 Mar 2024 21:58:42 +0300 Subject: [PATCH] FMT: Fix new format fails --- .pre-commit-config.yaml | 2 +- Makefile | 2 +- doc/_config.py | 1 + plotnine/_mpl/_plot_side_space.py | 1 + plotnine/_mpl/_plotnine_tight_layout.py | 1 + plotnine/_utils/__init__.py | 10 ++++------ plotnine/coords/__init__.py | 1 + plotnine/data/__init__.py | 1 + plotnine/facets/__init__.py | 1 + plotnine/iapi.py | 1 + plotnine/layer.py | 12 ++++-------- plotnine/mapping/__init__.py | 1 + plotnine/mapping/_env.py | 6 ++---- plotnine/positions/__init__.py | 1 + plotnine/scales/__init__.py | 1 + plotnine/stats/__init__.py | 1 + plotnine/stats/density.py | 1 + plotnine/themes/elements/element_base.py | 1 + plotnine/themes/elements/element_rect.py | 1 + plotnine/themes/elements/element_text.py | 1 + plotnine/themes/elements/margin.py | 1 + plotnine/themes/seaborn_rcmod.py | 1 - plotnine/themes/theme.py | 6 ++---- plotnine/themes/themeable.py | 1 + tools/gha_check_semver.py | 1 + 25 files changed, 32 insertions(+), 25 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 741be32d1..91496edb7 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.2.1 + rev: v0.3.0 hooks: # Run the linter. - id: ruff diff --git a/Makefile b/Makefile index 5e39cb3ea..45625d323 100644 --- a/Makefile +++ b/Makefile @@ -32,7 +32,7 @@ clean-test: rm -fr tests/result_images/* ruff: - ruff . $(args) + ruff check . $(args) format: ruff format . --check diff --git a/doc/_config.py b/doc/_config.py index 08407b8f8..d8f9d30cd 100644 --- a/doc/_config.py +++ b/doc/_config.py @@ -1,6 +1,7 @@ """ This script is run by the Makefile before quarto_build """ + import re from importlib.metadata import version as get_version from pathlib import Path diff --git a/plotnine/_mpl/_plot_side_space.py b/plotnine/_mpl/_plot_side_space.py index 5d88f55bb..1f1484547 100644 --- a/plotnine/_mpl/_plot_side_space.py +++ b/plotnine/_mpl/_plot_side_space.py @@ -8,6 +8,7 @@ Axes position. This may fail if `Axes.adjustable` is `datalim` as well as such cases as when left or right margin are affected by xlabel. """ + from __future__ import annotations from abc import ABC diff --git a/plotnine/_mpl/_plotnine_tight_layout.py b/plotnine/_mpl/_plotnine_tight_layout.py index cbd44d989..7f6e20d4b 100644 --- a/plotnine/_mpl/_plotnine_tight_layout.py +++ b/plotnine/_mpl/_plotnine_tight_layout.py @@ -8,6 +8,7 @@ Axes position. This may fail if `Axes.adjustable` is `datalim` as well as such cases as when left or right margin are affected by xlabel. """ + from __future__ import annotations import typing diff --git a/plotnine/_utils/__init__.py b/plotnine/_utils/__init__.py index 1dccd183f..f07501799 100644 --- a/plotnine/_utils/__init__.py +++ b/plotnine/_utils/__init__.py @@ -1,6 +1,7 @@ """ Little functions used all over the codebase """ + from __future__ import annotations import inspect @@ -527,22 +528,19 @@ def remove_missing( @overload -def to_rgba(colors: ColorType, alpha: float) -> ColorType: - ... +def to_rgba(colors: ColorType, alpha: float) -> ColorType: ... @overload def to_rgba( colors: Sequence[ColorType], alpha: float -) -> Sequence[ColorType] | ColorType: - ... +) -> Sequence[ColorType] | ColorType: ... @overload def to_rgba( colors: AnySeries, alpha: AnySeries -) -> Sequence[ColorType] | ColorType: - ... +) -> Sequence[ColorType] | ColorType: ... def to_rgba( diff --git a/plotnine/coords/__init__.py b/plotnine/coords/__init__.py index a89468aca..d49f9f8ff 100644 --- a/plotnine/coords/__init__.py +++ b/plotnine/coords/__init__.py @@ -1,6 +1,7 @@ """ Coordinates """ + from .coord_cartesian import coord_cartesian from .coord_fixed import coord_equal, coord_fixed from .coord_flip import coord_flip diff --git a/plotnine/data/__init__.py b/plotnine/data/__init__.py index edd950772..7e391535e 100644 --- a/plotnine/data/__init__.py +++ b/plotnine/data/__init__.py @@ -1,6 +1,7 @@ """ Plotnine Data """ + from pathlib import Path import pandas as pd diff --git a/plotnine/facets/__init__.py b/plotnine/facets/__init__.py index 9be638ce4..f468030a5 100644 --- a/plotnine/facets/__init__.py +++ b/plotnine/facets/__init__.py @@ -1,6 +1,7 @@ """ Facets """ + from .facet_grid import facet_grid from .facet_null import facet_null from .facet_wrap import facet_wrap diff --git a/plotnine/iapi.py b/plotnine/iapi.py index 617ce7531..f1471d94b 100644 --- a/plotnine/iapi.py +++ b/plotnine/iapi.py @@ -4,6 +4,7 @@ Specifications for containers that will hold different kinds of objects with data created when the plot is being built. """ + from __future__ import annotations import itertools diff --git a/plotnine/layer.py b/plotnine/layer.py index 9d15e6465..79ad1358d 100644 --- a/plotnine/layer.py +++ b/plotnine/layer.py @@ -407,12 +407,10 @@ class Layers(List[layer]): """ @overload - def __radd__(self, other: Iterable[layer]) -> Layers: - ... + def __radd__(self, other: Iterable[layer]) -> Layers: ... @overload - def __radd__(self, other: ggplot) -> ggplot: - ... + def __radd__(self, other: ggplot) -> ggplot: ... def __radd__(self, other: Iterable[layer] | ggplot) -> Layers | ggplot: """ @@ -431,12 +429,10 @@ def __radd__(self, other: Iterable[layer] | ggplot) -> Layers | ggplot: return other @overload - def __getitem__(self, key: SupportsIndex) -> layer: - ... + def __getitem__(self, key: SupportsIndex) -> layer: ... @overload - def __getitem__(self, key: slice) -> Layers: - ... + def __getitem__(self, key: slice) -> Layers: ... def __getitem__(self, key: SupportsIndex | slice) -> layer | Layers: result = super().__getitem__(key) diff --git a/plotnine/mapping/__init__.py b/plotnine/mapping/__init__.py index 29673b190..50e8f98ad 100644 --- a/plotnine/mapping/__init__.py +++ b/plotnine/mapping/__init__.py @@ -1,6 +1,7 @@ """ Aesthetic Mappings """ + from ._env import Environment # noqa: F401 from .aes import aes from .evaluation import after_scale, after_stat, stage diff --git a/plotnine/mapping/_env.py b/plotnine/mapping/_env.py index 873ae67a6..6cf560399 100644 --- a/plotnine/mapping/_env.py +++ b/plotnine/mapping/_env.py @@ -15,11 +15,9 @@ class SupportsGetItem(Protocol): Supports __getitem__ """ - def __getitem__(self, key: str, /) -> Any: - ... + def __getitem__(self, key: str, /) -> Any: ... - def __iter__(self) -> Iterator[Hashable]: - ... + def __iter__(self) -> Iterator[Hashable]: ... __all__ = ("Environment",) diff --git a/plotnine/positions/__init__.py b/plotnine/positions/__init__.py index c73bd0105..0534969c8 100644 --- a/plotnine/positions/__init__.py +++ b/plotnine/positions/__init__.py @@ -1,6 +1,7 @@ """ Position Adjustments """ + from .position_dodge import position_dodge from .position_dodge2 import position_dodge2 from .position_fill import position_fill diff --git a/plotnine/scales/__init__.py b/plotnine/scales/__init__.py index bcd376d12..480b761ee 100644 --- a/plotnine/scales/__init__.py +++ b/plotnine/scales/__init__.py @@ -1,6 +1,7 @@ """ Scales """ + # limits from .limits import expand_limits, lims, xlim, ylim diff --git a/plotnine/stats/__init__.py b/plotnine/stats/__init__.py index c9287f0dc..bd724fc5b 100644 --- a/plotnine/stats/__init__.py +++ b/plotnine/stats/__init__.py @@ -1,6 +1,7 @@ """ Statistics """ + from .stat_bin import stat_bin from .stat_bin_2d import stat_bin2d, stat_bin_2d from .stat_bindot import stat_bindot diff --git a/plotnine/stats/density.py b/plotnine/stats/density.py index b2383d765..0b407f1f5 100644 --- a/plotnine/stats/density.py +++ b/plotnine/stats/density.py @@ -7,6 +7,7 @@ Credit: Jake VanderPlas for the original kde_* functions https://jakevdp.github.io/blog/2013/12/01/kernel-density-estimation/ """ + from __future__ import annotations import typing diff --git a/plotnine/themes/elements/element_base.py b/plotnine/themes/elements/element_base.py index 0ed961e01..869a9cd6d 100644 --- a/plotnine/themes/elements/element_base.py +++ b/plotnine/themes/elements/element_base.py @@ -1,6 +1,7 @@ """ Theme elements used to decorate the graph. """ + from __future__ import annotations from typing import TYPE_CHECKING diff --git a/plotnine/themes/elements/element_rect.py b/plotnine/themes/elements/element_rect.py index 98fa1a21f..2b9ebd3f2 100644 --- a/plotnine/themes/elements/element_rect.py +++ b/plotnine/themes/elements/element_rect.py @@ -1,6 +1,7 @@ """ Theme elements used to decorate the graph. """ + from __future__ import annotations from typing import TYPE_CHECKING diff --git a/plotnine/themes/elements/element_text.py b/plotnine/themes/elements/element_text.py index 1ec7cf01a..2a09b0533 100644 --- a/plotnine/themes/elements/element_text.py +++ b/plotnine/themes/elements/element_text.py @@ -1,6 +1,7 @@ """ Theme elements used to decorate the graph. """ + from __future__ import annotations from contextlib import suppress diff --git a/plotnine/themes/elements/margin.py b/plotnine/themes/elements/margin.py index fe1d05779..a8e3288f3 100644 --- a/plotnine/themes/elements/margin.py +++ b/plotnine/themes/elements/margin.py @@ -1,6 +1,7 @@ """ Theme elements used to decorate the graph. """ + from __future__ import annotations from dataclasses import dataclass diff --git a/plotnine/themes/seaborn_rcmod.py b/plotnine/themes/seaborn_rcmod.py index 6791f2b9e..e6f41d4ef 100644 --- a/plotnine/themes/seaborn_rcmod.py +++ b/plotnine/themes/seaborn_rcmod.py @@ -2,7 +2,6 @@ """Functions that alter the matplotlib rc dictionary on the fly.""" - import functools import matplotlib as _mpl diff --git a/plotnine/themes/theme.py b/plotnine/themes/theme.py index c683c4cc2..4e2e33ae9 100644 --- a/plotnine/themes/theme.py +++ b/plotnine/themes/theme.py @@ -386,12 +386,10 @@ def __add__(self, other: theme) -> theme: return self.add_theme(other) @overload - def __radd__(self, other: theme) -> theme: - ... + def __radd__(self, other: theme) -> theme: ... @overload - def __radd__(self, other: ggplot) -> ggplot: - ... + def __radd__(self, other: ggplot) -> ggplot: ... def __radd__(self, other: theme | ggplot) -> theme | ggplot: """ diff --git a/plotnine/themes/themeable.py b/plotnine/themes/themeable.py index 7f6def787..a832ee636 100644 --- a/plotnine/themes/themeable.py +++ b/plotnine/themes/themeable.py @@ -8,6 +8,7 @@ only to the axis.title. In matplotlib terms this means that a theme that covers text also has to cover axis.title. """ + from __future__ import annotations from contextlib import suppress diff --git a/tools/gha_check_semver.py b/tools/gha_check_semver.py index 8b1205d7f..1b60099d1 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