Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove black with ruff formatter #2639

Merged
merged 4 commits into from
Dec 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 7 additions & 10 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
7 changes: 4 additions & 3 deletions docs/source/getting_started/primitives.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
},
{
Expand Down
10 changes: 6 additions & 4 deletions docs/source/guides/advanced_custom_primitives.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
},
{
Expand Down
5 changes: 2 additions & 3 deletions docs/source/guides/feature_selection.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
Expand Down
5 changes: 3 additions & 2 deletions docs/source/guides/time_series.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
},
{
Expand Down
5 changes: 3 additions & 2 deletions docs/source/guides/using_dask_entitysets.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
3 changes: 2 additions & 1 deletion docs/source/guides/using_spark_entitysets.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
5 changes: 3 additions & 2 deletions docs/source/release_notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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:`2639`)

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
Expand Down
13 changes: 7 additions & 6 deletions docs/source/resources/frequently_asked_questions.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
},
{
Expand Down Expand Up @@ -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",
")"
Expand Down Expand Up @@ -1472,6 +1472,7 @@
"outputs": [],
"source": [
"import pandas as pd\n",
"\n",
"import featuretools as ft\n",
"\n",
"df = pd.DataFrame(\n",
Expand Down Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions docs/source/resources/transition_to_ft_v1.0.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
},
{
Expand Down
3 changes: 1 addition & 2 deletions featuretools/feature_base/feature_descriptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand Down
7 changes: 5 additions & 2 deletions featuretools/synthesis/deep_feature_synthesis.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
22 changes: 10 additions & 12 deletions featuretools/utils/recommend_primitives.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down
8 changes: 2 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]",
Expand Down Expand Up @@ -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 = [
Expand All @@ -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
Expand Down
Loading