Skip to content

Commit

Permalink
style: Update ruff config (#209)
Browse files Browse the repository at this point in the history
  • Loading branch information
baggiponte committed Apr 28, 2024
1 parent a3f893e commit c28c47c
Show file tree
Hide file tree
Showing 51 changed files with 113 additions and 9 deletions.
2 changes: 2 additions & 0 deletions functime/_utils.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import logging
from typing import Any, Callable

Expand Down
2 changes: 2 additions & 0 deletions functime/backtesting.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

from typing import Any, Callable, Mapping, Optional, Tuple

import numpy as np
Expand Down
2 changes: 2 additions & 0 deletions functime/base/forecaster.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import logging
import sys
from dataclasses import dataclass
Expand Down
2 changes: 2 additions & 0 deletions functime/base/metric.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

from functools import wraps
from typing import Callable, Union

Expand Down
2 changes: 2 additions & 0 deletions functime/base/model.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

from dataclasses import dataclass
from typing import Any, Mapping, Protocol, Union

Expand Down
2 changes: 2 additions & 0 deletions functime/base/transformer.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import inspect
import sys
from functools import cached_property, wraps
Expand Down
2 changes: 2 additions & 0 deletions functime/conformal.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

from typing import List, Optional

import polars as pl
Expand Down
2 changes: 2 additions & 0 deletions functime/conversion.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import numpy as np
import polars as pl

Expand Down
2 changes: 2 additions & 0 deletions functime/cross_validation.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

from typing import Mapping, Optional, Tuple, Union

import numpy as np
Expand Down
2 changes: 2 additions & 0 deletions functime/evaluation.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

from functools import partial
from typing import List, Literal, Optional

Expand Down
2 changes: 2 additions & 0 deletions functime/feature_extractors.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import logging
import math
from typing import List, Mapping, Optional, Sequence, Union
Expand Down
2 changes: 2 additions & 0 deletions functime/forecasting/_ar.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import logging
from typing import Any, Callable, List, Literal, Mapping, Optional, Union

Expand Down
2 changes: 2 additions & 0 deletions functime/forecasting/_evaluate.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import logging
from functools import partial
from typing import Any, Callable, List, Mapping, Optional, Tuple, Union
Expand Down
2 changes: 2 additions & 0 deletions functime/forecasting/_reduction.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

from typing import Optional

import polars as pl
Expand Down
6 changes: 3 additions & 3 deletions functime/forecasting/_regressors.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""
Fit-predict regressors with special needs.
"""
"""Fit-predict regressors with special needs."""

from __future__ import annotations

from typing import Callable, Literal, Optional, Union

Expand Down
2 changes: 2 additions & 0 deletions functime/forecasting/automl.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

from abc import abstractmethod
from functools import partial
from typing import Any, Literal, Mapping, Optional, Union
Expand Down
2 changes: 2 additions & 0 deletions functime/forecasting/catboost.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

from typing import Callable, Optional, Union

import numpy as np
Expand Down
2 changes: 2 additions & 0 deletions functime/forecasting/censored.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

from typing import Callable, Optional, Union

import numpy as np
Expand Down
2 changes: 2 additions & 0 deletions functime/forecasting/elite.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

from functools import partial
from typing import Any, Literal, Mapping, Optional, Union

Expand Down
2 changes: 2 additions & 0 deletions functime/forecasting/knn.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

from typing import Optional

import polars as pl
Expand Down
2 changes: 2 additions & 0 deletions functime/forecasting/lance.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

from typing import Literal, Optional

import lance
Expand Down
2 changes: 2 additions & 0 deletions functime/forecasting/lightgbm.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

from typing import Callable, Optional, Union

import numpy as np
Expand Down
2 changes: 2 additions & 0 deletions functime/forecasting/linear.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

from typing import Optional

import polars as pl
Expand Down
2 changes: 2 additions & 0 deletions functime/forecasting/naive.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

from typing import Optional, Union

import polars as pl
Expand Down
2 changes: 2 additions & 0 deletions functime/forecasting/snaive.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

from typing import Optional, Union

import polars as pl
Expand Down
2 changes: 2 additions & 0 deletions functime/forecasting/xgboost.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

from typing import Callable, Optional, Union

import numpy as np
Expand Down
2 changes: 2 additions & 0 deletions functime/llm/api.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

from typing import List, Optional

import polars as pl
Expand Down
2 changes: 2 additions & 0 deletions functime/llm/common.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import logging
import os
from typing import Dict, List, Literal, Mapping
Expand Down
2 changes: 2 additions & 0 deletions functime/llm/formatting.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

from typing import Literal, Mapping, Tuple, Union

import polars as pl
Expand Down
2 changes: 2 additions & 0 deletions functime/metrics/multi_objective.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"""Module with functions to compute, compare, and optimize multi-objective forecasts."""

from __future__ import annotations

from dataclasses import dataclass
from functools import partial, reduce
from typing import Literal, Optional
Expand Down
2 changes: 2 additions & 0 deletions functime/metrics/point.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import numpy as np
import polars as pl

Expand Down
2 changes: 2 additions & 0 deletions functime/offsets.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

from typing import List, Tuple, Union

OFFSET_ALIASES = {"s", "m", "h", "d", "w", "mo", "y", "i"}
Expand Down
6 changes: 5 additions & 1 deletion functime/plotting.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
from typing import Any, Dict, Optional, Tuple, Union
from __future__ import annotations

from typing import TYPE_CHECKING

import plotly.express as px
import plotly.graph_objects as go
Expand All @@ -8,6 +10,8 @@
from functime.base.metric import METRIC_TYPE
from functime.metrics import smape

if TYPE_CHECKING:
from typing import Any, Dict, Optional, Tuple, Union
COLOR_PALETTE = {"actual": "#B7B7B7", "forecast": "#1b57f1", "backtest": "#A76EF4"}
DEFAULT_LAST_N = 64

Expand Down
2 changes: 2 additions & 0 deletions functime/preprocessing.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

from typing import Any, List, Literal, Mapping, Optional, Union

import cloudpickle
Expand Down
2 changes: 2 additions & 0 deletions functime/ranges.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

from typing import Optional

import polars as pl
Expand Down
2 changes: 2 additions & 0 deletions functime/seasonality/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

from functime.seasonality.calendar import (
add_calendar_effects,
add_holiday_effects,
Expand Down
2 changes: 2 additions & 0 deletions functime/seasonality/calendar.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

from typing import List, Literal, Optional

import polars as pl
Expand Down
2 changes: 2 additions & 0 deletions functime/seasonality/fourier.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import numpy as np
import polars as pl

Expand Down
2 changes: 2 additions & 0 deletions functime/type_alias.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import sys
from typing import Literal

Expand Down
10 changes: 9 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ select = [
"I", # isort
"B", # flake8-bugbear
"UP", # pyupgrade
"I", # isort
"YTT", # flake8-2020
]
ignore = [
"E501", # line too long, handled by black
Expand All @@ -127,6 +127,14 @@ ignore = [
"F821", # Undefined name
]

[tool.ruff.lint.per-file-ignores]
"__init__.py" = ["I002"]
"docs/**" = ["I002"]
"**.ipynb" = ["E402"]

[tool.ruff.lint.isort]
required-imports = ["from __future__ import annotations"]

[tool.ruff.lint.pyupgrade]
# Preserve types, even if a file imports `from __future__ import annotations`.
keep-runtime-typing = true
Expand Down
2 changes: 2 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import logging
import os
from functools import partial
Expand Down
2 changes: 2 additions & 0 deletions tests/test_benchmarks.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import logging
from functools import partial
from typing import List, Mapping
Expand Down
2 changes: 2 additions & 0 deletions tests/test_calendar.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

from datetime import datetime

import polars as pl
Expand Down
2 changes: 2 additions & 0 deletions tests/test_changepoint_detection.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import numpy as np
import polars as pl

Expand Down
2 changes: 2 additions & 0 deletions tests/test_cross_validation.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

from contextlib import nullcontext as does_not_raise

import polars as pl
Expand Down
2 changes: 2 additions & 0 deletions tests/test_evaluation.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

from functools import partial

import polars as pl
Expand Down
6 changes: 2 additions & 4 deletions tests/test_forecasting.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import logging

import cloudpickle
Expand All @@ -8,15 +10,11 @@
from functime.forecasting import ( # ann,
auto_elastic_net,
auto_lightgbm,
catboost,
censored_model,
elastic_net,
elite,
flaml_lightgbm,
lightgbm,
linear_model,
naive,
xgboost,
zero_inflated_model,
)
from functime.metrics import rmsse, smape, smape_original
Expand Down
2 changes: 2 additions & 0 deletions tests/test_fourier.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

from datetime import date

import polars as pl
Expand Down
2 changes: 2 additions & 0 deletions tests/test_plotting.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import polars as pl
import pytest

Expand Down
2 changes: 2 additions & 0 deletions tests/test_preprocessing.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

from typing import List, Tuple

import numpy as np
Expand Down
2 changes: 2 additions & 0 deletions tests/test_tsfresh.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import math

import numpy as np
Expand Down

0 comments on commit c28c47c

Please sign in to comment.