Skip to content

Commit

Permalink
Bump ruff to 0.7, 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 Nov 5, 2024
1 parent 2c13739 commit e3b6125
Show file tree
Hide file tree
Showing 67 changed files with 331 additions and 253 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
4 changes: 2 additions & 2 deletions conda/dev-environment-unix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ dependencies:
- graphviz
- gtest
- httpx>=0.20,<1
- isort>=5,<6
- libarrow=16
- libboost>=1.80.0
- libboost-headers>=1.80.0
- libprotobuf<5
- librdkafka
- lz4-c
- make
- mamba
- mdformat>=0.7.17,<0.8
- ninja
Expand All @@ -45,7 +45,7 @@ dependencies:
- rapidjson
- requests
- ruamel.yaml
- ruff>=0.3,<0.4
- ruff>=0.7,<0.8
- scikit-build
- setuptools>=69,<74
- sqlalchemy
Expand Down
8 changes: 6 additions & 2 deletions 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,10 +12,10 @@ dependencies:
- cyrus-sasl
- deprecated
- exprtk
# - flex # not available on windows
- graphviz
- gtest
- httpx>=0.20,<1
- isort>=5,<6
- libarrow=16
- libboost>=1.80.0
- libboost-headers>=1.80.0
Expand Down Expand Up @@ -44,12 +45,15 @@ dependencies:
- rapidjson
- requests
- ruamel.yaml
- ruff>=0.3,<0.4
- ruff>=0.7,<0.8
- scikit-build
- setuptools>=69,<74
- sqlalchemy
# - tar # not available on windows
- threadpoolctl
- tornado
- twine
- typing-extensions
# - unzip # not available on windows
- wheel
# - zip # not available on windows
3 changes: 2 additions & 1 deletion csp/adapters/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
except ImportError:
from backports import zoneinfo

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

import pytz
from packaging import version

from csp import PushMode, ts
Expand Down
5 changes: 3 additions & 2 deletions csp/adapters/output_adapters/parquet.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import numpy
import os
from importlib.metadata import PackageNotFoundError, version as get_package_version
from packaging import 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
5 changes: 3 additions & 2 deletions csp/adapters/parquet.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import datetime
import io
from importlib.metadata import PackageNotFoundError, 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: 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
4 changes: 2 additions & 2 deletions csp/build/csp_autogen.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import argparse
import importlib
import importlib.util
import importlib.machinery
import importlib.util
import os.path
import sys
import types
Expand All @@ -14,8 +14,8 @@
csp_mod = importlib.util.module_from_spec(spec)
sys.modules["csp"] = csp_mod

from csp.impl.struct import Struct # noqa: E402
from csp.impl.enum import Enum # noqa: E402
from csp.impl.struct import Struct # noqa: E402


def struct_type(type_info):
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,5 +1,6 @@
import numpy
import typing

import numpy
import typing_extensions

import csp.typing
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/pydantic_type_resolver.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from typing import Any, Dict, List, Set, Tuple, Type, Union, get_args

import numpy
from pydantic import TypeAdapter, ValidationError
from typing import Any, Dict, List, Set, Tuple, Type, Union, get_args

import csp.typing
from csp.impl.types.container_type_normalizer import ContainerTypeNormalizer
Expand Down
3 changes: 2 additions & 1 deletion csp/impl/types/pydantic_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
import sys
import types
import typing
from typing import Any, ForwardRef, Generic, Optional, Type, TypeVar, Union, get_args, get_origin

import typing_extensions
from pydantic import GetCoreSchemaHandler, ValidationInfo, ValidatorFunctionWrapHandler
from pydantic_core import CoreSchema, core_schema
from typing import Any, ForwardRef, Generic, Optional, Type, TypeVar, Union, get_args, get_origin

from csp.impl.types.common_definitions import OutputBasket, OutputBasketContainer
from csp.impl.types.tstype import SnapKeyType, SnapType, isTsDynamicBasket
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,9 +1,10 @@
# utils for dealing with typing types
import numpy
import sys
import types
import typing

import numpy

import csp.typing

T = typing.TypeVar("T")
Expand Down
1 change: 1 addition & 0 deletions csp/impl/wiring/adapters.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import inspect
from datetime import timedelta
from typing import List

from typing_extensions import override

from csp.impl.__cspimpl import _cspimpl
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
Loading

0 comments on commit e3b6125

Please sign in to comment.