Skip to content

Commit a38f62f

Browse files
snorfyangyusharthMarcoGorelli
authored and
im-vinicius
committed
STYLE: upgrade ruff (pandas-dev#52974)
* Bug: fix pre-commit problems * fix some errors * pre commit issues passed * Delete =1.5 * pytlint and alignment issue * fix errors * fix aligned and update ruff * Update pandas/core/series.py --------- Co-authored-by: yusharth <[email protected]> Co-authored-by: Yusharth Singh <[email protected]> Co-authored-by: Marco Edward Gorelli <[email protected]>
1 parent e0adf08 commit a38f62f

File tree

11 files changed

+153
-57
lines changed

11 files changed

+153
-57
lines changed

.pre-commit-config.yaml

+4-4
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ repos:
2828
types_or: [python, pyi]
2929
additional_dependencies: [black==23.1.0]
3030
- repo: https://github.com/charliermarsh/ruff-pre-commit
31-
rev: v0.0.259
31+
rev: v0.0.264
3232
hooks:
3333
- id: ruff
3434
args: [--exit-non-zero-on-fix]
@@ -40,13 +40,13 @@ repos:
4040
pass_filenames: true
4141
require_serial: false
4242
- repo: https://github.com/codespell-project/codespell
43-
rev: v2.2.2
43+
rev: v2.2.4
4444
hooks:
4545
- id: codespell
4646
types_or: [python, rst, markdown, cython, c]
4747
additional_dependencies: [tomli]
4848
- repo: https://github.com/MarcoGorelli/cython-lint
49-
rev: v0.12.5
49+
rev: v0.15.0
5050
hooks:
5151
- id: cython-lint
5252
- id: double-quote-cython-strings
@@ -104,7 +104,7 @@ repos:
104104
hooks:
105105
- id: isort
106106
- repo: https://github.com/asottile/pyupgrade
107-
rev: v3.3.1
107+
rev: v3.3.2
108108
hooks:
109109
- id: pyupgrade
110110
args: [--py38-plus]

pandas/_libs/lib.pyi

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ from enum import Enum
3030
class _NoDefault(Enum):
3131
no_default = ...
3232

33-
no_default: Final = _NoDefault.no_default
33+
no_default: Final = _NoDefault.no_default # noqa
3434
NoDefault = Literal[_NoDefault.no_default]
3535

3636
i8max: int

pandas/core/frame.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -5139,7 +5139,7 @@ def drop(
51395139
51405140
Drop columns and/or rows of MultiIndex DataFrame
51415141
5142-
>>> midx = pd.MultiIndex(levels=[['lama', 'cow', 'falcon'],
5142+
>>> midx = pd.MultiIndex(levels=[['llama', 'cow', 'falcon'],
51435143
... ['speed', 'weight', 'length']],
51445144
... codes=[[0, 0, 0, 1, 1, 1, 2, 2, 2],
51455145
... [0, 1, 2, 0, 1, 2, 0, 1, 2]])
@@ -5149,7 +5149,7 @@ def drop(
51495149
... [1, 0.8], [0.3, 0.2]])
51505150
>>> df
51515151
big small
5152-
lama speed 45.0 30.0
5152+
llama speed 45.0 30.0
51535153
weight 200.0 100.0
51545154
length 1.5 1.0
51555155
cow speed 30.0 20.0
@@ -5165,7 +5165,7 @@ def drop(
51655165
51665166
>>> df.drop(index=('falcon', 'weight'))
51675167
big small
5168-
lama speed 45.0 30.0
5168+
llama speed 45.0 30.0
51695169
weight 200.0 100.0
51705170
length 1.5 1.0
51715171
cow speed 30.0 20.0
@@ -5176,7 +5176,7 @@ def drop(
51765176
51775177
>>> df.drop(index='cow', columns='small')
51785178
big
5179-
lama speed 45.0
5179+
llama speed 45.0
51805180
weight 200.0
51815181
length 1.5
51825182
falcon speed 320.0
@@ -5185,7 +5185,7 @@ def drop(
51855185
51865186
>>> df.drop(index='length', level=1)
51875187
big small
5188-
lama speed 45.0 30.0
5188+
llama speed 45.0 30.0
51895189
weight 200.0 100.0
51905190
cow speed 30.0 20.0
51915191
weight 250.0 150.0

pandas/core/series.py

+15-15
Original file line numberDiff line numberDiff line change
@@ -2225,14 +2225,14 @@ def drop_duplicates(
22252225
--------
22262226
Generate a Series with duplicated entries.
22272227
2228-
>>> s = pd.Series(['lama', 'cow', 'lama', 'beetle', 'lama', 'hippo'],
2228+
>>> s = pd.Series(['llama', 'cow', 'llama', 'beetle', 'llama', 'hippo'],
22292229
... name='animal')
22302230
>>> s
2231-
0 lama
2231+
0 llama
22322232
1 cow
2233-
2 lama
2233+
2 llama
22342234
3 beetle
2235-
4 lama
2235+
4 llama
22362236
5 hippo
22372237
Name: animal, dtype: object
22382238
@@ -2241,7 +2241,7 @@ def drop_duplicates(
22412241
set of duplicated entries. The default value of keep is 'first'.
22422242
22432243
>>> s.drop_duplicates()
2244-
0 lama
2244+
0 llama
22452245
1 cow
22462246
3 beetle
22472247
5 hippo
@@ -2253,7 +2253,7 @@ def drop_duplicates(
22532253
>>> s.drop_duplicates(keep='last')
22542254
1 cow
22552255
3 beetle
2256-
4 lama
2256+
4 llama
22572257
5 hippo
22582258
Name: animal, dtype: object
22592259
@@ -2314,7 +2314,7 @@ def duplicated(self, keep: DropKeep = "first") -> Series:
23142314
By default, for each set of duplicated values, the first occurrence is
23152315
set on False and all others on True:
23162316
2317-
>>> animals = pd.Series(['lama', 'cow', 'lama', 'beetle', 'lama'])
2317+
>>> animals = pd.Series(['llama', 'cow', 'llama', 'beetle', 'llama'])
23182318
>>> animals.duplicated()
23192319
0 False
23202320
1 False
@@ -4862,14 +4862,14 @@ def drop(
48624862
48634863
Drop 2nd level label in MultiIndex Series
48644864
4865-
>>> midx = pd.MultiIndex(levels=[['lama', 'cow', 'falcon'],
4865+
>>> midx = pd.MultiIndex(levels=[['llama', 'cow', 'falcon'],
48664866
... ['speed', 'weight', 'length']],
48674867
... codes=[[0, 0, 0, 1, 1, 1, 2, 2, 2],
48684868
... [0, 1, 2, 0, 1, 2, 0, 1, 2]])
48694869
>>> s = pd.Series([45, 200, 1.2, 30, 250, 1.5, 320, 1, 0.3],
48704870
... index=midx)
48714871
>>> s
4872-
lama speed 45.0
4872+
llama speed 45.0
48734873
weight 200.0
48744874
length 1.2
48754875
cow speed 30.0
@@ -4881,7 +4881,7 @@ def drop(
48814881
dtype: float64
48824882
48834883
>>> s.drop(labels='weight', level=1)
4884-
lama speed 45.0
4884+
llama speed 45.0
48854885
length 1.2
48864886
cow speed 30.0
48874887
length 1.5
@@ -5048,9 +5048,9 @@ def isin(self, values) -> Series:
50485048
50495049
Examples
50505050
--------
5051-
>>> s = pd.Series(['lama', 'cow', 'lama', 'beetle', 'lama',
5051+
>>> s = pd.Series(['llama', 'cow', 'llama', 'beetle', 'llama',
50525052
... 'hippo'], name='animal')
5053-
>>> s.isin(['cow', 'lama'])
5053+
>>> s.isin(['cow', 'llama'])
50545054
0 True
50555055
1 True
50565056
2 True
@@ -5061,7 +5061,7 @@ def isin(self, values) -> Series:
50615061
50625062
To invert the boolean values, use the ``~`` operator:
50635063
5064-
>>> ~s.isin(['cow', 'lama'])
5064+
>>> ~s.isin(['cow', 'llama'])
50655065
0 False
50665066
1 False
50675067
2 False
@@ -5070,10 +5070,10 @@ def isin(self, values) -> Series:
50705070
5 True
50715071
Name: animal, dtype: bool
50725072
5073-
Passing a single string as ``s.isin('lama')`` will raise an error. Use
5073+
Passing a single string as ``s.isin('llama')`` will raise an error. Use
50745074
a list of one element instead:
50755075
5076-
>>> s.isin(['lama'])
5076+
>>> s.isin(['llama'])
50775077
0 True
50785078
1 False
50795079
2 True

pandas/tests/groupby/test_counting.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -257,10 +257,10 @@ def test_groupby_count_dateparseerror(self):
257257

258258
def test_groupby_timedelta_cython_count():
259259
df = DataFrame(
260-
{"g": list("ab" * 2), "delt": np.arange(4).astype("timedelta64[ns]")}
260+
{"g": list("ab" * 2), "delta": np.arange(4).astype("timedelta64[ns]")}
261261
)
262-
expected = Series([2, 2], index=Index(["a", "b"], name="g"), name="delt")
263-
result = df.groupby("g").delt.count()
262+
expected = Series([2, 2], index=Index(["a", "b"], name="g"), name="delta")
263+
result = df.groupby("g").delta.count()
264264
tm.assert_series_equal(expected, result)
265265

266266

pandas/tests/io/excel/test_readers.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -843,7 +843,13 @@ def test_bad_sheetname_raises(self, read_ext, sheet_name):
843843
def test_missing_file_raises(self, read_ext):
844844
bad_file = f"foo{read_ext}"
845845
# CI tests with other languages, translates to "No such file or directory"
846-
match = r"(No such file or directory|没有那个文件或目录|File o directory non esistente)"
846+
match = "|".join(
847+
[
848+
"(No such file or directory",
849+
"没有那个文件或目录",
850+
"File o directory non esistente)",
851+
]
852+
)
847853
with pytest.raises(FileNotFoundError, match=match):
848854
pd.read_excel(bad_file)
849855

0 commit comments

Comments
 (0)