Skip to content

Commit 75c9783

Browse files
basnijholtTomAugspurger
authored andcommitted
STYLE: run pre-commit filters on the repo (pandas-dev#27915)
* add isort:skip to "from .pandas_vb_common import setup" * add isort:skip to noqa: E402 marked lines * run black * add noqa: E402 isort:skip where needed * run pre-commit filters on asv_bench/benchmarks/ * parse the isort config when using pre-commit * run isort on pandas/core/api.py * run pre-commit filters and commit trivial import sorting changes * specify flake8 errors in pandas/io/msgpack/__init__.py * fix imports for doc/source/conf.py * fix the [isort] skip entry in setup.cfg Also I removed the files for which I have fixed the problems.
1 parent 51db82d commit 75c9783

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+255
-248
lines changed

.pre-commit-config.yaml

+20-16
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
11
repos:
2-
- repo: https://github.com/python/black
3-
rev: stable
4-
hooks:
5-
- id: black
6-
language_version: python3.7
7-
- repo: https://gitlab.com/pycqa/flake8
8-
rev: 3.7.7
9-
hooks:
10-
- id: flake8
11-
language: python_venv
12-
additional_dependencies: [flake8-comprehensions]
13-
- repo: https://github.com/pre-commit/mirrors-isort
14-
rev: v4.3.20
15-
hooks:
16-
- id: isort
17-
language: python_venv
2+
- repo: https://github.com/python/black
3+
rev: stable
4+
hooks:
5+
- id: black
6+
language_version: python3.7
7+
- repo: https://gitlab.com/pycqa/flake8
8+
rev: 3.7.7
9+
hooks:
10+
- id: flake8
11+
language: python_venv
12+
additional_dependencies: [flake8-comprehensions]
13+
- repo: https://github.com/pre-commit/mirrors-isort
14+
rev: v4.3.20
15+
hooks:
16+
- id: isort
17+
language: python_venv
18+
- repo: https://github.com/asottile/seed-isort-config
19+
rev: v1.9.2
20+
hooks:
21+
- id: seed-isort-config

asv_bench/benchmarks/attrs_caching.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import numpy as np
2+
23
from pandas import DataFrame
34

45
try:
@@ -32,4 +33,4 @@ def time_cache_readonly(self):
3233
self.obj.prop
3334

3435

35-
from .pandas_vb_common import setup # noqa: F401
36+
from .pandas_vb_common import setup # noqa: F401 isort:skip

asv_bench/benchmarks/binary_ops.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import numpy as np
2+
23
from pandas import DataFrame, Series, date_range
34
from pandas.core.algorithms import checked_add_with_arr
45

@@ -155,4 +156,4 @@ def time_add_overflow_both_arg_nan(self):
155156
)
156157

157158

158-
from .pandas_vb_common import setup # noqa: F401
159+
from .pandas_vb_common import setup # noqa: F401 isort:skip

asv_bench/benchmarks/categoricals.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
import warnings
2+
13
import numpy as np
4+
25
import pandas as pd
36
import pandas.util.testing as tm
4-
import warnings
57

68
try:
79
from pandas.api.types import union_categoricals
@@ -280,4 +282,4 @@ def time_sort_values(self):
280282
self.index.sort_values(ascending=False)
281283

282284

283-
from .pandas_vb_common import setup # noqa: F401
285+
from .pandas_vb_common import setup # noqa: F401 isort:skip

asv_bench/benchmarks/ctors.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import numpy as np
2+
3+
from pandas import DatetimeIndex, Index, MultiIndex, Series, Timestamp
24
import pandas.util.testing as tm
3-
from pandas import Series, Index, DatetimeIndex, Timestamp, MultiIndex
45

56

67
def no_change(arr):
@@ -113,4 +114,4 @@ def time_multiindex_from_iterables(self):
113114
MultiIndex.from_product(self.iterables)
114115

115116

116-
from .pandas_vb_common import setup # noqa: F401
117+
from .pandas_vb_common import setup # noqa: F401 isort:skip

asv_bench/benchmarks/dtypes.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1+
import numpy as np
2+
13
from pandas.api.types import pandas_dtype
24

3-
import numpy as np
45
from .pandas_vb_common import (
5-
numeric_dtypes,
66
datetime_dtypes,
7-
string_dtypes,
87
extension_dtypes,
8+
numeric_dtypes,
9+
string_dtypes,
910
)
1011

11-
1212
_numpy_dtypes = [
1313
np.dtype(dtype) for dtype in (numeric_dtypes + datetime_dtypes + string_dtypes)
1414
]
@@ -40,4 +40,4 @@ def time_pandas_dtype_invalid(self, dtype):
4040
pass
4141

4242

43-
from .pandas_vb_common import setup # noqa: F401
43+
from .pandas_vb_common import setup # noqa: F401 isort:skip

asv_bench/benchmarks/eval.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import numpy as np
2+
23
import pandas as pd
34

45
try:
@@ -62,4 +63,4 @@ def time_query_with_boolean_selection(self):
6263
self.df.query("(a >= @self.min_val) & (a <= @self.max_val)")
6364

6465

65-
from .pandas_vb_common import setup # noqa: F401
66+
from .pandas_vb_common import setup # noqa: F401 isort:skip

asv_bench/benchmarks/frame_ctor.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import numpy as np
2+
3+
from pandas import DataFrame, MultiIndex, Series, Timestamp, date_range
24
import pandas.util.testing as tm
3-
from pandas import DataFrame, Series, MultiIndex, Timestamp, date_range
45

56
try:
67
from pandas.tseries.offsets import Nano, Hour
@@ -104,4 +105,4 @@ def time_frame_from_lists(self):
104105
self.df = DataFrame(self.data)
105106

106107

107-
from .pandas_vb_common import setup # noqa: F401
108+
from .pandas_vb_common import setup # noqa: F401 isort:skip

asv_bench/benchmarks/frame_methods.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import warnings
21
import string
2+
import warnings
33

44
import numpy as np
55

@@ -609,4 +609,4 @@ def time_dataframe_describe(self):
609609
self.df.describe()
610610

611611

612-
from .pandas_vb_common import setup # noqa: F401
612+
from .pandas_vb_common import setup # noqa: F401 isort:skip

asv_bench/benchmarks/gil.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import numpy as np
2-
import pandas.util.testing as tm
3-
from pandas import DataFrame, Series, read_csv, factorize, date_range
2+
3+
from pandas import DataFrame, Series, date_range, factorize, read_csv
44
from pandas.core.algorithms import take_1d
5+
import pandas.util.testing as tm
56

67
try:
78
from pandas import (
@@ -36,7 +37,7 @@ def wrapper(fname):
3637
return wrapper
3738

3839

39-
from .pandas_vb_common import BaseIO
40+
from .pandas_vb_common import BaseIO # noqa: E402 isort:skip
4041

4142

4243
class ParallelGroupbyMethods:
@@ -301,4 +302,4 @@ def time_loop(self, threads):
301302
self.loop()
302303

303304

304-
from .pandas_vb_common import setup # noqa: F401
305+
from .pandas_vb_common import setup # noqa: F401 isort:skip

asv_bench/benchmarks/groupby.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
)
1616
import pandas.util.testing as tm
1717

18-
1918
method_blacklist = {
2019
"object": {
2120
"median",
@@ -626,4 +625,4 @@ def time_first(self):
626625
self.df_nans.groupby("key").transform("first")
627626

628627

629-
from .pandas_vb_common import setup # noqa: F401
628+
from .pandas_vb_common import setup # noqa: F401 isort:skip

asv_bench/benchmarks/index_object.py

+8-6
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
import gc
2+
23
import numpy as np
3-
import pandas.util.testing as tm
4+
45
from pandas import (
5-
Series,
6-
date_range,
76
DatetimeIndex,
8-
Index,
9-
RangeIndex,
107
Float64Index,
8+
Index,
119
IntervalIndex,
10+
RangeIndex,
11+
Series,
12+
date_range,
1213
)
14+
import pandas.util.testing as tm
1315

1416

1517
class SetOperations:
@@ -243,4 +245,4 @@ def peakmem_gc_instances(self, N):
243245
gc.enable()
244246

245247

246-
from .pandas_vb_common import setup # noqa: F401
248+
from .pandas_vb_common import setup # noqa: F401 isort:skip

asv_bench/benchmarks/indexing.py

+9-8
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
11
import warnings
22

33
import numpy as np
4-
import pandas.util.testing as tm
4+
55
from pandas import (
6-
Series,
6+
CategoricalIndex,
77
DataFrame,
8-
MultiIndex,
9-
Int64Index,
10-
UInt64Index,
118
Float64Index,
12-
IntervalIndex,
13-
CategoricalIndex,
149
IndexSlice,
10+
Int64Index,
11+
IntervalIndex,
12+
MultiIndex,
13+
Series,
14+
UInt64Index,
1515
concat,
1616
date_range,
1717
option_context,
1818
period_range,
1919
)
20+
import pandas.util.testing as tm
2021

2122

2223
class NumericSeriesIndexing:
@@ -371,4 +372,4 @@ def time_chained_indexing(self, mode):
371372
df2["C"] = 1.0
372373

373374

374-
from .pandas_vb_common import setup # noqa: F401
375+
from .pandas_vb_common import setup # noqa: F401 isort:skip

asv_bench/benchmarks/inference.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import numpy as np
2-
import pandas.util.testing as tm
2+
33
from pandas import DataFrame, Series, to_numeric
4+
import pandas.util.testing as tm
45

5-
from .pandas_vb_common import numeric_dtypes, lib
6+
from .pandas_vb_common import lib, numeric_dtypes
67

78

89
class NumericInferOps:
@@ -120,4 +121,4 @@ def time_convert(self, data):
120121
lib.maybe_convert_numeric(data, set(), coerce_numeric=False)
121122

122123

123-
from .pandas_vb_common import setup # noqa: F401
124+
from .pandas_vb_common import setup # noqa: F401 isort:skip

asv_bench/benchmarks/io/csv.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1+
from io import StringIO
12
import random
23
import string
34

45
import numpy as np
6+
7+
from pandas import Categorical, DataFrame, date_range, read_csv, to_datetime
58
import pandas.util.testing as tm
6-
from pandas import DataFrame, Categorical, date_range, read_csv, to_datetime
7-
from io import StringIO
89

910
from ..pandas_vb_common import BaseIO
1011

@@ -406,4 +407,4 @@ def time_to_datetime_format_DD_MM_YYYY(self, cache_dates):
406407
to_datetime(df["date"], cache=cache_dates, format="%d-%m-%Y")
407408

408409

409-
from ..pandas_vb_common import setup # noqa: F401
410+
from ..pandas_vb_common import setup # noqa: F401 isort:skip

asv_bench/benchmarks/io/excel.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
from io import BytesIO
2+
23
import numpy as np
3-
from pandas import DataFrame, date_range, ExcelWriter, read_excel
4+
5+
from pandas import DataFrame, ExcelWriter, date_range, read_excel
46
import pandas.util.testing as tm
57

68

@@ -35,4 +37,4 @@ def time_write_excel(self, engine):
3537
writer_write.save()
3638

3739

38-
from ..pandas_vb_common import setup # noqa: F401
40+
from ..pandas_vb_common import setup # noqa: F401 isort:skip

asv_bench/benchmarks/io/hdf.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import numpy as np
2-
from pandas import DataFrame, date_range, HDFStore, read_hdf
2+
3+
from pandas import DataFrame, HDFStore, date_range, read_hdf
34
import pandas.util.testing as tm
45

56
from ..pandas_vb_common import BaseIO
@@ -127,4 +128,4 @@ def time_write_hdf(self, format):
127128
self.df.to_hdf(self.fname, "df", format=format)
128129

129130

130-
from ..pandas_vb_common import setup # noqa: F401
131+
from ..pandas_vb_common import setup # noqa: F401 isort:skip

asv_bench/benchmarks/io/json.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import numpy as np
2+
3+
from pandas import DataFrame, concat, date_range, read_json, timedelta_range
24
import pandas.util.testing as tm
3-
from pandas import DataFrame, date_range, timedelta_range, concat, read_json
45

56
from ..pandas_vb_common import BaseIO
67

@@ -214,4 +215,4 @@ def peakmem_float(self, frames):
214215
df.to_json()
215216

216217

217-
from ..pandas_vb_common import setup # noqa: F401
218+
from ..pandas_vb_common import setup # noqa: F401 isort:skip

asv_bench/benchmarks/io/msgpack.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import warnings
2+
23
import numpy as np
4+
35
from pandas import DataFrame, date_range, read_msgpack
46
import pandas.util.testing as tm
57

@@ -27,4 +29,4 @@ def time_write_msgpack(self):
2729
self.df.to_msgpack(self.fname)
2830

2931

30-
from ..pandas_vb_common import setup # noqa: F401
32+
from ..pandas_vb_common import setup # noqa: F401 isort:skip

asv_bench/benchmarks/io/pickle.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import numpy as np
2+
23
from pandas import DataFrame, date_range, read_pickle
34
import pandas.util.testing as tm
45

@@ -25,4 +26,4 @@ def time_write_pickle(self):
2526
self.df.to_pickle(self.fname)
2627

2728

28-
from ..pandas_vb_common import setup # noqa: F401
29+
from ..pandas_vb_common import setup # noqa: F401 isort:skip

asv_bench/benchmarks/io/sql.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import sqlite3
22

33
import numpy as np
4-
import pandas.util.testing as tm
5-
from pandas import DataFrame, date_range, read_sql_query, read_sql_table
64
from sqlalchemy import create_engine
75

6+
from pandas import DataFrame, date_range, read_sql_query, read_sql_table
7+
import pandas.util.testing as tm
8+
89

910
class SQL:
1011

@@ -141,4 +142,4 @@ def time_read_sql_table_column(self, dtype):
141142
read_sql_table(self.table_name, self.con, columns=[dtype])
142143

143144

144-
from ..pandas_vb_common import setup # noqa: F401
145+
from ..pandas_vb_common import setup # noqa: F401 isort:skip

0 commit comments

Comments
 (0)