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 3 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
12 changes: 6 additions & 6 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.263
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 @@ -79,12 +79,12 @@ repos:
'--filter=-readability/casting,-runtime/int,-build/include_subdir,-readability/fn_size'
]
- repo: https://github.com/pycqa/pylint
rev: v2.16.2
rev: v3.0.0a6
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like pylint have pushed a new tag, but no new release. I'd suggest reverting this change for now

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ping on this

hooks:
- id: pylint
stages: [manual]
- repo: https://github.com/pycqa/pylint
rev: v2.16.2
rev: v3.0.0a6
hooks:
- id: pylint
alias: redefined-outer-name
Expand All @@ -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
6 changes: 6 additions & 0 deletions =1.5
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Requirement already satisfied: pandas in /home/yusharthsingh/Desktop/pandas (0+untagged.32262.g3790452.dirty)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this file

Requirement already satisfied: python-dateutil>=2.8.2 in /home/yusharthsingh/mambaforge/envs/pandas-dev/lib/python3.10/site-packages (from pandas) (2.8.2)
Requirement already satisfied: pytz>=2020.1 in /home/yusharthsingh/mambaforge/envs/pandas-dev/lib/python3.10/site-packages (from pandas) (2023.3)
Requirement already satisfied: tzdata>=2022.1 in /home/yusharthsingh/mambaforge/envs/pandas-dev/lib/python3.10/site-packages (from pandas) (2023.3)
Requirement already satisfied: numpy>=1.21.6 in /home/yusharthsingh/.local/lib/python3.10/site-packages (from pandas) (1.23.1)
Requirement already satisfied: six>=1.5 in /home/yusharthsingh/mambaforge/envs/pandas-dev/lib/python3.10/site-packages (from python-dateutil>=2.8.2->pandas) (1.16.0)
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 @@ -5140,7 +5140,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 @@ -5150,7 +5150,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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these aren't aligned anymore

I'd suggest either:

  • anytime you change lama to llama, fixup the alignment
  • or, just keep the codespell update out of this PR

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and this

weight 200.0 100.0
length 1.5 1.0
cow speed 30.0 20.0
Expand All @@ -5166,7 +5166,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 @@ -5177,7 +5177,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 @@ -5186,7 +5186,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 @@ -2222,14 +2222,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 @@ -2238,7 +2238,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 @@ -2250,7 +2250,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 @@ -2311,7 +2311,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 @@ -4859,14 +4859,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 @@ -4878,7 +4878,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 @@ -5045,9 +5045,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 @@ -5058,7 +5058,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 @@ -5067,10 +5067,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