diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 7d85db3b..e5c0889a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -160,7 +160,7 @@ currently using a minimum version of PyCharm 2019.2.4. - Run `pytest --nbval` to validate install - To test specific versions of Python use `nox -s test-3.8` - To run the automatic formatter and check for lint issues - run `nox -s blacken` + run `nox -s format` ### Documentation diff --git a/docs/source/conf.py b/docs/source/conf.py index 65560de3..2ad50116 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -23,13 +23,13 @@ # -- Path setup -------------------------------------------------------------- +import datetime +import os +import sys + # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. -# -import os -import sys -import datetime sys.path.insert(0, os.path.abspath("../sphinxext")) sys.path.extend( diff --git a/eland/__init__.py b/eland/__init__.py index 0c9ba02c..640b18a9 100644 --- a/eland/__init__.py +++ b/eland/__init__.py @@ -15,22 +15,22 @@ # specific language governing permissions and limitations # under the License. -from eland._version import ( # noqa: F401 - __title__, - __description__, - __url__, - __version__, +from ._version import ( # noqa: F401 __author__, __author_email__, + __description__, __maintainer__, __maintainer_email__, + __title__, + __url__, + __version__, ) -from eland.common import SortOrder -from eland.index import Index -from eland.ndframe import NDFrame -from eland.series import Series -from eland.dataframe import DataFrame -from eland.etl import pandas_to_eland, eland_to_pandas, read_es, read_csv, csv_to_eland +from .common import SortOrder +from .dataframe import DataFrame +from .etl import csv_to_eland, eland_to_pandas, pandas_to_eland, read_csv, read_es +from .index import Index +from .ndframe import NDFrame +from .series import Series __all__ = [ "DataFrame", diff --git a/eland/actions.py b/eland/actions.py index 6da1751a..d9f43069 100644 --- a/eland/actions.py +++ b/eland/actions.py @@ -16,9 +16,9 @@ # under the License. from abc import ABC, abstractmethod -from typing import List, Optional, TYPE_CHECKING, Union -from eland import SortOrder +from typing import TYPE_CHECKING, List, Optional, Union +from eland import SortOrder if TYPE_CHECKING: import pandas as pd # type: ignore diff --git a/eland/arithmetics.py b/eland/arithmetics.py index e8d923b0..b9d1b80f 100644 --- a/eland/arithmetics.py +++ b/eland/arithmetics.py @@ -17,7 +17,7 @@ from abc import ABC, abstractmethod from io import StringIO -from typing import Union, List, TYPE_CHECKING, Any +from typing import TYPE_CHECKING, Any, List, Union import numpy as np # type: ignore diff --git a/eland/common.py b/eland/common.py index 772457ab..647d598e 100644 --- a/eland/common.py +++ b/eland/common.py @@ -18,7 +18,7 @@ import re import warnings from enum import Enum -from typing import Union, List, Tuple, cast, Callable, Any, Optional, Dict +from typing import Any, Callable, Dict, List, Optional, Tuple, Union, cast import numpy as np # type: ignore import pandas as pd # type: ignore diff --git a/eland/dataframe.py b/eland/dataframe.py index 5eea8762..89e110c6 100644 --- a/eland/dataframe.py +++ b/eland/dataframe.py @@ -15,11 +15,11 @@ # specific language governing permissions and limitations # under the License. +import re import sys import warnings from io import StringIO -import re -from typing import List, Optional, Sequence, Union, Tuple +from typing import List, Optional, Sequence, Tuple, Union import numpy as np import pandas as pd @@ -34,12 +34,12 @@ from pandas.util._validators import validate_bool_kwarg import eland.plotting as gfx -from eland.ndframe import NDFrame -from eland.series import Series from eland.common import DEFAULT_NUM_ROWS_DISPLAYED, docstring_parameter from eland.filter import BooleanFilter -from eland.utils import deprecated_api, is_valid_attr_name from eland.groupby import GroupByDataFrame +from eland.ndframe import NDFrame +from eland.series import Series +from eland.utils import deprecated_api, is_valid_attr_name class DataFrame(NDFrame): diff --git a/eland/etl.py b/eland/etl.py index e24b3967..00e6c0f7 100644 --- a/eland/etl.py +++ b/eland/etl.py @@ -16,17 +16,18 @@ # under the License. import csv -from typing import Generator, Union, List, Tuple, Optional, Mapping, Dict, Any from collections import deque +from typing import Any, Dict, Generator, List, Mapping, Optional, Tuple, Union + import pandas as pd # type: ignore +from elasticsearch import Elasticsearch # type: ignore +from elasticsearch.helpers import parallel_bulk # type: ignore from pandas.io.parsers import _c_parser_defaults # type: ignore from eland import DataFrame +from eland.common import DEFAULT_CHUNK_SIZE, ensure_es_client from eland.field_mappings import FieldMappings, verify_mapping_compatibility -from eland.common import ensure_es_client, DEFAULT_CHUNK_SIZE from eland.utils import deprecated_api -from elasticsearch import Elasticsearch # type: ignore -from elasticsearch.helpers import parallel_bulk # type: ignore @deprecated_api("eland.DataFrame()") diff --git a/eland/field_mappings.py b/eland/field_mappings.py index 56018276..7754d298 100644 --- a/eland/field_mappings.py +++ b/eland/field_mappings.py @@ -16,31 +16,32 @@ # under the License. import warnings +from typing import ( + TYPE_CHECKING, + Any, + Dict, + List, + Mapping, + NamedTuple, + Optional, + Set, + Tuple, +) import numpy as np import pandas as pd from pandas.core.dtypes.common import ( - is_float_dtype, is_bool_dtype, - is_integer_dtype, is_datetime_or_timedelta_dtype, + is_float_dtype, + is_integer_dtype, is_string_dtype, ) from pandas.core.dtypes.inference import is_list_like -from typing import ( - NamedTuple, - Optional, - Mapping, - Dict, - Any, - Tuple, - TYPE_CHECKING, - List, - Set, -) if TYPE_CHECKING: from elasticsearch import Elasticsearch + from eland import DataFrame diff --git a/eland/filter.py b/eland/filter.py index ea77929e..3cc5806d 100644 --- a/eland/filter.py +++ b/eland/filter.py @@ -17,7 +17,7 @@ # Originally based on code in MIT-licensed pandasticsearch filters -from typing import Dict, Any, List, Optional, Union, cast +from typing import Any, Dict, List, Optional, Union, cast class BooleanFilter: diff --git a/eland/groupby.py b/eland/groupby.py index b9979dd8..3679a8c1 100644 --- a/eland/groupby.py +++ b/eland/groupby.py @@ -15,7 +15,8 @@ # specific language governing permissions and limitations # under the License. -from typing import List, TYPE_CHECKING +from typing import TYPE_CHECKING, List + from eland.query_compiler import QueryCompiler if TYPE_CHECKING: diff --git a/eland/index.py b/eland/index.py index 08588f77..3a130adc 100644 --- a/eland/index.py +++ b/eland/index.py @@ -15,7 +15,8 @@ # specific language governing permissions and limitations # under the License. -from typing import Optional, TextIO, TYPE_CHECKING +from typing import TYPE_CHECKING, Optional, TextIO + from eland.utils import deprecated_api if TYPE_CHECKING: diff --git a/eland/ml/__init__.py b/eland/ml/__init__.py index 5326bc32..3b650620 100644 --- a/eland/ml/__init__.py +++ b/eland/ml/__init__.py @@ -15,7 +15,7 @@ # specific language governing permissions and limitations # under the License. -from eland.ml.ml_model import MLModel, ImportedMLModel +from eland.ml.ml_model import ImportedMLModel, MLModel __all__ = [ "MLModel", diff --git a/eland/ml/_model_serializer.py b/eland/ml/_model_serializer.py index 976a85c2..da45a00a 100644 --- a/eland/ml/_model_serializer.py +++ b/eland/ml/_model_serializer.py @@ -19,7 +19,7 @@ import gzip import json from abc import ABC -from typing import Sequence, Dict, Any, Optional, List +from typing import Any, Dict, List, Optional, Sequence def add_if_exists(d: Dict[str, Any], k: str, v: Any) -> None: diff --git a/eland/ml/ml_model.py b/eland/ml/ml_model.py index 50d64734..3ca08948 100644 --- a/eland/ml/ml_model.py +++ b/eland/ml/ml_model.py @@ -15,31 +15,40 @@ # specific language governing permissions and limitations # under the License. -from typing import List, Union, cast, Optional, Dict, TYPE_CHECKING, Any, Tuple import warnings -import numpy as np # type: ignore +from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, Union, cast + import elasticsearch # type: ignore -from .common import TYPE_REGRESSION, TYPE_CLASSIFICATION -from .transformers import get_model_transformer +import numpy as np # type: ignore + from eland.common import ensure_es_client, es_version from eland.utils import deprecated_api +from .common import TYPE_CLASSIFICATION, TYPE_REGRESSION +from .transformers import get_model_transformer + if TYPE_CHECKING: from elasticsearch import Elasticsearch # noqa: F401 # Try importing each ML lib separately so mypy users don't have to # have both installed to use type-checking. try: - from sklearn.ensemble import RandomForestClassifier, RandomForestRegressor # type: ignore # noqa: F401 - from sklearn.tree import DecisionTreeClassifier, DecisionTreeRegressor # type: ignore # noqa: F401 + from sklearn.ensemble import ( # type: ignore # noqa: F401 + RandomForestClassifier, + RandomForestRegressor, + ) + from sklearn.tree import ( # type: ignore # noqa: F401 + DecisionTreeClassifier, + DecisionTreeRegressor, + ) except ImportError: pass try: - from xgboost import XGBRegressor, XGBClassifier # type: ignore # noqa: F401 + from xgboost import XGBClassifier, XGBRegressor # type: ignore # noqa: F401 except ImportError: pass try: - from lightgbm import LGBMRegressor, LGBMClassifier # type: ignore # noqa: F401 + from lightgbm import LGBMClassifier, LGBMRegressor # type: ignore # noqa: F401 except ImportError: pass diff --git a/eland/ml/transformers/__init__.py b/eland/ml/transformers/__init__.py index 76a72bbf..7c56f39a 100644 --- a/eland/ml/transformers/__init__.py +++ b/eland/ml/transformers/__init__.py @@ -17,8 +17,8 @@ import inspect from typing import Any, Dict, Type -from .base import ModelTransformer +from .base import ModelTransformer __all__ = ["get_model_transformer"] _MODEL_TRANSFORMERS: Dict[type, Type[ModelTransformer]] = {} @@ -42,13 +42,13 @@ def get_model_transformer(model: Any, **kwargs: Any) -> ModelTransformer: try: + from .sklearn import _MODEL_TRANSFORMERS as _SKLEARN_MODEL_TRANSFORMERS from .sklearn import ( SKLearnDecisionTreeTransformer, SKLearnForestClassifierTransformer, SKLearnForestRegressorTransformer, SKLearnForestTransformer, SKLearnTransformer, - _MODEL_TRANSFORMERS as _SKLEARN_MODEL_TRANSFORMERS, ) __all__ += [ @@ -63,13 +63,13 @@ def get_model_transformer(model: Any, **kwargs: Any) -> ModelTransformer: pass try: + from .xgboost import _MODEL_TRANSFORMERS as _XGBOOST_MODEL_TRANSFORMERS from .xgboost import ( - XGBoostClassifierTransformer, XGBClassifier, + XGBoostClassifierTransformer, XGBoostForestTransformer, XGBoostRegressorTransformer, XGBRegressor, - _MODEL_TRANSFORMERS as _XGBOOST_MODEL_TRANSFORMERS, ) __all__ += [ @@ -84,13 +84,13 @@ def get_model_transformer(model: Any, **kwargs: Any) -> ModelTransformer: pass try: + from .lightgbm import _MODEL_TRANSFORMERS as _LIGHTGBM_MODEL_TRANSFORMERS from .lightgbm import ( - LGBMRegressor, LGBMClassifier, + LGBMClassifierTransformer, LGBMForestTransformer, + LGBMRegressor, LGBMRegressorTransformer, - LGBMClassifierTransformer, - _MODEL_TRANSFORMERS as _LIGHTGBM_MODEL_TRANSFORMERS, ) __all__ += [ diff --git a/eland/ml/transformers/base.py b/eland/ml/transformers/base.py index d251108e..a9f4fdc8 100644 --- a/eland/ml/transformers/base.py +++ b/eland/ml/transformers/base.py @@ -15,7 +15,8 @@ # specific language governing permissions and limitations # under the License. -from typing import Sequence, Optional, Any +from typing import Any, Optional, Sequence + from .._model_serializer import ModelSerializer diff --git a/eland/ml/transformers/lightgbm.py b/eland/ml/transformers/lightgbm.py index 218249c8..8e96957e 100644 --- a/eland/ml/transformers/lightgbm.py +++ b/eland/ml/transformers/lightgbm.py @@ -15,15 +15,16 @@ # specific language governing permissions and limitations # under the License. -from typing import Optional, List, Dict, Any, Type -from .base import ModelTransformer +from typing import Any, Dict, List, Optional, Type + from .._model_serializer import Ensemble, Tree, TreeNode -from ..common import TYPE_CLASSIFICATION, TYPE_REGRESSION from .._optional import import_optional_dependency +from ..common import TYPE_CLASSIFICATION, TYPE_REGRESSION +from .base import ModelTransformer import_optional_dependency("lightgbm", on_version="warn") -from lightgbm import Booster, LGBMRegressor, LGBMClassifier # type: ignore +from lightgbm import Booster, LGBMClassifier, LGBMRegressor # type: ignore def transform_decider(decider: str) -> str: diff --git a/eland/ml/transformers/sklearn.py b/eland/ml/transformers/sklearn.py index 79c999e4..303f5ec4 100644 --- a/eland/ml/transformers/sklearn.py +++ b/eland/ml/transformers/sklearn.py @@ -15,16 +15,21 @@ # specific language governing permissions and limitations # under the License. +from typing import Any, Dict, Optional, Sequence, Tuple, Type, Union + import numpy as np # type: ignore -from typing import Optional, Sequence, Union, Dict, Any, Type, Tuple -from .base import ModelTransformer -from ..common import TYPE_CLASSIFICATION, TYPE_REGRESSION -from .._optional import import_optional_dependency + from .._model_serializer import Ensemble, Tree, TreeNode +from .._optional import import_optional_dependency +from ..common import TYPE_CLASSIFICATION, TYPE_REGRESSION +from .base import ModelTransformer import_optional_dependency("sklearn", on_version="warn") -from sklearn.ensemble import RandomForestClassifier, RandomForestRegressor # type: ignore +from sklearn.ensemble import ( # type: ignore + RandomForestClassifier, + RandomForestRegressor, +) from sklearn.tree import DecisionTreeClassifier, DecisionTreeRegressor # type: ignore from sklearn.utils.validation import check_is_fitted # type: ignore diff --git a/eland/ml/transformers/xgboost.py b/eland/ml/transformers/xgboost.py index 4adb4d20..5d4e85ea 100644 --- a/eland/ml/transformers/xgboost.py +++ b/eland/ml/transformers/xgboost.py @@ -16,16 +16,18 @@ # under the License. import re -from typing import Optional, List, Dict, Any, Type -from .base import ModelTransformer +from typing import Any, Dict, List, Optional, Type + import pandas as pd # type: ignore + from .._model_serializer import Ensemble, Tree, TreeNode -from ..common import TYPE_CLASSIFICATION, TYPE_REGRESSION from .._optional import import_optional_dependency +from ..common import TYPE_CLASSIFICATION, TYPE_REGRESSION +from .base import ModelTransformer import_optional_dependency("xgboost", on_version="warn") -from xgboost import Booster, XGBRegressor, XGBClassifier # type: ignore +from xgboost import Booster, XGBClassifier, XGBRegressor # type: ignore class XGBoostForestTransformer(ModelTransformer): diff --git a/eland/ndframe.py b/eland/ndframe.py index e55f5576..17ef2886 100644 --- a/eland/ndframe.py +++ b/eland/ndframe.py @@ -17,10 +17,11 @@ import sys from abc import ABC, abstractmethod -from typing import TYPE_CHECKING, Tuple, Optional +from typing import TYPE_CHECKING, Optional, Tuple + import pandas as pd -from eland.query_compiler import QueryCompiler +from eland.query_compiler import QueryCompiler if TYPE_CHECKING: from eland.index import Index diff --git a/eland/operations.py b/eland/operations.py index 63fcf899..70251560 100644 --- a/eland/operations.py +++ b/eland/operations.py @@ -17,49 +17,49 @@ import copy import warnings +from collections import defaultdict from typing import ( + TYPE_CHECKING, + Any, + Dict, Generator, + List, Optional, Sequence, Tuple, - List, - Dict, - Any, - TYPE_CHECKING, Union, ) import numpy as np import pandas as pd -from collections import defaultdict from elasticsearch.helpers import scan -from eland.index import Index +from eland.actions import PostProcessingAction, SortFieldAction from eland.common import ( - SortOrder, DEFAULT_CSV_BATCH_OUTPUT_SIZE, DEFAULT_ES_MAX_RESULT_WINDOW, - elasticsearch_date_to_pandas_date, - build_pd_series, DEFAULT_PAGINATION_SIZE, + SortOrder, + build_pd_series, + elasticsearch_date_to_pandas_date, ) +from eland.index import Index from eland.query import Query -from eland.actions import PostProcessingAction, SortFieldAction from eland.tasks import ( - HeadTask, RESOLVED_TASK_TYPE, - TailTask, - SampleTask, - BooleanFilterTask, ArithmeticOpFieldsTask, - QueryTermsTask, + BooleanFilterTask, + HeadTask, QueryIdsTask, + QueryTermsTask, + SampleTask, SizeTask, + TailTask, ) if TYPE_CHECKING: - from eland.query_compiler import QueryCompiler from eland.field_mappings import Field + from eland.query_compiler import QueryCompiler class QueryParams: diff --git a/eland/plotting/__init__.py b/eland/plotting/__init__.py index 61c16a05..571191f9 100644 --- a/eland/plotting/__init__.py +++ b/eland/plotting/__init__.py @@ -22,10 +22,7 @@ but only supporting a subset of plotting methods (for now). """ -from eland.plotting._core import ( - ed_hist_frame, - ed_hist_series, -) +from eland.plotting._core import ed_hist_frame, ed_hist_series __all__ = [ "ed_hist_frame", diff --git a/eland/plotting/_core.py b/eland/plotting/_core.py index 26951bb0..2f402fed 100644 --- a/eland/plotting/_core.py +++ b/eland/plotting/_core.py @@ -15,7 +15,7 @@ # specific language governing permissions and limitations # under the License. -from eland.plotting._matplotlib.hist import hist_series, hist_frame +from eland.plotting._matplotlib.hist import hist_frame, hist_series def ed_hist_series( diff --git a/eland/plotting/_matplotlib/__init__.py b/eland/plotting/_matplotlib/__init__.py index 3af30269..15d74ec8 100644 --- a/eland/plotting/_matplotlib/__init__.py +++ b/eland/plotting/_matplotlib/__init__.py @@ -22,10 +22,7 @@ but only supporting a subset of plotting methods (for now). """ -from eland.plotting._matplotlib.hist import ( - hist_frame, - hist_series, -) +from eland.plotting._matplotlib.hist import hist_frame, hist_series __all__ = [ "hist_frame", diff --git a/eland/plotting/_matplotlib/hist.py b/eland/plotting/_matplotlib/hist.py index 197d9b95..f3b33419 100644 --- a/eland/plotting/_matplotlib/hist.py +++ b/eland/plotting/_matplotlib/hist.py @@ -19,6 +19,7 @@ from pandas.core.dtypes.generic import ABCIndexClass from pandas.plotting._matplotlib import converter from pandas.plotting._matplotlib.tools import _flatten, _set_ticks_props, _subplots + from eland.utils import try_sort diff --git a/eland/query.py b/eland/query.py index 3c2ad1b5..8d55fa25 100644 --- a/eland/query.py +++ b/eland/query.py @@ -17,16 +17,9 @@ import warnings from copy import deepcopy -from typing import Optional, Dict, List, Any - -from eland.filter import ( - RandomScoreFilter, - BooleanFilter, - NotNull, - IsNull, - IsIn, - Rlike, -) +from typing import Any, Dict, List, Optional + +from eland.filter import BooleanFilter, IsIn, IsNull, NotNull, RandomScoreFilter, Rlike class Query: diff --git a/eland/query_compiler.py b/eland/query_compiler.py index f1a4240d..956e402d 100644 --- a/eland/query_compiler.py +++ b/eland/query_compiler.py @@ -17,20 +17,20 @@ import copy from datetime import datetime -from typing import Optional, Sequence, TYPE_CHECKING, List +from typing import TYPE_CHECKING, List, Optional, Sequence import numpy as np # type: ignore import pandas as pd # type: ignore -from eland.field_mappings import FieldMappings -from eland.filter import QueryFilter -from eland.operations import Operations -from eland.index import Index from eland.common import ( - ensure_es_client, DEFAULT_PROGRESS_REPORTING_NUM_ROWS, elasticsearch_date_to_pandas_date, + ensure_es_client, ) +from eland.field_mappings import FieldMappings +from eland.filter import QueryFilter +from eland.index import Index +from eland.operations import Operations if TYPE_CHECKING: from .tasks import ArithmeticOpFieldsTask # noqa: F401 diff --git a/eland/series.py b/eland/series.py index fcf21738..3004693b 100644 --- a/eland/series.py +++ b/eland/series.py @@ -35,33 +35,34 @@ import warnings from collections.abc import Collection from io import StringIO -from typing import Optional, Union, Sequence, Any, Tuple, TYPE_CHECKING +from typing import TYPE_CHECKING, Any, Optional, Sequence, Tuple, Union import numpy as np import pandas as pd from pandas.io.common import _expand_user, stringify_path import eland.plotting -from eland import NDFrame -from eland.arithmetics import ArithmeticSeries, ArithmeticString, ArithmeticNumber +from eland.arithmetics import ArithmeticNumber, ArithmeticSeries, ArithmeticString from eland.common import DEFAULT_NUM_ROWS_DISPLAYED, docstring_parameter from eland.filter import ( BooleanFilter, - NotFilter, Equal, Greater, - Less, GreaterEqual, - LessEqual, - ScriptFilter, IsIn, IsNull, + Less, + LessEqual, + NotFilter, NotNull, + ScriptFilter, ) +from eland.ndframe import NDFrame from eland.utils import deprecated_api, to_list if TYPE_CHECKING: # type: ignore from elasticsearch import Elasticsearch # noqa: F401 + from eland.query_compiler import QueryCompiler # noqa: F401 diff --git a/eland/tasks.py b/eland/tasks.py index f2b5b397..fff7ec02 100644 --- a/eland/tasks.py +++ b/eland/tasks.py @@ -16,18 +16,18 @@ # under the License. from abc import ABC, abstractmethod -from typing import TYPE_CHECKING, List, Any, Tuple +from typing import TYPE_CHECKING, Any, List, Tuple from eland import SortOrder -from eland.actions import HeadAction, TailAction, SortIndexAction +from eland.actions import HeadAction, SortIndexAction, TailAction from eland.arithmetics import ArithmeticSeries if TYPE_CHECKING: from .actions import PostProcessingAction # noqa: F401 from .filter import BooleanFilter # noqa: F401 - from .query_compiler import QueryCompiler # noqa: F401 - from .operations import QueryParams # noqa: F401 from .index import Index # noqa: F401 + from .operations import QueryParams # noqa: F401 + from .query_compiler import QueryCompiler # noqa: F401 RESOLVED_TASK_TYPE = Tuple["QueryParams", List["PostProcessingAction"]] diff --git a/eland/tests/__init__.py b/eland/tests/__init__.py index eb0b155a..7b0ba966 100644 --- a/eland/tests/__init__.py +++ b/eland/tests/__init__.py @@ -19,6 +19,7 @@ import pandas as pd from elasticsearch import Elasticsearch + from eland.common import es_version ROOT_DIR = os.path.dirname(os.path.abspath(__file__)) diff --git a/eland/tests/common.py b/eland/tests/common.py index 8bc4e860..21553cea 100644 --- a/eland/tests/common.py +++ b/eland/tests/common.py @@ -26,12 +26,12 @@ # Create pandas and eland data frames from eland.tests import ( + ECOMMERCE_DF_FILE_NAME, + ECOMMERCE_INDEX_NAME, ES_TEST_CLIENT, FLIGHTS_DF_FILE_NAME, FLIGHTS_INDEX_NAME, FLIGHTS_SMALL_INDEX_NAME, - ECOMMERCE_DF_FILE_NAME, - ECOMMERCE_INDEX_NAME, ) _pd_flights = pd.read_json(FLIGHTS_DF_FILE_NAME).sort_index() diff --git a/eland/tests/conftest.py b/eland/tests/conftest.py index 525862c5..680942f1 100644 --- a/eland/tests/conftest.py +++ b/eland/tests/conftest.py @@ -16,22 +16,25 @@ # under the License. import inspect -import pytest + import pandas as pd +import pytest + +import eland as ed + from .common import ( - assert_pandas_eland_frame_equal, - assert_pandas_eland_series_equal, - assert_frame_equal, - assert_series_equal, - _ed_flights, - _pd_flights, + TestData, _ed_ecommerce, - _pd_ecommerce, + _ed_flights, _ed_flights_small, + _pd_ecommerce, + _pd_flights, _pd_flights_small, - TestData, + assert_frame_equal, + assert_pandas_eland_frame_equal, + assert_pandas_eland_series_equal, + assert_series_equal, ) -import eland as ed class SymmetricAPIChecker: diff --git a/eland/tests/dataframe/test_aggs_pytest.py b/eland/tests/dataframe/test_aggs_pytest.py index e483f471..54b05a23 100644 --- a/eland/tests/dataframe/test_aggs_pytest.py +++ b/eland/tests/dataframe/test_aggs_pytest.py @@ -18,8 +18,9 @@ # File called _pytest for PyCharm compatability import numpy as np -from pandas.testing import assert_frame_equal, assert_series_equal import pytest +from pandas.testing import assert_frame_equal, assert_series_equal + from eland.tests.common import TestData diff --git a/eland/tests/dataframe/test_big_mapping_pytest.py b/eland/tests/dataframe/test_big_mapping_pytest.py index de268f91..425365ce 100644 --- a/eland/tests/dataframe/test_big_mapping_pytest.py +++ b/eland/tests/dataframe/test_big_mapping_pytest.py @@ -18,8 +18,7 @@ # File called _pytest for PyCharm compatability import eland as ed -from eland.tests.common import ES_TEST_CLIENT -from eland.tests.common import TestData +from eland.tests.common import ES_TEST_CLIENT, TestData class TestDataFrameBigMapping(TestData): diff --git a/eland/tests/dataframe/test_datetime_pytest.py b/eland/tests/dataframe/test_datetime_pytest.py index b523e563..99ae51ab 100644 --- a/eland/tests/dataframe/test_datetime_pytest.py +++ b/eland/tests/dataframe/test_datetime_pytest.py @@ -24,10 +24,12 @@ import eland as ed from eland.field_mappings import FieldMappings -from eland.tests.common import ES_TEST_CLIENT -from eland.tests.common import TestData -from eland.tests.common import assert_pandas_eland_frame_equal -from eland.tests.common import assert_pandas_eland_series_equal +from eland.tests.common import ( + ES_TEST_CLIENT, + TestData, + assert_pandas_eland_frame_equal, + assert_pandas_eland_series_equal, +) class TestDataFrameDateTime(TestData): diff --git a/eland/tests/dataframe/test_dtypes_pytest.py b/eland/tests/dataframe/test_dtypes_pytest.py index fd0630cf..729d9634 100644 --- a/eland/tests/dataframe/test_dtypes_pytest.py +++ b/eland/tests/dataframe/test_dtypes_pytest.py @@ -19,6 +19,7 @@ import numpy as np import pandas as pd + from eland.tests.common import assert_series_equal diff --git a/eland/tests/dataframe/test_es_query_pytest.py b/eland/tests/dataframe/test_es_query_pytest.py index 95e24dd8..fe9429a8 100644 --- a/eland/tests/dataframe/test_es_query_pytest.py +++ b/eland/tests/dataframe/test_es_query_pytest.py @@ -18,8 +18,8 @@ # File called _pytest for PyCharm compatability import pytest -from eland.tests.common import TestData -from eland.tests.common import assert_eland_frame_equal + +from eland.tests.common import TestData, assert_eland_frame_equal class TestDataEsQuery(TestData): diff --git a/eland/tests/dataframe/test_filter_pytest.py b/eland/tests/dataframe/test_filter_pytest.py index 9524e17a..9fdc7a27 100644 --- a/eland/tests/dataframe/test_filter_pytest.py +++ b/eland/tests/dataframe/test_filter_pytest.py @@ -18,6 +18,7 @@ # File called _pytest for PyCharm compatability import pytest + from eland.tests.common import TestData diff --git a/eland/tests/dataframe/test_groupby_pytest.py b/eland/tests/dataframe/test_groupby_pytest.py index 3cdd48a7..3ae95a01 100644 --- a/eland/tests/dataframe/test_groupby_pytest.py +++ b/eland/tests/dataframe/test_groupby_pytest.py @@ -17,10 +17,11 @@ # File called _pytest for PyCharm compatability +import pandas as pd import pytest from pandas.testing import assert_frame_equal, assert_series_equal + from eland.tests.common import TestData -import pandas as pd class TestGroupbyDataFrame(TestData): diff --git a/eland/tests/dataframe/test_head_tail_pytest.py b/eland/tests/dataframe/test_head_tail_pytest.py index 829159b1..ec1f0a42 100644 --- a/eland/tests/dataframe/test_head_tail_pytest.py +++ b/eland/tests/dataframe/test_head_tail_pytest.py @@ -17,8 +17,7 @@ # File called _pytest for PyCharm compatability -from eland.tests.common import TestData -from eland.tests.common import assert_pandas_eland_frame_equal +from eland.tests.common import TestData, assert_pandas_eland_frame_equal class TestDataFrameHeadTail(TestData): diff --git a/eland/tests/dataframe/test_info_pytest.py b/eland/tests/dataframe/test_info_pytest.py index b7151026..6b38a0a9 100644 --- a/eland/tests/dataframe/test_info_pytest.py +++ b/eland/tests/dataframe/test_info_pytest.py @@ -19,9 +19,7 @@ from io import StringIO import eland as ed - from eland.tests import ES_TEST_CLIENT - from eland.tests.common import TestData diff --git a/eland/tests/dataframe/test_init_pytest.py b/eland/tests/dataframe/test_init_pytest.py index b8c5aa12..e33dd6bf 100644 --- a/eland/tests/dataframe/test_init_pytest.py +++ b/eland/tests/dataframe/test_init_pytest.py @@ -21,8 +21,7 @@ import eland as ed from eland.query_compiler import QueryCompiler -from eland.tests import ES_TEST_CLIENT -from eland.tests import FLIGHTS_INDEX_NAME +from eland.tests import ES_TEST_CLIENT, FLIGHTS_INDEX_NAME class TestDataFrameInit: diff --git a/eland/tests/dataframe/test_metrics_pytest.py b/eland/tests/dataframe/test_metrics_pytest.py index dbef894e..d3d57851 100644 --- a/eland/tests/dataframe/test_metrics_pytest.py +++ b/eland/tests/dataframe/test_metrics_pytest.py @@ -15,11 +15,13 @@ # specific language governing permissions and limitations # under the License. -# File called _pytest for PyCharm compatibility -import pytest import numpy as np import pandas as pd + +# File called _pytest for PyCharm compatibility +import pytest from pandas.testing import assert_series_equal + from eland.tests.common import TestData diff --git a/eland/tests/dataframe/test_query_pytest.py b/eland/tests/dataframe/test_query_pytest.py index 97a9eebd..321f351c 100644 --- a/eland/tests/dataframe/test_query_pytest.py +++ b/eland/tests/dataframe/test_query_pytest.py @@ -20,9 +20,7 @@ import pandas as pd import eland as ed -from eland.tests.common import ES_TEST_CLIENT -from eland.tests.common import TestData -from eland.tests.common import assert_pandas_eland_frame_equal +from eland.tests.common import ES_TEST_CLIENT, TestData, assert_pandas_eland_frame_equal class TestDataFrameQuery(TestData): diff --git a/eland/tests/dataframe/test_sample_pytest.py b/eland/tests/dataframe/test_sample_pytest.py index 9a4a5757..33451261 100644 --- a/eland/tests/dataframe/test_sample_pytest.py +++ b/eland/tests/dataframe/test_sample_pytest.py @@ -19,8 +19,8 @@ import pytest from pandas.testing import assert_frame_equal -from eland.tests.common import TestData from eland import eland_to_pandas +from eland.tests.common import TestData class TestDataFrameSample(TestData): diff --git a/eland/tests/dataframe/test_select_dtypes_pytest.py b/eland/tests/dataframe/test_select_dtypes_pytest.py index d00ae178..738bf3bd 100644 --- a/eland/tests/dataframe/test_select_dtypes_pytest.py +++ b/eland/tests/dataframe/test_select_dtypes_pytest.py @@ -18,8 +18,7 @@ # File called _pytest for PyCharm compatability import numpy as np -from eland.tests.common import TestData -from eland.tests.common import assert_pandas_eland_frame_equal +from eland.tests.common import TestData, assert_pandas_eland_frame_equal class TestDataFrameSelectDTypes(TestData): diff --git a/eland/tests/dataframe/test_to_csv_pytest.py b/eland/tests/dataframe/test_to_csv_pytest.py index 5ca50482..bb9560f4 100644 --- a/eland/tests/dataframe/test_to_csv_pytest.py +++ b/eland/tests/dataframe/test_to_csv_pytest.py @@ -24,10 +24,8 @@ from pandas.testing import assert_frame_equal import eland as ed -from eland.tests import ES_TEST_CLIENT -from eland.tests import FLIGHTS_INDEX_NAME -from eland.tests.common import ROOT_DIR -from eland.tests.common import TestData +from eland.tests import ES_TEST_CLIENT, FLIGHTS_INDEX_NAME +from eland.tests.common import ROOT_DIR, TestData class TestDataFrameToCSV(TestData): diff --git a/eland/tests/dataframe/test_utils_pytest.py b/eland/tests/dataframe/test_utils_pytest.py index fa5985ae..e1b57c33 100644 --- a/eland/tests/dataframe/test_utils_pytest.py +++ b/eland/tests/dataframe/test_utils_pytest.py @@ -22,8 +22,7 @@ import eland as ed from eland.field_mappings import FieldMappings -from eland.tests.common import ES_TEST_CLIENT, assert_pandas_eland_frame_equal -from eland.tests.common import TestData +from eland.tests.common import ES_TEST_CLIENT, TestData, assert_pandas_eland_frame_equal class TestDataFrameUtils(TestData): diff --git a/eland/tests/etl/test_pandas_to_eland.py b/eland/tests/etl/test_pandas_to_eland.py index 2ffb01ba..e4a054ab 100644 --- a/eland/tests/etl/test_pandas_to_eland.py +++ b/eland/tests/etl/test_pandas_to_eland.py @@ -16,10 +16,12 @@ # under the License. from datetime import datetime, timedelta -import pytest + import pandas as pd +import pytest from elasticsearch.helpers import BulkIndexError -from eland import pandas_to_eland, DataFrame + +from eland import DataFrame, pandas_to_eland from eland.tests.common import ( ES_TEST_CLIENT, assert_frame_equal, diff --git a/eland/tests/field_mappings/test_aggregatables_pytest.py b/eland/tests/field_mappings/test_aggregatables_pytest.py index 2f4a62f8..c6af0a30 100644 --- a/eland/tests/field_mappings/test_aggregatables_pytest.py +++ b/eland/tests/field_mappings/test_aggregatables_pytest.py @@ -19,7 +19,7 @@ import pytest from eland.field_mappings import FieldMappings -from eland.tests import ES_TEST_CLIENT, ECOMMERCE_INDEX_NAME +from eland.tests import ECOMMERCE_INDEX_NAME, ES_TEST_CLIENT from eland.tests.common import TestData diff --git a/eland/tests/field_mappings/test_datetime_pytest.py b/eland/tests/field_mappings/test_datetime_pytest.py index 4ce575aa..447381e5 100644 --- a/eland/tests/field_mappings/test_datetime_pytest.py +++ b/eland/tests/field_mappings/test_datetime_pytest.py @@ -19,8 +19,7 @@ from datetime import datetime from eland.field_mappings import FieldMappings -from eland.tests.common import ES_TEST_CLIENT -from eland.tests.common import TestData +from eland.tests.common import ES_TEST_CLIENT, TestData class TestDateTime(TestData): diff --git a/eland/tests/field_mappings/test_field_name_pd_dtype_pytest.py b/eland/tests/field_mappings/test_field_name_pd_dtype_pytest.py index 30bdc346..94efe2cd 100644 --- a/eland/tests/field_mappings/test_field_name_pd_dtype_pytest.py +++ b/eland/tests/field_mappings/test_field_name_pd_dtype_pytest.py @@ -21,8 +21,7 @@ from eland.field_mappings import FieldMappings from eland.tests import FLIGHTS_INDEX_NAME, FLIGHTS_MAPPING -from eland.tests.common import ES_TEST_CLIENT -from eland.tests.common import TestData +from eland.tests.common import ES_TEST_CLIENT, TestData class TestFieldNamePDDType(TestData): diff --git a/eland/tests/field_mappings/test_get_field_names_pytest.py b/eland/tests/field_mappings/test_get_field_names_pytest.py index c56ccda8..59bdd385 100644 --- a/eland/tests/field_mappings/test_get_field_names_pytest.py +++ b/eland/tests/field_mappings/test_get_field_names_pytest.py @@ -21,7 +21,7 @@ # File called _pytest for PyCharm compatability from eland.field_mappings import FieldMappings -from eland.tests import FLIGHTS_INDEX_NAME, ES_TEST_CLIENT +from eland.tests import ES_TEST_CLIENT, FLIGHTS_INDEX_NAME from eland.tests.common import TestData diff --git a/eland/tests/field_mappings/test_metric_source_fields_pytest.py b/eland/tests/field_mappings/test_metric_source_fields_pytest.py index 6cf8001f..9c4e2c94 100644 --- a/eland/tests/field_mappings/test_metric_source_fields_pytest.py +++ b/eland/tests/field_mappings/test_metric_source_fields_pytest.py @@ -20,7 +20,7 @@ import numpy as np from eland.field_mappings import FieldMappings -from eland.tests import ES_TEST_CLIENT, ECOMMERCE_INDEX_NAME, FLIGHTS_INDEX_NAME +from eland.tests import ECOMMERCE_INDEX_NAME, ES_TEST_CLIENT, FLIGHTS_INDEX_NAME from eland.tests.common import TestData diff --git a/eland/tests/field_mappings/test_scripted_fields_pytest.py b/eland/tests/field_mappings/test_scripted_fields_pytest.py index f2f276ad..0e3d4f99 100644 --- a/eland/tests/field_mappings/test_scripted_fields_pytest.py +++ b/eland/tests/field_mappings/test_scripted_fields_pytest.py @@ -21,7 +21,7 @@ import numpy as np from eland.field_mappings import FieldMappings -from eland.tests import FLIGHTS_INDEX_NAME, ES_TEST_CLIENT +from eland.tests import ES_TEST_CLIENT, FLIGHTS_INDEX_NAME from eland.tests.common import TestData diff --git a/eland/tests/ml/test_imported_ml_model_pytest.py b/eland/tests/ml/test_imported_ml_model_pytest.py index d9ca4a4a..9e8445d4 100644 --- a/eland/tests/ml/test_imported_ml_model_pytest.py +++ b/eland/tests/ml/test_imported_ml_model_pytest.py @@ -15,16 +15,15 @@ # specific language governing permissions and limitations # under the License. -import pytest import numpy as np +import pytest from eland.ml import MLModel from eland.tests import ES_TEST_CLIENT, ES_VERSION - try: from sklearn import datasets - from sklearn.ensemble import RandomForestRegressor, RandomForestClassifier + from sklearn.ensemble import RandomForestClassifier, RandomForestRegressor from sklearn.tree import DecisionTreeClassifier, DecisionTreeRegressor HAS_SKLEARN = True @@ -32,14 +31,14 @@ HAS_SKLEARN = False try: - from xgboost import XGBRegressor, XGBClassifier + from xgboost import XGBClassifier, XGBRegressor HAS_XGBOOST = True except ImportError: HAS_XGBOOST = False try: - from lightgbm import LGBMRegressor, LGBMClassifier + from lightgbm import LGBMClassifier, LGBMRegressor HAS_LIGHTGBM = True except ImportError: diff --git a/eland/tests/operators/test_operators_pytest.py b/eland/tests/operators/test_operators_pytest.py index 0b7cb616..7fe602ca 100644 --- a/eland/tests/operators/test_operators_pytest.py +++ b/eland/tests/operators/test_operators_pytest.py @@ -16,18 +16,18 @@ # under the License. from eland.filter import ( + Equal, Greater, GreaterEqual, - Less, - LessEqual, - Equal, IsIn, IsNull, + Less, + LessEqual, Like, - Rlike, - Startswith, NotNull, + Rlike, ScriptFilter, + Startswith, ) diff --git a/eland/tests/series/test_describe_pytest.py b/eland/tests/series/test_describe_pytest.py index 2f6f6ec7..2f255ebf 100644 --- a/eland/tests/series/test_describe_pytest.py +++ b/eland/tests/series/test_describe_pytest.py @@ -16,6 +16,7 @@ # under the License. import pandas as pd + from eland.tests.common import TestData, assert_series_equal diff --git a/eland/tests/series/test_dtype_pytest.py b/eland/tests/series/test_dtype_pytest.py index eb00c989..4c45531d 100644 --- a/eland/tests/series/test_dtype_pytest.py +++ b/eland/tests/series/test_dtype_pytest.py @@ -15,10 +15,12 @@ # specific language governing permissions and limitations # under the License. +import warnings + import numpy as np import pandas as pd -import warnings -from eland.common import build_pd_series, EMPTY_SERIES_DTYPE + +from eland.common import EMPTY_SERIES_DTYPE, build_pd_series from eland.tests.common import assert_series_equal diff --git a/eland/tests/series/test_filter_pytest.py b/eland/tests/series/test_filter_pytest.py index 052ef9a8..9da03c7c 100644 --- a/eland/tests/series/test_filter_pytest.py +++ b/eland/tests/series/test_filter_pytest.py @@ -18,8 +18,8 @@ # File called _pytest for PyCharm compatability import pytest -from eland.tests.common import TestData -from eland.tests.common import assert_pandas_eland_series_equal + +from eland.tests.common import TestData, assert_pandas_eland_series_equal class TestSeriesFilter(TestData): diff --git a/eland/tests/series/test_head_tail_pytest.py b/eland/tests/series/test_head_tail_pytest.py index 49cb83c9..93c1d3f5 100644 --- a/eland/tests/series/test_head_tail_pytest.py +++ b/eland/tests/series/test_head_tail_pytest.py @@ -17,10 +17,8 @@ # File called _pytest for PyCharm compatability import eland as ed -from eland.tests import ES_TEST_CLIENT -from eland.tests import FLIGHTS_INDEX_NAME -from eland.tests.common import TestData -from eland.tests.common import assert_pandas_eland_series_equal +from eland.tests import ES_TEST_CLIENT, FLIGHTS_INDEX_NAME +from eland.tests.common import TestData, assert_pandas_eland_series_equal class TestSeriesHeadTail(TestData): diff --git a/eland/tests/series/test_metrics_pytest.py b/eland/tests/series/test_metrics_pytest.py index d8e213d2..01ce34a8 100644 --- a/eland/tests/series/test_metrics_pytest.py +++ b/eland/tests/series/test_metrics_pytest.py @@ -17,11 +17,12 @@ # File called _pytest for PyCharm compatability -import pytest -import pandas as pd -import numpy as np from datetime import timedelta +import numpy as np +import pandas as pd +import pytest + from eland.tests.common import TestData diff --git a/eland/tests/series/test_na_pytest.py b/eland/tests/series/test_na_pytest.py index d9267b92..a11c91c2 100644 --- a/eland/tests/series/test_na_pytest.py +++ b/eland/tests/series/test_na_pytest.py @@ -16,8 +16,7 @@ # under the License. from eland import eland_to_pandas -from eland.tests.common import TestData -from eland.tests.common import assert_pandas_eland_frame_equal +from eland.tests.common import TestData, assert_pandas_eland_frame_equal class TestSeriesNA(TestData): diff --git a/eland/tests/series/test_name_pytest.py b/eland/tests/series/test_name_pytest.py index 37209165..619aa9c3 100644 --- a/eland/tests/series/test_name_pytest.py +++ b/eland/tests/series/test_name_pytest.py @@ -17,10 +17,8 @@ # File called _pytest for PyCharm compatability import eland as ed -from eland.tests import ES_TEST_CLIENT -from eland.tests import FLIGHTS_INDEX_NAME -from eland.tests.common import TestData -from eland.tests.common import assert_pandas_eland_series_equal +from eland.tests import ES_TEST_CLIENT, FLIGHTS_INDEX_NAME +from eland.tests.common import TestData, assert_pandas_eland_series_equal class TestSeriesName(TestData): diff --git a/eland/tests/series/test_rename_pytest.py b/eland/tests/series/test_rename_pytest.py index ae970c05..b99b9bb6 100644 --- a/eland/tests/series/test_rename_pytest.py +++ b/eland/tests/series/test_rename_pytest.py @@ -17,10 +17,8 @@ # File called _pytest for PyCharm compatability import eland as ed -from eland.tests import ES_TEST_CLIENT -from eland.tests import FLIGHTS_INDEX_NAME -from eland.tests.common import TestData -from eland.tests.common import assert_pandas_eland_series_equal +from eland.tests import ES_TEST_CLIENT, FLIGHTS_INDEX_NAME +from eland.tests.common import TestData, assert_pandas_eland_series_equal class TestSeriesRename(TestData): diff --git a/eland/tests/series/test_repr_pytest.py b/eland/tests/series/test_repr_pytest.py index f1da73d7..61c103c5 100644 --- a/eland/tests/series/test_repr_pytest.py +++ b/eland/tests/series/test_repr_pytest.py @@ -17,8 +17,7 @@ # File called _pytest for PyCharm compatability import eland as ed -from eland.tests import ES_TEST_CLIENT -from eland.tests import FLIGHTS_INDEX_NAME +from eland.tests import ES_TEST_CLIENT, FLIGHTS_INDEX_NAME from eland.tests.common import TestData diff --git a/eland/tests/series/test_sample_pytest.py b/eland/tests/series/test_sample_pytest.py index 8de43e38..184e4b3f 100644 --- a/eland/tests/series/test_sample_pytest.py +++ b/eland/tests/series/test_sample_pytest.py @@ -17,10 +17,8 @@ # File called _pytest for PyCharm compatibility import eland as ed -from eland.tests import ES_TEST_CLIENT -from eland.tests import FLIGHTS_INDEX_NAME -from eland.tests.common import TestData -from eland.tests.common import assert_pandas_eland_series_equal +from eland.tests import ES_TEST_CLIENT, FLIGHTS_INDEX_NAME +from eland.tests.common import TestData, assert_pandas_eland_series_equal class TestSeriesSample(TestData): diff --git a/eland/tests/setup_tests.py b/eland/tests/setup_tests.py index b858c645..a5075237 100644 --- a/eland/tests/setup_tests.py +++ b/eland/tests/setup_tests.py @@ -18,25 +18,24 @@ import pandas as pd from elasticsearch import helpers +from eland.common import es_version from eland.tests import ( + ECOMMERCE_FILE_NAME, + ECOMMERCE_INDEX_NAME, + ECOMMERCE_MAPPING, + ELASTICSEARCH_HOST, + ES_TEST_CLIENT, FLIGHTS_FILE_NAME, FLIGHTS_INDEX_NAME, + FLIGHTS_MAPPING, FLIGHTS_SMALL_FILE_NAME, FLIGHTS_SMALL_INDEX_NAME, - FLIGHTS_MAPPING, - ECOMMERCE_FILE_NAME, - ECOMMERCE_INDEX_NAME, - ECOMMERCE_MAPPING, TEST_MAPPING1, TEST_MAPPING1_INDEX_NAME, TEST_NESTED_USER_GROUP_DOCS, TEST_NESTED_USER_GROUP_INDEX_NAME, TEST_NESTED_USER_GROUP_MAPPING, - ES_TEST_CLIENT, - ELASTICSEARCH_HOST, ) -from eland.common import es_version - DATA_LIST = [ (FLIGHTS_FILE_NAME, FLIGHTS_INDEX_NAME, FLIGHTS_MAPPING), diff --git a/eland/utils.py b/eland/utils.py index 66bf5862..de63e19e 100644 --- a/eland/utils.py +++ b/eland/utils.py @@ -15,13 +15,13 @@ # specific language governing permissions and limitations # under the License. -import re import functools +import re import warnings -from typing import Callable, TypeVar, Any, Union, List, cast, Collection, Iterable from collections.abc import Collection as ABCCollection -import pandas as pd # type: ignore +from typing import Any, Callable, Collection, Iterable, List, TypeVar, Union, cast +import pandas as pd # type: ignore RT = TypeVar("RT") diff --git a/noxfile.py b/noxfile.py index fe8ec113..52517f53 100644 --- a/noxfile.py +++ b/noxfile.py @@ -18,9 +18,9 @@ import os import subprocess from pathlib import Path -import nox -import elasticsearch +import elasticsearch +import nox BASE_DIR = Path(__file__).parent SOURCE_FILES = ( @@ -57,18 +57,20 @@ @nox.session(reuse_venv=True) -def blacken(session): - session.install("black") +def format(session): + session.install("black", "isort") session.run("python", "utils/license-headers.py", "fix", *SOURCE_FILES) session.run("black", "--target-version=py36", *SOURCE_FILES) + session.run("isort", *SOURCE_FILES) lint(session) @nox.session(reuse_venv=True) def lint(session): - session.install("black", "flake8", "mypy") + session.install("black", "flake8", "mypy", "isort") session.run("python", "utils/license-headers.py", "check", *SOURCE_FILES) session.run("black", "--check", "--target-version=py36", *SOURCE_FILES) + session.run("isort", "--check", *SOURCE_FILES) session.run("flake8", "--ignore=E501,W503,E402,E712,E203", *SOURCE_FILES) # TODO: When all files are typed we can change this to .run("mypy", "--strict", "eland/") diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 00000000..c76db01f --- /dev/null +++ b/setup.cfg @@ -0,0 +1,2 @@ +[isort] +profile = black diff --git a/setup.py b/setup.py index 450a7be4..8b36258a 100644 --- a/setup.py +++ b/setup.py @@ -20,7 +20,7 @@ from codecs import open from os import path -from setuptools import setup, find_packages +from setuptools import find_packages, setup here = path.abspath(path.dirname(__file__)) about = {} diff --git a/utils/generate-supported-apis.py b/utils/generate-supported-apis.py index 58020da5..ba4b939a 100644 --- a/utils/generate-supported-apis.py +++ b/utils/generate-supported-apis.py @@ -17,12 +17,13 @@ """Script that is used to create the compatibility matrix in the documentation""" -import re -import eland -import pandas import inspect +import re from pathlib import Path +import pandas + +import eland api_docs_dir = Path(__file__).absolute().parent.parent / "docs/source/reference/api" is_supported = [] diff --git a/utils/license-headers.py b/utils/license-headers.py index 993334d9..d501c85e 100644 --- a/utils/license-headers.py +++ b/utils/license-headers.py @@ -23,9 +23,8 @@ import os import sys -from typing import List, Iterator from itertools import chain - +from typing import Iterator, List lines_to_keep = ["# -*- coding: utf-8 -*-\n", "#!/usr/bin/env python\n"] license_header_lines = [