summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPierre Sassoulas <pierre.sassoulas@gmail.com>2023-03-02 21:19:56 +0100
committerGitHub <noreply@github.com>2023-03-02 21:19:56 +0100
commit4de654512e8c1219046f2f49664b6c9f66946e84 (patch)
tree6b7b4dd14e48198829080f98893925481c2a7011
parentb5aab35a6f20efad94ae8da07392fad6d1c28aad (diff)
downloadpylint-git-4de654512e8c1219046f2f49664b6c9f66946e84.tar.gz
[pre-commit] Transition from flake8/autoflake to ruff (#8372)
ruff is faster and support pyproject.toml. flake8-typing-import is not implemented but it checks for things in python version < 3.7.2 that we do not support.
-rw-r--r--.pre-commit-config.yaml32
-rw-r--r--doc/data/ruff.toml (renamed from doc/data/.flake8)7
-rw-r--r--pylint/config/config_initialization.py7
-rw-r--r--pyproject.toml9
-rw-r--r--setup.cfg16
5 files changed, 20 insertions, 51 deletions
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 6e4cc35e4..5d67d407d 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -15,23 +15,19 @@ repos:
doc/data/messages/t/trailing-newlines/bad.py|
doc/data/messages/m/missing-final-newline/bad.py|
)$
- - repo: https://github.com/PyCQA/autoflake
- rev: v2.0.1
+ - repo: https://github.com/charliermarsh/ruff-pre-commit
+ rev: "v0.0.253"
hooks:
- - id: autoflake
+ - id: ruff
+ args: ["--fix"]
exclude: &fixtures tests(/\w*)*/functional/|tests/input|doc/data/messages|tests(/\w*)*data/
- args:
- - --in-place
- - --remove-all-unused-imports
- - --expand-star-imports
- - --remove-duplicate-keys
- - --remove-unused-variables
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: "v0.0.253"
hooks:
- id: ruff
- args: ["--fix"]
- exclude: *fixtures
+ name: line-length-doc
+ files: doc/data/messages
+ args: ["--config", "doc/data/ruff.toml"]
- repo: https://github.com/Pierre-Sassoulas/copyright_notice_precommit
rev: 0.1.2
hooks:
@@ -60,20 +56,6 @@ repos:
rev: v1.1.3
hooks:
- id: black-disable-checker
- - repo: https://github.com/PyCQA/flake8
- rev: 6.0.0
- hooks:
- - id: flake8
- additional_dependencies:
- [flake8-bugbear==23.1.20, flake8-typing-imports==1.14.0]
- exclude: *fixtures
- - repo: https://github.com/PyCQA/flake8
- rev: 6.0.0
- hooks:
- - id: flake8
- name: line-length-doc
- files: doc/data/messages
- args: ["--config", "doc/data/.flake8"]
- repo: local
hooks:
- id: pylint
diff --git a/doc/data/.flake8 b/doc/data/ruff.toml
index 676bedc0d..da929be3b 100644
--- a/doc/data/.flake8
+++ b/doc/data/ruff.toml
@@ -1,6 +1,5 @@
-[flake8]
-select =
- E501,
+ignore = []
# Reading ease is drastically reduced on read the doc after 103 chars
# (Because of horizontal scrolling)
-max-line-length=103
+line-length = 103
+select = ["E501"]
diff --git a/pylint/config/config_initialization.py b/pylint/config/config_initialization.py
index 60d2d8fee..3c9c4e22a 100644
--- a/pylint/config/config_initialization.py
+++ b/pylint/config/config_initialization.py
@@ -125,9 +125,10 @@ def _config_initialization(
# All other options have been removed from the list.
return list(
chain.from_iterable(
- # NOTE: 'or [arg]' is needed in the case the input file or directory does not exist and 'glob(arg)' cannot
- # find anything. Without this we would not be able to output the fatal import error for this module later
- # on, as it would get silently ignored.
+ # NOTE: 'or [arg]' is needed in the case the input file or directory does
+ # not exist and 'glob(arg)' cannot find anything. Without this we would
+ # not be able to output the fatal import error for this module later on,
+ # as it would get silently ignored.
glob(arg, recursive=True) or [arg]
for arg in parsed_args_list
)
diff --git a/pyproject.toml b/pyproject.toml
index 80547df05..1c8a915ac 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -130,10 +130,13 @@ module = [
"pytest",
"sphinx.*",
]
+
[tool.ruff]
-select = ["E", "F", "B"]
+select = ["E", "F", "W", "B"]
ignore = [
"B905", # Not enforced previousely
]
-fixable = ["E", "F", "B"]
-line-length = 125
+fixable = ["E", "F", "W", "B"]
+# ruff is less lenient than pylint and does not make any exceptions
+# (for docstrings, strings and comments in particular).
+line-length = 115
diff --git a/setup.cfg b/setup.cfg
index 1f188de83..3b35d7a5e 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -7,19 +7,3 @@
license_files =
LICENSE
CONTRIBUTORS.txt
-
-[flake8]
-# Incompatible with black see https://github.com/ambv/black/issues/315
-# E203: Whitespace before ':'
-# W503: Line break occurred before a binary operator
-# B028: consider using the `!r` conversion flag
-ignore =
- E203,
- W503,
- B028,
-# Flake8 is less lenient than pylint and does not make any exceptions
-# (for docstrings, strings and comments in particular).
-max-line-length=115
-# Required for flake8-typing-imports (v1.12.0)
-# The plugin doesn't yet read the value from pyproject.toml
-min_python_version = 3.7.2