Skip to content

Commit

Permalink
Translate config with pylint-to-ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
tqa236 committed Feb 6, 2024
1 parent 009fd1c commit 5f5a73f
Show file tree
Hide file tree
Showing 6 changed files with 101 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ repos:
exclude: ^pandas/tests
args: [--select, "ANN001,ANN2", --fix-only, --exit-non-zero-on-fix]
- id: ruff
args: [--exit-non-zero-on-fix, --preview, "--ignore=E721,F841,RUF025,RUF100,RUF001,E226,RUF003,E203"]
args: [--exit-non-zero-on-fix, --preview, "--ignore=E,F841,RUF"]
- id: ruff-format
- repo: https://github.com/jendrikseipp/vulture
rev: v2.11
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -5106,7 +5106,7 @@ def _sanitize_column(self, value) -> tuple[ArrayLike, BlockValuesRefs | None]:
isinstance(value, Index)
and value.dtype == "object"
and arr.dtype != value.dtype
): #
):
# TODO: Remove kludge in sanitize_array for string mode when enforcing
# this deprecation
warnings.warn(
Expand Down
1 change: 0 additions & 1 deletion pandas/tests/extension/decimal/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ def to_numpy(
return result

def __array_ufunc__(self, ufunc: np.ufunc, method: str, *inputs, **kwargs):
#
if not all(
isinstance(t, self._HANDLED_TYPES + (DecimalArray,)) for t in inputs
):
Expand Down
5 changes: 0 additions & 5 deletions pandas/tests/scalar/period/test_period.py
Original file line number Diff line number Diff line change
Expand Up @@ -968,7 +968,6 @@ def test_properties_quarterly(self):
qedec_date = Period(freq="Q-DEC", year=2007, quarter=1)
qejan_date = Period(freq="Q-JAN", year=2007, quarter=1)
qejun_date = Period(freq="Q-JUN", year=2007, quarter=1)
#
for x in range(3):
for qd in (qedec_date, qejan_date, qejun_date):
assert (qd + x).qyear == 2007
Expand All @@ -993,7 +992,6 @@ def test_properties_monthly(self):
def test_properties_weekly(self):
# Test properties on Periods with daily frequency.
w_date = Period(freq="W", year=2007, month=1, day=7)
#
assert w_date.year == 2007
assert w_date.quarter == 1
assert w_date.month == 1
Expand Down Expand Up @@ -1023,7 +1021,6 @@ def test_properties_daily(self):
# Test properties on Periods with daily frequency.
with tm.assert_produces_warning(FutureWarning, match=bday_msg):
b_date = Period(freq="B", year=2007, month=1, day=1)
#
assert b_date.year == 2007
assert b_date.quarter == 1
assert b_date.month == 1
Expand Down Expand Up @@ -1066,7 +1063,6 @@ def test_properties_hourly(self):
def test_properties_minutely(self):
# Test properties on Periods with minutely frequency.
t_date = Period(freq="Min", year=2007, month=1, day=1, hour=0, minute=0)
#
assert t_date.quarter == 1
assert t_date.month == 1
assert t_date.day == 1
Expand All @@ -1085,7 +1081,6 @@ def test_properties_secondly(self):
s_date = Period(
freq="Min", year=2007, month=1, day=1, hour=0, minute=0, second=0
)
#
assert s_date.year == 2007
assert s_date.quarter == 1
assert s_date.month == 1
Expand Down
1 change: 0 additions & 1 deletion pandas/tests/scalar/timestamp/methods/test_round.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,6 @@ def test_round_dst_border_ambiguous(self, method, unit):
# GH 18946 round near "fall back" DST
ts = Timestamp("2017-10-29 00:00:00", tz="UTC").tz_convert("Europe/Madrid")
ts = ts.as_unit(unit)
#
result = getattr(ts, method)("h", ambiguous=True)
assert result == ts
assert result._creso == getattr(NpyDatetimeUnit, f"NPY_FR_{unit}").value
Expand Down
103 changes: 99 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,6 @@ ignore = [
# Use `typing.NamedTuple` instead of `collections.namedtuple`
"PYI024",
# No builtin `eval()` allowed
"PGH001",
# "S307", # flake8-bandit is not enabled yet
# compare-to-empty-string
"PLC1901",
Expand Down Expand Up @@ -322,7 +321,6 @@ ignore = [
"RUF012",
# Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks
# "E721",
# "F841",
# Parenthesize `a and b` expressions when chaining `and` and `or` together, to make the precedence clear
"RUF021",
# `__all__` is not sorted
Expand Down Expand Up @@ -361,7 +359,105 @@ ignore = [
# Unnecessary lookup of dictionary value by key
"PLR1733",
# Unnecessary lookup of list item by index
"PLR1736"
"PLR1736",

# Output of pylint-to-ruff
# "PLC0103", # invalid-name
# "PLC0114", # missing-module-docstring
# "PLC0115", # missing-class-docstring
# "PLC0116", # missing-function-docstring
# "PLC0121", # singleton-comparison
# "PLC0123", # unidiomatic-typecheck
# "PLC0200", # consider-using-enumerate
# "PLC0204", # bad-mcs-classmethod-argument
# "PLC0302", # too-many-lines
# "PLC0325", # superfluous-parens
# "PLC0411", # wrong-import-order
# "PLC0412", # ungrouped-imports
# "PLC0413", # wrong-import-position
# "PLC0415", # import-outside-toplevel
# "PLC1802", # use-implicit-booleaness-not-len
# "PLC1803", # use-implicit-booleaness-not-comparison
# "PLC1804", # use-implicit-booleaness-not-comparison-to-string
# "PLC1805", # use-implicit-booleaness-not-comparison-to-zero
"PLC2801", # unnecessary-dunder-call
# "PLC3001", # unnecessary-lambda-assignment
# "PLE0110", # abstract-class-instantiated
# "PLE0401", # import-error
# "PLE0601", # used-before-assignment
# "PLE0602", # undefined-variable
# "PLE0611", # no-name-in-module
# "PLE0633", # unpacking-non-sequence
# "PLE1101", # no-member
# "PLE1120", # no-value-for-parameter
# "PLE1121", # too-many-function-args
# "PLE1123", # unexpected-keyword-arg
# "PLE1124", # redundant-keyword-arg
# "PLE1130", # invalid-unary-operand-type
# "PLE1133", # not-an-iterable
# "PLE1135", # unsupported-membership-test
# "PLE1136", # unsubscriptable-object
# "PLE1137", # unsupported-assignment-operation
# "PLI0001", # raw-checker-failed
# "PLI0010", # bad-inline-option
# "PLI0011", # locally-disabled
# "PLI0013", # file-ignored
# "PLI0020", # suppressed-message
# "PLI0021", # useless-suppression
# "PLI0022", # deprecated-pragma
# "PLI0023", # use-symbolic-message-instead
# "PLI1101", # c-extension-no-member
"PLR0124", # comparison-with-itself
# "PLR0401", # cyclic-import
# "PLR0801", # duplicate-code
# "PLR0901", # too-many-ancestors
# "PLR0902", # too-many-instance-attributes
# "PLR0903", # too-few-public-methods
"PLR0904", # too-many-public-methods
"PLR0911", # too-many-return-statements
"PLR0912", # too-many-branches
"PLR0913", # too-many-arguments
"PLR0914", # too-many-locals
"PLR0915", # too-many-statements
"PLR0916", # too-many-boolean-expressions
"PLR1702", # too-many-nested-blocks
"PLR1704", # redefined-argument-from-local
# "PLR1705", # no-else-return
# "PLR1710", # inconsistent-return-statements
# "PLR1720", # no-else-raise
# "PLR1724", # no-else-continue
# "PLR1732", # consider-using-with
# "PLR1735", # use-dict-literal
# "PLW0102", # dangerous-default-value
# "PLW0104", # pointless-statement
# "PLW0106", # expression-not-assigned
"PLW0108", # unnecessary-lambda
# "PLW0123", # eval-used
# "PLW0125", # using-constant-test
# "PLW0143", # comparison-with-callable
# "PLW0201", # attribute-defined-outside-init
# "PLW0212", # protected-access
# "PLW0221", # arguments-differ
# "PLW0222", # signature-differs
# "PLW0223", # abstract-method
# "PLW0231", # super-init-not-called
# "PLW0236", # invalid-overridden-method
# "PLW0237", # arguments-renamed
# "PLW0239", # overridden-final-method
# "PLW0511", # fixme
"PLW0603", # global-statement
# "PLW0613", # unused-argument
# "PLW0621", # redefined-outer-name
# "PLW0622", # redefined-builtin
# "PLW0641", # possibly-unused-variable
# "PLW0642", # self-cls-assignment
# "PLW0706", # try-except-raise
# "PLW0707", # raise-missing-from
# "PLW0718", # broad-exception-caught
# "PLW0719", # broad-exception-raised
# "PLW1113", # keyword-arg-before-vararg
# "PLW1114", # arguments-out-of-order
# "PLW4901", # deprecated-module
]

exclude = [
Expand All @@ -379,7 +475,6 @@ exclude = [
[tool.ruff.lint.flake8-tidy-imports.banned-api]
"urllib.request.urlopen".msg = "Use pandas.io.common.urlopen instead of urllib.request.urlopen"

[tool.ruff.per-file-ignores]
[tool.ruff.lint.per-file-ignores]
# relative imports allowed for asv_bench
"asv_bench/*" = ["TID", "NPY002"]
Expand Down

0 comments on commit 5f5a73f

Please sign in to comment.