Skip to content

Commit

Permalink
Bump ruff to 0.5, normalize conda recipes, clean docs to only use mak…
Browse files Browse the repository at this point in the history
…efile commands

Add ruff isort to rules
apply isort
update settings

Signed-off-by: Tim Paine <3105306+timkpaine@users.noreply.github.com>
  • Loading branch information
timkpaine committed Sep 13, 2024
1 parent 1ce6f25 commit 001e7e7
Show file tree
Hide file tree
Showing 59 changed files with 166 additions and 126 deletions.
3 changes: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ install: ## install library
.PHONY: lint-py lint-cpp lint lints fix-py fix-cpp fix format check checks

lint-py:
python -m isort --check csp/ examples/ setup.py
python -m ruff check csp/ examples/ setup.py
python -m ruff format --check csp/ examples/ setup.py

Expand All @@ -57,7 +56,7 @@ lint: lint-py lint-docs ## run lints
lints: lint

fix-py:
python -m isort csp/ examples/ setup.py
python -m ruff check --fix csp/ examples/ setup.py
python -m ruff format csp/ examples/ setup.py

fix-cpp:
Expand Down
3 changes: 2 additions & 1 deletion conda/dev-environment-unix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ dependencies:
- libboost-headers>=1.80.0
- librdkafka
- lz4-c
- make
- mamba
- mdformat>=0.7.17,<0.8
- ninja
Expand All @@ -43,7 +44,7 @@ dependencies:
- rapidjson
- requests
- ruamel.yaml
- ruff>=0.3,<0.4
- ruff>=0.5,<0.6
- scikit-build
- setuptools>=69,<74
- sqlalchemy
Expand Down
7 changes: 6 additions & 1 deletion conda/dev-environment-win.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ channels:
- conda-forge
- nodefaults
dependencies:
# - bison # not available on windows
- brotli
- bump2version>=1
- cmake
Expand All @@ -11,6 +12,7 @@ dependencies:
- cyrus-sasl
- deprecated
- exprtk
# - flex # not available on windows
- graphviz
- gtest
- httpx>=0.20,<1
Expand Down Expand Up @@ -42,11 +44,14 @@ dependencies:
- rapidjson
- requests
- ruamel.yaml
- ruff>=0.3,<0.4
- ruff>=0.5,<0.6
- scikit-build
- setuptools>=69,<74
- sqlalchemy
# - tar # not available on windows
- threadpoolctl
- tornado
- twine
# - unzip # not available on windows
- wheel
# - zip # not available on windows
6 changes: 5 additions & 1 deletion csp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@
from csp.impl.mem_cache import csp_memoized, memoize
from csp.impl.struct import Struct
from csp.impl.types.common_definitions import OutputBasket, Outputs, OutputTypeError, PushMode
from csp.impl.types.tstype import AttachType as attach, DynamicBasket, SnapKeyType as snapkey, SnapType as snap, ts
from csp.impl.types.tstype import AttachType as attach
from csp.impl.types.tstype import DynamicBasket
from csp.impl.types.tstype import SnapKeyType as snapkey
from csp.impl.types.tstype import SnapType as snap
from csp.impl.types.tstype import ts
from csp.impl.wiring import (
CspParseError,
DelayedEdge,
Expand Down
4 changes: 3 additions & 1 deletion csp/adapters/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@
except ImportError:
from backports import zoneinfo

from importlib.metadata import PackageNotFoundError
from importlib.metadata import version as get_package_version

import pytz
from importlib.metadata import PackageNotFoundError, version as get_package_version
from packaging import version

from csp import PushMode, ts
Expand Down
8 changes: 5 additions & 3 deletions csp/adapters/output_adapters/parquet.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import numpy
import os
from importlib.metadata import PackageNotFoundError, version as get_package_version
from packaging import version
from importlib.metadata import PackageNotFoundError
from importlib.metadata import version as get_package_version
from typing import Callable, Dict, Optional, TypeVar

import numpy
from packaging import version

import csp
from csp.impl.struct import Struct
from csp.impl.types.container_type_normalizer import ContainerTypeNormalizer
Expand Down
3 changes: 2 additions & 1 deletion csp/adapters/output_adapters/parquet_utility_nodes.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import numpy
import typing

import numpy

import csp

T = typing.TypeVar("T")
Expand Down
6 changes: 4 additions & 2 deletions csp/adapters/parquet.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import datetime
import io
from importlib.metadata import PackageNotFoundError
from importlib.metadata import version as get_package_version
from typing import TypeVar

import numpy
import pyarrow
import pyarrow.parquet
from importlib.metadata import PackageNotFoundError, version as get_package_version
from packaging import version
from typing import TypeVar

import csp
from csp.adapters.output_adapters.parquet import ParquetOutputConfig, ParquetWriter, resolve_array_shape_column_name
Expand Down
5 changes: 4 additions & 1 deletion csp/adapters/perspective.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@


try:
from perspective import PerspectiveManager, Table as Table_, View as View_, __version__, set_threadpool_size
from perspective import PerspectiveManager
from perspective import Table as Table_
from perspective import View as View_
from perspective import __version__, set_threadpool_size

MAJOR, MINOR, PATCH = map(int, __version__.split("."))
if (MAJOR, MINOR, PATCH) < (0, 6, 2):
Expand Down
5 changes: 3 additions & 2 deletions csp/baselib.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
import contextlib
import logging
import math
import numpy as np
import pytz
import queue
import threading
from datetime import datetime, timedelta
from typing import Callable, Dict, List, Optional, TypeVar, Union

import numpy as np
import pytz

import csp
from csp.impl.__cspimpl import _cspimpl
from csp.impl.constants import UNSET
Expand Down
5 changes: 3 additions & 2 deletions csp/curve.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import copy
import numpy as np
import pytz
from datetime import timedelta
from typing import Union

import numpy as np
import pytz

from csp import null_ts
from csp.impl.__cspimpl import _cspimpl
from csp.impl.pulladapter import PullInputAdapter
Expand Down
3 changes: 2 additions & 1 deletion csp/impl/pandas.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import pandas
from datetime import timedelta

import pandas

import csp
from csp import ts

Expand Down
5 changes: 3 additions & 2 deletions csp/impl/pandas_accessor.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
from datetime import datetime, timedelta
from typing import Dict, List, TypeVar, Union

import numpy as np
import pandas as pd
from datetime import datetime, timedelta
from pandas.api.extensions import register_dataframe_accessor, register_series_accessor
from pandas.core.arrays import ExtensionArray
from typing import Dict, List, TypeVar, Union

import csp
from csp import ts
Expand Down
9 changes: 5 additions & 4 deletions csp/impl/pandas_ext_type.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import copy
import functools
import numpy as np
import operator
import pandas as pd
import re
from pydoc import locate
from typing import Any, List, Type, TypeVar, Union, cast

import numpy as np
import pandas as pd
from pandas.api.types import is_integer, is_list_like
from pandas.core.arrays import ExtensionArray, ExtensionScalarOpsMixin, IntervalArray
from pandas.core.dtypes.dtypes import PandasExtensionDtype, register_extension_dtype
from pandas.core.indexers import check_array_indexer
from pydoc import locate
from typing import Any, List, Type, TypeVar, Union, cast

import csp
from csp.impl.types.tstype import TsType, isTsType, ts
Expand Down
5 changes: 3 additions & 2 deletions csp/impl/pandas_perspective.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from datetime import datetime, timedelta
from typing import Optional

import pandas as pd
import pytz
from datetime import datetime, timedelta
from pandas.compat import set_function_name
from typing import Optional

import csp
import csp.impl.pandas_accessor # To ensure that the csp accessors are registered
Expand Down
3 changes: 2 additions & 1 deletion csp/impl/struct.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import io
import ruamel.yaml
import typing
from copy import deepcopy

import ruamel.yaml
from deprecated import deprecated

import csp
Expand Down
3 changes: 2 additions & 1 deletion csp/impl/types/container_type_normalizer.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import numpy
import typing

import numpy

import csp.typing
from csp.impl.types.typing_utils import CspTypingUtils, FastList

Expand Down
3 changes: 2 additions & 1 deletion csp/impl/types/instantiation_type_resolver.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import collections
import inspect
import numpy
import typing
from abc import ABCMeta, abstractmethod

import numpy

import csp.typing
from csp.impl.types import tstype
from csp.impl.types.common_definitions import ArgKind, BasketKind, InputDef, OutputDef
Expand Down
3 changes: 2 additions & 1 deletion csp/impl/types/typing_utils.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# utils for dealing with typing types
import numpy
import typing

import numpy

import csp.typing

T = typing.TypeVar("T")
Expand Down
1 change: 1 addition & 0 deletions csp/impl/wiring/numba_utils/datetime_extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"""

import datetime

import numba

from csp.impl.wiring.numba_utils.csp_cpp_numba_interface import C as csp_c
Expand Down
3 changes: 2 additions & 1 deletion csp/impl/wiring/numba_utils/numba_type_resolver.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import datetime
import numba
import typing

import numba

from csp.impl.types.typing_utils import CspTypingUtils
from csp.impl.wiring.numba_utils import datetime_extension

Expand Down
3 changes: 2 additions & 1 deletion csp/impl/wiring/runtime.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import pytz
import threading
import time
from collections import deque
from datetime import datetime, timedelta

import pytz

from csp.impl.__cspimpl import _cspimpl
from csp.impl.error_handling import ExceptionContext
from csp.impl.wiring.adapters import _graph_return_adapter
Expand Down
3 changes: 2 additions & 1 deletion csp/math.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import math
import numpy as np
from functools import lru_cache
from typing import List, TypeVar, get_origin

import numpy as np

import csp
from csp.impl.types.tstype import ts
from csp.impl.wiring import node
Expand Down
3 changes: 2 additions & 1 deletion csp/profiler.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import base64
import gc
import numpy as np
import pickle
import sys
import threading
Expand All @@ -11,6 +10,8 @@
from io import BytesIO
from typing import Dict, List

import numpy as np

import csp
from csp.impl.genericpushadapter import GenericPushAdapter
from csp.impl.struct import Struct
Expand Down
3 changes: 2 additions & 1 deletion csp/random.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import numpy as np
from datetime import timedelta
from typing import TypeVar

import numpy as np

import csp
from csp import ts
from csp.stats import numpy_to_list
Expand Down
5 changes: 3 additions & 2 deletions csp/stats.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import numpy as np
from datetime import datetime, timedelta
from typing import Any, List, Optional, TypeVar, Union

import numpy as np

import csp
from csp import ts
from csp.lib import _cspnpstatsimpl, _cspstatsimpl
Expand Down Expand Up @@ -232,7 +233,7 @@ def _setup(x, interval, min_window, trigger, sampler, reset, weights=None, ignor
if min_window is None:
min_window = interval
else:
if type(min_window) != type(interval):
if type(min_window) is not type(interval):
raise TypeError("Interval and min_window must be of the same type")

if sampler is None:
Expand Down
5 changes: 3 additions & 2 deletions csp/tests/adapters/test_db.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import os
import pytz
import sqlalchemy as db
import unittest
from datetime import date, datetime, time

import pytz
import sqlalchemy as db

import csp
from csp.adapters.db import _SQLALCHEMY_2, DateTimeAccessor, DBReader, EngineStartTimeAccessor, TimestampAccessor

Expand Down
3 changes: 2 additions & 1 deletion csp/tests/adapters/test_kafka.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import os
import pytest
from datetime import datetime, timedelta

import pytest

import csp
from csp import ts
from csp.adapters.kafka import (
Expand Down
3 changes: 2 additions & 1 deletion csp/tests/adapters/test_numpy.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import numpy as np
import unittest
from datetime import datetime, timedelta
from typing import List

import numpy as np

import csp


Expand Down
Loading

0 comments on commit 001e7e7

Please sign in to comment.