From 05a24cbe0b5bcc1a967e68ea950215e9bd14d51e Mon Sep 17 00:00:00 2001 From: Seth Michael Larson Date: Thu, 15 Oct 2020 16:46:21 -0500 Subject: [PATCH] Add isort, rename Nox session to 'format' --- CONTRIBUTING.md | 2 +- docs/source/conf.py | 8 ++--- eland/__init__.py | 22 ++++++------- eland/actions.py | 4 +-- eland/arithmetics.py | 2 +- eland/common.py | 2 +- eland/dataframe.py | 10 +++--- eland/etl.py | 9 +++--- eland/field_mappings.py | 27 ++++++++-------- eland/filter.py | 2 +- eland/groupby.py | 3 +- eland/index.py | 3 +- eland/ml/__init__.py | 2 +- eland/ml/_model_serializer.py | 2 +- eland/ml/ml_model.py | 25 ++++++++++----- eland/ml/transformers/__init__.py | 16 +++++----- eland/ml/transformers/base.py | 3 +- eland/ml/transformers/lightgbm.py | 9 +++--- eland/ml/transformers/sklearn.py | 15 ++++++--- eland/ml/transformers/xgboost.py | 10 +++--- eland/ndframe.py | 7 ++-- eland/operations.py | 32 +++++++++---------- eland/plotting/__init__.py | 5 +-- eland/plotting/_core.py | 2 +- eland/plotting/_matplotlib/__init__.py | 5 +-- eland/plotting/_matplotlib/hist.py | 1 + eland/query.py | 11 ++----- eland/query_compiler.py | 12 +++---- eland/series.py | 15 +++++---- eland/tasks.py | 8 ++--- eland/tests/__init__.py | 1 + eland/tests/common.py | 4 +-- eland/tests/conftest.py | 23 +++++++------ eland/tests/dataframe/test_aggs_pytest.py | 3 +- .../dataframe/test_big_mapping_pytest.py | 3 +- eland/tests/dataframe/test_datetime_pytest.py | 10 +++--- eland/tests/dataframe/test_dtypes_pytest.py | 1 + eland/tests/dataframe/test_es_query_pytest.py | 4 +-- eland/tests/dataframe/test_filter_pytest.py | 1 + eland/tests/dataframe/test_groupby_pytest.py | 3 +- .../tests/dataframe/test_head_tail_pytest.py | 3 +- eland/tests/dataframe/test_info_pytest.py | 2 -- eland/tests/dataframe/test_init_pytest.py | 3 +- eland/tests/dataframe/test_metrics_pytest.py | 6 ++-- eland/tests/dataframe/test_query_pytest.py | 4 +-- eland/tests/dataframe/test_sample_pytest.py | 2 +- .../dataframe/test_select_dtypes_pytest.py | 3 +- eland/tests/dataframe/test_to_csv_pytest.py | 6 ++-- eland/tests/dataframe/test_utils_pytest.py | 3 +- eland/tests/etl/test_pandas_to_eland.py | 6 ++-- .../test_aggregatables_pytest.py | 2 +- .../field_mappings/test_datetime_pytest.py | 3 +- .../test_field_name_pd_dtype_pytest.py | 3 +- .../test_get_field_names_pytest.py | 2 +- .../test_metric_source_fields_pytest.py | 2 +- .../test_scripted_fields_pytest.py | 2 +- .../tests/ml/test_imported_ml_model_pytest.py | 9 +++--- .../tests/operators/test_operators_pytest.py | 10 +++--- eland/tests/series/test_describe_pytest.py | 1 + eland/tests/series/test_dtype_pytest.py | 6 ++-- eland/tests/series/test_filter_pytest.py | 4 +-- eland/tests/series/test_head_tail_pytest.py | 6 ++-- eland/tests/series/test_metrics_pytest.py | 7 ++-- eland/tests/series/test_na_pytest.py | 3 +- eland/tests/series/test_name_pytest.py | 6 ++-- eland/tests/series/test_rename_pytest.py | 6 ++-- eland/tests/series/test_repr_pytest.py | 3 +- eland/tests/series/test_sample_pytest.py | 6 ++-- eland/tests/setup_tests.py | 17 +++++----- eland/utils.py | 6 ++-- noxfile.py | 12 ++++--- setup.cfg | 2 ++ setup.py | 2 +- utils/generate-supported-apis.py | 7 ++-- utils/license-headers.py | 3 +- 75 files changed, 252 insertions(+), 243 deletions(-) create mode 100644 setup.cfg diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 7d85db3..e5c0889 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 65560de..2ad5011 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 0c9ba02..640b18a 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 6da1751..d9f4306 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 e8d923b..b9d1b80 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 772457a..647d598 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 5eea876..89e110c 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.io.formats.printing import pprint_thing 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 e24b396..00e6c0f 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 5601827..7754d29 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 ea77929..3cc5806 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 b9979dd..3679a8c 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 08588f7..3a130ad 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 5326bc3..3b65062 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 976a85c..da45a00 100644 --- a/eland/ml/_model_serializer.py +++ b/eland/ml/_model_serializer.py @@ -19,7 +19,7 @@ import base64 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 50d6473..3ca0894 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 76a72bb..7c56f39 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 @@ except ImportError: 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 @@ except ImportError: pass try: + from .lightgbm import _MODEL_TRANSFORMERS as _LIGHTGBM_MODEL_TRANSFORMERS from .lightgbm import ( - LGBMRegressor, LGBMClassifier, - LGBMForestTransformer, - LGBMRegressorTransformer, LGBMClassifierTransformer, - _MODEL_TRANSFORMERS as _LIGHTGBM_MODEL_TRANSFORMERS, + LGBMForestTransformer, + LGBMRegressor, + LGBMRegressorTransformer, ) __all__ += [ diff --git a/eland/ml/transformers/base.py b/eland/ml/transformers/base.py index d251108..a9f4fdc 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 218249c..8e96957 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 79c999e..303f5ec 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 4adb4d2..5d4e85e 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 e55f557..17ef288 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 -import pandas as pd -from eland.query_compiler import QueryCompiler +from typing import TYPE_CHECKING, Optional, Tuple +import pandas as pd + +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 63fcf89..7025156 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 61c16a0..571191f 100644 --- a/eland/plotting/__init__.py +++ b/eland/plotting/__init__.py @@ -22,10 +22,7 @@ Based from https://github.com/pandas-dev/pandas/blob/v0.25.3/pandas/plotting/__i 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 26951bb..2f402fe 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 3af3026..15d74ec 100644 --- a/eland/plotting/_matplotlib/__init__.py +++ b/eland/plotting/_matplotlib/__init__.py @@ -22,10 +22,7 @@ Based from https://github.com/pandas-dev/pandas/blob/v0.25.3/pandas/plotting/__i 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 197d9b9..f3b3341 100644 --- a/eland/plotting/_matplotlib/hist.py +++ b/eland/plotting/_matplotlib/hist.py @@ -19,6 +19,7 @@ import numpy as np 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 3c2ad1b..8d55fa2 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 typing import Any, Dict, List, Optional -from eland.filter import ( - RandomScoreFilter, - BooleanFilter, - NotNull, - IsNull, - IsIn, - Rlike, -) +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 f1a4240..956e402 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 fcf2173..3004693 100644 --- a/eland/series.py +++ b/eland/series.py @@ -35,33 +35,34 @@ import sys 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 f2b5b39..fff7ec0 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 eb0b155..7b0ba96 100644 --- a/eland/tests/__init__.py +++ b/eland/tests/__init__.py @@ -19,6 +19,7 @@ import os 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 8bc4e86..21553ce 100644 --- a/eland/tests/common.py +++ b/eland/tests/common.py @@ -26,12 +26,12 @@ ROOT_DIR = os.path.dirname(os.path.abspath(__file__)) # 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 525862c..680942f 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 ( + TestData, + _ed_ecommerce, + _ed_flights, + _ed_flights_small, + _pd_ecommerce, + _pd_flights, + _pd_flights_small, + assert_frame_equal, assert_pandas_eland_frame_equal, assert_pandas_eland_series_equal, - assert_frame_equal, assert_series_equal, - _ed_flights, - _pd_flights, - _ed_ecommerce, - _pd_ecommerce, - _ed_flights_small, - _pd_flights_small, - TestData, ) -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 e483f47..54b05a2 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 de268f9..425365c 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 b523e56..99ae51a 100644 --- a/eland/tests/dataframe/test_datetime_pytest.py +++ b/eland/tests/dataframe/test_datetime_pytest.py @@ -24,10 +24,12 @@ from pandas.testing import assert_series_equal 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 fd0630c..729d963 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 95e24dd..fe9429a 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 9524e17..9fdc7a2 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 3cdd48a..3ae95a0 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 829159b..ec1f0a4 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 b715102..6b38a0a 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 b8c5aa1..e33dd6b 100644 --- a/eland/tests/dataframe/test_init_pytest.py +++ b/eland/tests/dataframe/test_init_pytest.py @@ -21,8 +21,7 @@ import pytest 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 dbef894..d3d5785 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 97a9eeb..321f351 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 9a4a575..3345126 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 d00ae17..738bf3b 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 5ca5048..bb9560f 100644 --- a/eland/tests/dataframe/test_to_csv_pytest.py +++ b/eland/tests/dataframe/test_to_csv_pytest.py @@ -24,10 +24,8 @@ import pandas as pd 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 fa5985a..e1b57c3 100644 --- a/eland/tests/dataframe/test_utils_pytest.py +++ b/eland/tests/dataframe/test_utils_pytest.py @@ -22,8 +22,7 @@ import pandas as pd 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 2ffb01b..e4a054a 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 2f4a62f..c6af0a3 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 4ce575a..447381e 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 30bdc34..94efe2c 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 pandas.testing import assert_series_equal 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 c56ccda..59bdd38 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 @@ from pandas.testing import assert_index_equal # 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 6cf8001..9c4e2c9 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 f2f276a..0e3d4f9 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 @@ from io import StringIO 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 d9ca4a4..9e8445d 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 @@ except ImportError: 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 0b7cb61..7fe602c 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 2f6f6ec..2f255eb 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 eb00c98..4c45531 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 052ef9a..9da03c7 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 49cb83c..93c1d3f 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 d8e213d..01ce34a 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 d9267b9..a11c91c 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 3720916..619aa9c 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 ae970c0..b99b9bb 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 f1da73d..61c103c 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 8de43e3..184e4b3 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 b858c64..a507523 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 ( - FLIGHTS_FILE_NAME, - FLIGHTS_INDEX_NAME, - FLIGHTS_SMALL_FILE_NAME, - FLIGHTS_SMALL_INDEX_NAME, - FLIGHTS_MAPPING, 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, 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 66bf586..de63e19 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 fe8ec11..52517f5 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 @@ TYPED_FILES = ( @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 0000000..c76db01 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,2 @@ +[isort] +profile = black diff --git a/setup.py b/setup.py index 450a7be..8b36258 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 58020da..ba4b939 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 993334d..d501c85 100644 --- a/utils/license-headers.py +++ b/utils/license-headers.py @@ -23,9 +23,8 @@ error out if 'fix' would have changed the file. 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 = [