Skip to content

Commit 60b4400

Browse files
STYLE: upgrade flake8 (#48069)
* ⬆️ UPGRADE: Autoupdate pre-commit config * sync flake8 version * update flake8-pyi version * remove flake8-comprehensions (unnecessary since pyupgrade) * bump bugbear * GH48061 set flake8 bugbear errors (B019, B020, B023) to ignore * GH48061 fix flake8 character length (E501) errors Co-authored-by: MarcoGorelli <[email protected]> Co-authored-by: Marco Gorelli <[email protected]>
1 parent 96fe059 commit 60b4400

File tree

7 files changed

+23
-20
lines changed

7 files changed

+23
-20
lines changed

.pre-commit-config.yaml

+7-8
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ repos:
1111
- id: absolufy-imports
1212
files: ^pandas/
1313
- repo: https://github.com/jendrikseipp/vulture
14-
rev: 'v2.4'
14+
rev: 'v2.5'
1515
hooks:
1616
- id: vulture
1717
entry: python scripts/run_vulture.py
@@ -46,20 +46,19 @@ repos:
4646
exclude: ^pandas/_libs/src/(klib|headers)/
4747
args: [--quiet, '--extensions=c,h', '--headers=h', --recursive, '--filter=-readability/casting,-runtime/int,-build/include_subdir']
4848
- repo: https://github.com/PyCQA/flake8
49-
rev: 4.0.1
49+
rev: 5.0.4
5050
hooks:
5151
- id: flake8
5252
additional_dependencies: &flake8_dependencies
53-
- flake8==4.0.1
54-
- flake8-comprehensions==3.7.0
55-
- flake8-bugbear==21.3.2
53+
- flake8==5.0.4
54+
- flake8-bugbear==22.7.1
5655
- pandas-dev-flaker==0.5.0
5756
- repo: https://github.com/PyCQA/isort
5857
rev: 5.10.1
5958
hooks:
6059
- id: isort
6160
- repo: https://github.com/asottile/pyupgrade
62-
rev: v2.34.0
61+
rev: v2.37.3
6362
hooks:
6463
- id: pyupgrade
6564
args: [--py38-plus]
@@ -239,8 +238,8 @@ repos:
239238
types: [pyi]
240239
language: python
241240
additional_dependencies:
242-
- flake8==4.0.1
243-
- flake8-pyi==22.7.0
241+
- flake8==5.0.4
242+
- flake8-pyi==22.8.1
244243
- id: future-annotations
245244
name: import annotations from __future__
246245
entry: 'from __future__ import annotations'

environment.yml

+2-3
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,8 @@ dependencies:
8585
# code checks
8686
- black=22.3.0
8787
- cpplint
88-
- flake8=4.0.1
89-
- flake8-bugbear=21.3.2 # used by flake8, find likely bugs
90-
- flake8-comprehensions=3.7.0 # used by flake8, linting of unnecessary comprehensions
88+
- flake8=5.0.4
89+
- flake8-bugbear=22.7.1 # used by flake8, find likely bugs
9190
- isort>=5.2.1 # check that imports are in the right order
9291
- mypy=0.971
9392
- pre-commit>=2.15.0

pandas/tests/arrays/categorical/test_repr.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ def test_categorical_repr_timedelta(self):
319319

320320
c = Categorical(idx.append(idx), categories=idx)
321321
exp = """[1 days, 2 days, 3 days, 4 days, 5 days, 1 days, 2 days, 3 days, 4 days, 5 days]
322-
Categories (5, timedelta64[ns]): [1 days, 2 days, 3 days, 4 days, 5 days]"""
322+
Categories (5, timedelta64[ns]): [1 days, 2 days, 3 days, 4 days, 5 days]""" # noqa:E501
323323

324324
assert repr(c) == exp
325325

@@ -352,7 +352,7 @@ def test_categorical_repr_timedelta_ordered(self):
352352

353353
c = Categorical(idx.append(idx), categories=idx, ordered=True)
354354
exp = """[1 days, 2 days, 3 days, 4 days, 5 days, 1 days, 2 days, 3 days, 4 days, 5 days]
355-
Categories (5, timedelta64[ns]): [1 days < 2 days < 3 days < 4 days < 5 days]"""
355+
Categories (5, timedelta64[ns]): [1 days < 2 days < 3 days < 4 days < 5 days]""" # noqa:E501
356356

357357
assert repr(c) == exp
358358

pandas/tests/indexes/categorical/test_formats.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def test_string_categorical_index_repr(self):
2424
expected = """CategoricalIndex(['a', 'bb', 'ccc', 'a', 'bb', 'ccc', 'a', 'bb', 'ccc', 'a',
2525
'bb', 'ccc', 'a', 'bb', 'ccc', 'a', 'bb', 'ccc', 'a', 'bb',
2626
'ccc', 'a', 'bb', 'ccc', 'a', 'bb', 'ccc', 'a', 'bb', 'ccc'],
27-
categories=['a', 'bb', 'ccc'], ordered=False, dtype='category')"""
27+
categories=['a', 'bb', 'ccc'], ordered=False, dtype='category')""" # noqa:E501
2828

2929
assert repr(idx) == expected
3030

@@ -55,7 +55,7 @@ def test_string_categorical_index_repr(self):
5555
expected = """CategoricalIndex(['あ', 'いい', 'ううう', 'あ', 'いい', 'ううう', 'あ', 'いい', 'ううう', 'あ',
5656
'いい', 'ううう', 'あ', 'いい', 'ううう', 'あ', 'いい', 'ううう', 'あ', 'いい',
5757
'ううう', 'あ', 'いい', 'ううう', 'あ', 'いい', 'ううう', 'あ', 'いい', 'ううう'],
58-
categories=['あ', 'いい', 'ううう'], ordered=False, dtype='category')"""
58+
categories=['あ', 'いい', 'ううう'], ordered=False, dtype='category')""" # noqa:E501
5959

6060
assert repr(idx) == expected
6161

@@ -90,7 +90,7 @@ def test_string_categorical_index_repr(self):
9090
'ううう', 'あ', 'いい', 'ううう', 'あ', 'いい', 'ううう',
9191
'あ', 'いい', 'ううう', 'あ', 'いい', 'ううう', 'あ', 'いい',
9292
'ううう', 'あ', 'いい', 'ううう', 'あ', 'いい', 'ううう'],
93-
categories=['あ', 'いい', 'ううう'], ordered=False, dtype='category')"""
93+
categories=['あ', 'いい', 'ううう'], ordered=False, dtype='category')""" # noqa:E501
9494

9595
assert repr(idx) == expected
9696

pandas/tests/indexes/multi/test_formats.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ def test_tuple_width(self, wide_multi_index):
184184
mi = wide_multi_index
185185
result = mi[:1].__repr__()
186186
expected = """MultiIndex([('a', 9, '2000-01-01 00:00:00', '2000-01-01 00:00:00', ...)],
187-
names=['a', 'b', 'dti_1', 'dti_2', 'dti_3'])"""
187+
names=['a', 'b', 'dti_1', 'dti_2', 'dti_3'])""" # noqa:E501
188188
assert result == expected
189189

190190
result = mi[:10].__repr__()

requirements-dev.txt

+2-3
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,8 @@ flask
6464
asv
6565
black==22.3.0
6666
cpplint
67-
flake8==4.0.1
68-
flake8-bugbear==21.3.2
69-
flake8-comprehensions==3.7.0
67+
flake8==5.0.4
68+
flake8-bugbear==22.7.1
7069
isort>=5.2.1
7170
mypy==0.971
7271
pre-commit>=2.15.0

setup.cfg

+6
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,12 @@ ignore =
103103
# tests use comparisons but not their returned value
104104
B015,
105105
# false positives
106+
B019,
107+
# Use of functools.lru_cache or functools.cache on methods can lead to memory leaks.
108+
B020
109+
# Loop control variable overrides iterable it iterates
110+
B023
111+
# Functions defined inside a loop must not use variables redefined in the loop
106112
B301,
107113
# single-letter variables
108114
PDF023,

0 commit comments

Comments
 (0)