From dc19148bf7197a928a129b1d1679b1445a7ea7c7 Mon Sep 17 00:00:00 2001 From: Trinh Quoc Anh Date: Sat, 9 Mar 2024 23:19:03 +0100 Subject: [PATCH] Migrate ruff config to the latest format (#57791) * Migrate ruff config to the latest format * Fix errors discovered by the new config --- doc/sphinxext/announce.py | 1 + doc/sphinxext/contributors.py | 1 + pandas/util/version/__init__.py | 2 +- pyproject.toml | 8 +++++--- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/doc/sphinxext/announce.py b/doc/sphinxext/announce.py index 89361eb75606c..66e999e251c5e 100755 --- a/doc/sphinxext/announce.py +++ b/doc/sphinxext/announce.py @@ -32,6 +32,7 @@ $ ./scripts/announce.py $GITHUB v1.11.0..v1.11.1 > announce.rst """ + import codecs import os import re diff --git a/doc/sphinxext/contributors.py b/doc/sphinxext/contributors.py index c2b21e40cadad..06f205b5cc3ce 100644 --- a/doc/sphinxext/contributors.py +++ b/doc/sphinxext/contributors.py @@ -14,6 +14,7 @@ While the v0.23.1 tag does not exist, that will use the HEAD of the branch as the end of the revision range. """ + from announce import build_components from docutils import nodes from docutils.parsers.rst import Directive diff --git a/pandas/util/version/__init__.py b/pandas/util/version/__init__.py index 3a5efbbb09c1e..153424e339c45 100644 --- a/pandas/util/version/__init__.py +++ b/pandas/util/version/__init__.py @@ -131,7 +131,7 @@ class InvalidVersion(ValueError): Examples -------- - >>> pd.util.version.Version('1.') + >>> pd.util.version.Version("1.") Traceback (most recent call last): InvalidVersion: Invalid version: '1.' """ diff --git a/pyproject.toml b/pyproject.toml index 5a06e22f4be9b..56d5f59e10a4f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -185,6 +185,8 @@ environment = {CFLAGS="-g0"} line-length = 88 target-version = "py310" fix = true + +[tool.ruff.lint] unfixable = [] typing-modules = ["pandas._typing"] @@ -271,8 +273,8 @@ ignore = [ "PLW0603", # Use `typing.NamedTuple` instead of `collections.namedtuple` "PYI024", - # No builtin `eval()` allowed - "PGH001", + # Use of possibly insecure function; consider using ast.literal_eval + "S307", # while int | float can be shortened to float, the former is more explicit "PYI041", # incorrect-dict-iterator, flags valid Series.items usage @@ -345,7 +347,7 @@ exclude = [ [tool.ruff.lint.flake8-import-conventions.aliases] "pandas.core.construction.array" = "pd_array" -[tool.ruff.per-file-ignores] +[tool.ruff.lint.per-file-ignores] # relative imports allowed for asv_bench "asv_bench/*" = ["TID", "NPY002"] # to be enabled gradually