Skip to content

STYLE: upgrade ruff #52974

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

Merged
merged 10 commits into from
May 2, 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
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ repos:
types_or: [python, pyi]
additional_dependencies: [black==23.1.0]
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.0.259
rev: v0.0.264
hooks:
- id: ruff
args: [--exit-non-zero-on-fix]
Expand All @@ -40,13 +40,13 @@ repos:
pass_filenames: true
require_serial: false
- repo: https://github.com/codespell-project/codespell
rev: v2.2.2
rev: v2.2.4
hooks:
- id: codespell
types_or: [python, rst, markdown, cython, c]
additional_dependencies: [tomli]
- repo: https://github.com/MarcoGorelli/cython-lint
rev: v0.12.5
rev: v0.15.0
hooks:
- id: cython-lint
- id: double-quote-cython-strings
Expand Down Expand Up @@ -104,7 +104,7 @@ repos:
hooks:
- id: isort
- repo: https://github.com/asottile/pyupgrade
rev: v3.3.1
rev: v3.3.2
hooks:
- id: pyupgrade
args: [--py38-plus]
Expand Down
2 changes: 1 addition & 1 deletion pandas/_libs/lib.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ from enum import Enum
class _NoDefault(Enum):
no_default = ...

no_default: Final = _NoDefault.no_default
no_default: Final = _NoDefault.no_default # noqa
NoDefault = Literal[_NoDefault.no_default]

i8max: int
Expand Down
10 changes: 5 additions & 5 deletions pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -5139,7 +5139,7 @@ def drop(

Drop columns and/or rows of MultiIndex DataFrame

>>> midx = pd.MultiIndex(levels=[['lama', 'cow', 'falcon'],
>>> midx = pd.MultiIndex(levels=[['llama', 'cow', 'falcon'],
... ['speed', 'weight', 'length']],
... codes=[[0, 0, 0, 1, 1, 1, 2, 2, 2],
... [0, 1, 2, 0, 1, 2, 0, 1, 2]])
Expand All @@ -5149,7 +5149,7 @@ def drop(
... [1, 0.8], [0.3, 0.2]])
>>> df
big small
lama speed 45.0 30.0
llama speed 45.0 30.0
weight 200.0 100.0
length 1.5 1.0
cow speed 30.0 20.0
Expand All @@ -5165,7 +5165,7 @@ def drop(

>>> df.drop(index=('falcon', 'weight'))
big small
lama speed 45.0 30.0
llama speed 45.0 30.0
weight 200.0 100.0
length 1.5 1.0
cow speed 30.0 20.0
Expand All @@ -5176,7 +5176,7 @@ def drop(

>>> df.drop(index='cow', columns='small')
big
lama speed 45.0
llama speed 45.0
weight 200.0
length 1.5
falcon speed 320.0
Expand All @@ -5185,7 +5185,7 @@ def drop(

>>> df.drop(index='length', level=1)
big small
lama speed 45.0 30.0
llama speed 45.0 30.0
weight 200.0 100.0
cow speed 30.0 20.0
weight 250.0 150.0
Expand Down
30 changes: 15 additions & 15 deletions pandas/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -2225,14 +2225,14 @@ def drop_duplicates(
--------
Generate a Series with duplicated entries.

>>> s = pd.Series(['lama', 'cow', 'lama', 'beetle', 'lama', 'hippo'],
>>> s = pd.Series(['llama', 'cow', 'llama', 'beetle', 'llama', 'hippo'],
... name='animal')
>>> s
0 lama
0 llama
1 cow
2 lama
2 llama
3 beetle
4 lama
4 llama
5 hippo
Name: animal, dtype: object

Expand All @@ -2241,7 +2241,7 @@ def drop_duplicates(
set of duplicated entries. The default value of keep is 'first'.

>>> s.drop_duplicates()
0 lama
0 llama
1 cow
3 beetle
5 hippo
Expand All @@ -2253,7 +2253,7 @@ def drop_duplicates(
>>> s.drop_duplicates(keep='last')
1 cow
3 beetle
4 lama
4 llama
5 hippo
Name: animal, dtype: object

Expand Down Expand Up @@ -2314,7 +2314,7 @@ def duplicated(self, keep: DropKeep = "first") -> Series:
By default, for each set of duplicated values, the first occurrence is
set on False and all others on True:

>>> animals = pd.Series(['lama', 'cow', 'lama', 'beetle', 'lama'])
>>> animals = pd.Series(['llama', 'cow', 'llama', 'beetle', 'llama'])
>>> animals.duplicated()
0 False
1 False
Expand Down Expand Up @@ -4862,14 +4862,14 @@ def drop(

Drop 2nd level label in MultiIndex Series

>>> midx = pd.MultiIndex(levels=[['lama', 'cow', 'falcon'],
>>> midx = pd.MultiIndex(levels=[['llama', 'cow', 'falcon'],
... ['speed', 'weight', 'length']],
... codes=[[0, 0, 0, 1, 1, 1, 2, 2, 2],
... [0, 1, 2, 0, 1, 2, 0, 1, 2]])
>>> s = pd.Series([45, 200, 1.2, 30, 250, 1.5, 320, 1, 0.3],
... index=midx)
>>> s
lama speed 45.0
llama speed 45.0
weight 200.0
length 1.2
cow speed 30.0
Expand All @@ -4881,7 +4881,7 @@ def drop(
dtype: float64

>>> s.drop(labels='weight', level=1)
lama speed 45.0
llama speed 45.0
length 1.2
cow speed 30.0
length 1.5
Expand Down Expand Up @@ -5048,9 +5048,9 @@ def isin(self, values) -> Series:

Examples
--------
>>> s = pd.Series(['lama', 'cow', 'lama', 'beetle', 'lama',
>>> s = pd.Series(['llama', 'cow', 'llama', 'beetle', 'llama',
... 'hippo'], name='animal')
>>> s.isin(['cow', 'lama'])
>>> s.isin(['cow', 'llama'])
0 True
1 True
2 True
Expand All @@ -5061,7 +5061,7 @@ def isin(self, values) -> Series:

To invert the boolean values, use the ``~`` operator:

>>> ~s.isin(['cow', 'lama'])
>>> ~s.isin(['cow', 'llama'])
0 False
1 False
2 False
Expand All @@ -5070,10 +5070,10 @@ def isin(self, values) -> Series:
5 True
Name: animal, dtype: bool

Passing a single string as ``s.isin('lama')`` will raise an error. Use
Passing a single string as ``s.isin('llama')`` will raise an error. Use
a list of one element instead:

>>> s.isin(['lama'])
>>> s.isin(['llama'])
0 True
1 False
2 True
Expand Down
6 changes: 3 additions & 3 deletions pandas/tests/groupby/test_counting.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,10 +257,10 @@ def test_groupby_count_dateparseerror(self):

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


Expand Down
8 changes: 7 additions & 1 deletion pandas/tests/io/excel/test_readers.py
Original file line number Diff line number Diff line change
Expand Up @@ -843,7 +843,13 @@ def test_bad_sheetname_raises(self, read_ext, sheet_name):
def test_missing_file_raises(self, read_ext):
bad_file = f"foo{read_ext}"
# CI tests with other languages, translates to "No such file or directory"
match = r"(No such file or directory|没有那个文件或目录|File o directory non esistente)"
match = "|".join(
[
"(No such file or directory",
"没有那个文件或目录",
"File o directory non esistente)",
]
)
with pytest.raises(FileNotFoundError, match=match):
pd.read_excel(bad_file)

Expand Down
Loading