From cffada217d6b17c041a26dbcc0d9292cefa7a341 Mon Sep 17 00:00:00 2001 From: Gaurav Sheni Date: Thu, 7 Dec 2023 10:35:21 -0500 Subject: [PATCH 1/4] update ruff --- .pre-commit-config.yaml | 17 +++++++---------- Makefile | 10 +++++----- pyproject.toml | 8 ++------ 3 files changed, 14 insertions(+), 21 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5948fbad6f..b89b67125b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -25,18 +25,15 @@ repos: hooks: - id: add-trailing-comma name: Add trailing comma - - repo: https://github.com/python/black - rev: 22.12.0 - hooks: - - id: black - args: - - --config=./pyproject.toml - additional_dependencies: [".[jupyter]"] - types_or: [python, jupyter] - repo: https://github.com/charliermarsh/ruff-pre-commit - rev: 'v0.0.239' + rev: 'v0.1.6' hooks: - id: ruff + types_or: [ python, pyi, jupyter ] args: - - --config=./pyproject.toml - --fix + - --config=./pyproject.toml + - id: ruff-format + types_or: [ python, pyi, jupyter ] + args: + - --config=./pyproject.toml diff --git a/Makefile b/Makefile index 0635674e97..e0cf275871 100644 --- a/Makefile +++ b/Makefile @@ -9,14 +9,14 @@ clean: .PHONY: lint lint: python docs/notebook_version_standardizer.py check-execution - black . --config=./pyproject.toml --check - ruff . --config=./pyproject.toml + ruff check . --config=./pyproject.toml + ruff format . --check --config=./pyproject.toml .PHONY: lint-fix lint-fix: python docs/notebook_version_standardizer.py standardize - black . --config=./pyproject.toml - ruff . --fix --config=./pyproject.toml + ruff check . --fix --config=./pyproject.toml + ruff format . --config=./pyproject.toml .PHONY: test test: @@ -61,4 +61,4 @@ package: upgradepip upgradebuild upgradesetuptools python -m build $(eval PACKAGE=$(shell python -c 'import setuptools; setuptools.setup()' --version)) tar -zxvf "dist/featuretools-${PACKAGE}.tar.gz" - mv "featuretools-${PACKAGE}" unpacked_sdist + mv "featuretools-${PACKAGE}" unpacked_sdist \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 101ed7a894..f851b25bab 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -113,7 +113,7 @@ docs = [ "featuretools[sklearn,dask,spark,test]", ] dev = [ - "ruff >= 0.0.239", + "ruff >= 0.1.6", "black[jupyter] >= 23.1.0", "pre-commit >= 2.20.0", "featuretools[docs,dask,spark,test]", @@ -152,7 +152,6 @@ namespaces = true [tool.setuptools.dynamic] version = {attr = "featuretools.version.__version__"} - [tool.pytest.ini_options] addopts = "--doctest-modules --ignore=featuretools/tests/entry_point_tests/add-ons" testpaths = [ @@ -163,12 +162,9 @@ filterwarnings = [ "ignore::PendingDeprecationWarning" ] -[tool.black] -line-length = 88 -target-version = ["py311"] - [tool.ruff] line-length = 88 +target-version = "py311" ignore = ["E501"] select = [ # Pyflakes From 0fa0841ddc39f872b0a32d4f033fadc643b3c651 Mon Sep 17 00:00:00 2001 From: Gaurav Sheni Date: Thu, 7 Dec 2023 10:36:12 -0500 Subject: [PATCH 2/4] run ruff --- .readthedocs.yaml | 2 +- Makefile | 2 +- docs/source/getting_started/primitives.ipynb | 7 +++--- .../guides/advanced_custom_primitives.ipynb | 10 +++++---- docs/source/guides/feature_selection.ipynb | 5 ++--- docs/source/guides/time_series.ipynb | 5 +++-- .../source/guides/using_dask_entitysets.ipynb | 5 +++-- .../guides/using_spark_entitysets.ipynb | 3 ++- .../frequently_asked_questions.ipynb | 13 ++++++----- .../resources/transition_to_ft_v1.0.ipynb | 4 ++-- .../feature_base/feature_descriptions.py | 3 +-- .../synthesis/deep_feature_synthesis.py | 7 ++++-- .../test_rolling_primitive_utils.py | 14 +++++++----- featuretools/utils/recommend_primitives.py | 22 +++++++++---------- 14 files changed, 55 insertions(+), 47 deletions(-) diff --git a/.readthedocs.yaml b/.readthedocs.yaml index b7658c191d..9e1d98e92b 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -20,7 +20,7 @@ build: - graphviz - openjdk-11-jre-headless jobs: - post_build: + post_build: - export JAVA_HOME="/usr/lib/jvm/java-11-openjdk-amd64" python: diff --git a/Makefile b/Makefile index e0cf275871..323ef82282 100644 --- a/Makefile +++ b/Makefile @@ -61,4 +61,4 @@ package: upgradepip upgradebuild upgradesetuptools python -m build $(eval PACKAGE=$(shell python -c 'import setuptools; setuptools.setup()' --version)) tar -zxvf "dist/featuretools-${PACKAGE}.tar.gz" - mv "featuretools-${PACKAGE}" unpacked_sdist \ No newline at end of file + mv "featuretools-${PACKAGE}" unpacked_sdist diff --git a/docs/source/getting_started/primitives.ipynb b/docs/source/getting_started/primitives.ipynb index 5c35c3c5fe..50fcfd851e 100644 --- a/docs/source/getting_started/primitives.ipynb +++ b/docs/source/getting_started/primitives.ipynb @@ -186,11 +186,12 @@ "metadata": {}, "outputs": [], "source": [ - "from featuretools.primitives import AggregationPrimitive, TransformPrimitive\n", - "from featuretools.tests.testing_utils import make_ecommerce_entityset\n", + "import pandas as pd\n", "from woodwork.column_schema import ColumnSchema\n", "from woodwork.logical_types import Datetime, NaturalLanguage\n", - "import pandas as pd" + "\n", + "from featuretools.primitives import AggregationPrimitive, TransformPrimitive\n", + "from featuretools.tests.testing_utils import make_ecommerce_entityset" ] }, { diff --git a/docs/source/guides/advanced_custom_primitives.ipynb b/docs/source/guides/advanced_custom_primitives.ipynb index f57ea18e65..b4418c784a 100644 --- a/docs/source/guides/advanced_custom_primitives.ipynb +++ b/docs/source/guides/advanced_custom_primitives.ipynb @@ -13,13 +13,15 @@ "metadata": {}, "outputs": [], "source": [ - "from featuretools.primitives import TransformPrimitive\n", - "from featuretools.tests.testing_utils import make_ecommerce_entityset\n", + "import re\n", + "\n", + "import numpy as np\n", "from woodwork.column_schema import ColumnSchema\n", "from woodwork.logical_types import Datetime, NaturalLanguage\n", + "\n", "import featuretools as ft\n", - "import numpy as np\n", - "import re" + "from featuretools.primitives import TransformPrimitive\n", + "from featuretools.tests.testing_utils import make_ecommerce_entityset" ] }, { diff --git a/docs/source/guides/feature_selection.ipynb b/docs/source/guides/feature_selection.ipynb index 0df96b4efc..5ce4667e72 100644 --- a/docs/source/guides/feature_selection.ipynb +++ b/docs/source/guides/feature_selection.ipynb @@ -24,16 +24,15 @@ "outputs": [], "source": [ "import pandas as pd\n", - "import featuretools as ft\n", "\n", + "import featuretools as ft\n", + "from featuretools.demo.flight import load_flight\n", "from featuretools.selection import (\n", " remove_highly_correlated_features,\n", " remove_highly_null_features,\n", " remove_single_value_features,\n", ")\n", "\n", - "from featuretools.demo.flight import load_flight\n", - "\n", "es = load_flight(nrows=50)\n", "es" ] diff --git a/docs/source/guides/time_series.ipynb b/docs/source/guides/time_series.ipynb index a434f31fca..0c104849a9 100644 --- a/docs/source/guides/time_series.ipynb +++ b/docs/source/guides/time_series.ipynb @@ -12,10 +12,11 @@ "import warnings\n", "\n", "warnings.filterwarnings(\"ignore\")\n", + "import pandas as pd\n", + "\n", "import featuretools as ft\n", - "from featuretools.primitives import RollingMean, Lag, RollingMin\n", "from featuretools.demo.weather import load_weather\n", - "import pandas as pd" + "from featuretools.primitives import Lag, RollingMean, RollingMin" ] }, { diff --git a/docs/source/guides/using_dask_entitysets.ipynb b/docs/source/guides/using_dask_entitysets.ipynb index 2c4fe3526b..73e2929d3c 100644 --- a/docs/source/guides/using_dask_entitysets.ipynb +++ b/docs/source/guides/using_dask_entitysets.ipynb @@ -42,9 +42,10 @@ "metadata": {}, "outputs": [], "source": [ - "import featuretools as ft\n", - "import pandas as pd\n", "import dask.dataframe as dd\n", + "import pandas as pd\n", + "\n", + "import featuretools as ft\n", "\n", "id = [0, 1, 2, 3, 4]\n", "values = [12, -35, 14, 103, -51]\n", diff --git a/docs/source/guides/using_spark_entitysets.ipynb b/docs/source/guides/using_spark_entitysets.ipynb index 500b895edc..e863b7aaee 100644 --- a/docs/source/guides/using_spark_entitysets.ipynb +++ b/docs/source/guides/using_spark_entitysets.ipynb @@ -64,9 +64,10 @@ "metadata": {}, "outputs": [], "source": [ - "import featuretools as ft\n", "import pyspark.pandas as ps\n", "\n", + "import featuretools as ft\n", + "\n", "ps.set_option(\"compute.default_index_type\", \"distributed\")\n", "\n", "id = [0, 1, 2, 3, 4]\n", diff --git a/docs/source/resources/frequently_asked_questions.ipynb b/docs/source/resources/frequently_asked_questions.ipynb index ea50e0765e..de024d5b33 100644 --- a/docs/source/resources/frequently_asked_questions.ipynb +++ b/docs/source/resources/frequently_asked_questions.ipynb @@ -15,10 +15,10 @@ "metadata": {}, "outputs": [], "source": [ - "import featuretools as ft\n", "import pandas as pd\n", - "import numpy as np\n", - "import woodwork as ww" + "import woodwork as ww\n", + "\n", + "import featuretools as ft" ] }, { @@ -720,7 +720,7 @@ " },\n", " # For mode, ignore the \"sessions\" DataFrame and only include \"brands\" in the\n", " # \"products\" dataframe and \"product_id\" in the \"transactions\" DataFrame\n", - " (\"count\", \"mean\"): {\"include_dataframes\": [\"sessions\", \"transactions\"]}\n", + " (\"count\", \"mean\"): {\"include_dataframes\": [\"sessions\", \"transactions\"]},\n", " # For count and mean, only include the dataframes \"sessions\" and \"transactions\"\n", " },\n", ")" @@ -1472,6 +1472,7 @@ "outputs": [], "source": [ "import pandas as pd\n", + "\n", "import featuretools as ft\n", "\n", "df = pd.DataFrame(\n", @@ -1689,9 +1690,9 @@ "source": [ "from featuretools.primitives import (\n", " TimeSince,\n", - " TimeSincePrevious,\n", - " TimeSinceLast,\n", " TimeSinceFirst,\n", + " TimeSinceLast,\n", + " TimeSincePrevious,\n", ")\n", "\n", "time_since = TimeSince(unit=\"minutes\")\n", diff --git a/docs/source/resources/transition_to_ft_v1.0.ipynb b/docs/source/resources/transition_to_ft_v1.0.ipynb index 6be14130d4..f10b39faf6 100644 --- a/docs/source/resources/transition_to_ft_v1.0.ipynb +++ b/docs/source/resources/transition_to_ft_v1.0.ipynb @@ -98,9 +98,9 @@ "metadata": {}, "outputs": [], "source": [ - "import featuretools as ft\n", "import pandas as pd\n", - "import woodwork as ww" + "\n", + "import featuretools as ft" ] }, { diff --git a/featuretools/feature_base/feature_descriptions.py b/featuretools/feature_base/feature_descriptions.py index cd7199f59c..b3be510436 100644 --- a/featuretools/feature_base/feature_descriptions.py +++ b/featuretools/feature_base/feature_descriptions.py @@ -148,8 +148,7 @@ def generate_description(feature, feature_descriptions, primitive_templates): def get_direct_description(feature): direct_description = ( - ' the instance of "{}" associated with this ' - 'instance of "{}"'.format( + ' the instance of "{}" associated with this ' 'instance of "{}"'.format( feature.relationship_path[-1][1].parent_dataframe.ww.name, feature.dataframe_name, ) diff --git a/featuretools/synthesis/deep_feature_synthesis.py b/featuretools/synthesis/deep_feature_synthesis.py index 2c29cc2460..36c1944dde 100644 --- a/featuretools/synthesis/deep_feature_synthesis.py +++ b/featuretools/synthesis/deep_feature_synthesis.py @@ -1290,8 +1290,11 @@ def check_primitive( primitive = handle_primitive(primitive) if not isinstance(primitive, supertype): raise ValueError( - "Primitive {} in {} is not {} " - "primitive".format(type(primitive), arg_name, s), + "Primitive {} in {} is not {} " "primitive".format( + type(primitive), + arg_name, + s, + ), ) return primitive diff --git a/featuretools/tests/primitive_tests/test_rolling_primitive_utils.py b/featuretools/tests/primitive_tests/test_rolling_primitive_utils.py index b3e277f7c7..1b8c94b0c5 100644 --- a/featuretools/tests/primitive_tests/test_rolling_primitive_utils.py +++ b/featuretools/tests/primitive_tests/test_rolling_primitive_utils.py @@ -542,12 +542,14 @@ def count_wrapper(sub_s): def test_roll_series_with_gap_incorrect_types(window_series_pd): error = "Window length must be either an offset string or an integer." with pytest.raises(TypeError, match=error): - roll_series_with_gap( - window_series_pd, - window_length=4.2, - gap=4, - min_periods=1, - ), + ( + roll_series_with_gap( + window_series_pd, + window_length=4.2, + gap=4, + min_periods=1, + ), + ) error = "Gap must be either an offset string or an integer." with pytest.raises(TypeError, match=error): diff --git a/featuretools/utils/recommend_primitives.py b/featuretools/utils/recommend_primitives.py index 6859d34e92..a3a172264b 100644 --- a/featuretools/utils/recommend_primitives.py +++ b/featuretools/utils/recommend_primitives.py @@ -6,18 +6,16 @@ from featuretools.primitives.utils import get_transform_primitives from featuretools.synthesis import dfs, get_valid_primitives -ORDERED_PRIMITIVES = ( - [ # non-numeric primitives that require specific ordering or a time index to be set - "cum_count", - "cumulative_time_since_last_false", - "cumulative_time_since_last_true", - "diff", - "diff_datetime", - "is_first_occurrence", - "is_last_occurrence", - "time_since_previous", - ] -) +ORDERED_PRIMITIVES = [ # non-numeric primitives that require specific ordering or a time index to be set + "cum_count", + "cumulative_time_since_last_false", + "cumulative_time_since_last_true", + "diff", + "diff_datetime", + "is_first_occurrence", + "is_last_occurrence", + "time_since_previous", +] DEPRECATED_PRIMITIVES = [ From dcd346e72058ee1442c09701948767618973cfb3 Mon Sep 17 00:00:00 2001 From: Gaurav Sheni Date: Thu, 7 Dec 2023 10:38:18 -0500 Subject: [PATCH 3/4] run ruff --- docs/source/release_notes.rst | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/source/release_notes.rst b/docs/source/release_notes.rst index 07513fe37d..5c06d2c976 100644 --- a/docs/source/release_notes.rst +++ b/docs/source/release_notes.rst @@ -11,9 +11,10 @@ Future Release * Documentation Changes * Testing Changes * Update tests for compatibility with new versions of ``holidays`` (:pr:`2636`) + * Update ruff to 0.1.6 and use ruff linter/formatter (:pr:`2638`) - Thanks to the following people for contributing to this release: - :user:`thehomebrewnerd` + Thanks to the following people for contributing to this release: + :user:`gsheni`, :user:`thehomebrewnerd` v1.28.0 Oct 26, 2023 From c06567d91e2c8d3d9d31c34bacd02aa37200434b Mon Sep 17 00:00:00 2001 From: Gaurav Sheni Date: Thu, 7 Dec 2023 11:05:14 -0500 Subject: [PATCH 4/4] release notes --- docs/source/release_notes.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/release_notes.rst b/docs/source/release_notes.rst index 5c06d2c976..52dab62597 100644 --- a/docs/source/release_notes.rst +++ b/docs/source/release_notes.rst @@ -11,7 +11,7 @@ Future Release * Documentation Changes * Testing Changes * Update tests for compatibility with new versions of ``holidays`` (:pr:`2636`) - * Update ruff to 0.1.6 and use ruff linter/formatter (:pr:`2638`) + * Update ruff to 0.1.6 and use ruff linter/formatter (:pr:`2639`) Thanks to the following people for contributing to this release: :user:`gsheni`, :user:`thehomebrewnerd`