Migrate from autoflake, black, isort, pyupgrade, flake8 and pydocstyle, to ruff (#11911)
ruff is faster and handle everything we had prior. isort configuration done based on the indication from https://github.com/astral-sh/ruff/issues/4670, previousely based on reorder-python-import (#11896) flake8-docstrings was a wrapper around pydocstyle (now archived) that explicitly asks to use ruff in https://github.com/PyCQA/pydocstyle/pull/658. flake8-typing-import is useful mainly for project that support python 3.7 and the one useful check will be implemented in https://github.com/astral-sh/ruff/issues/2302 We need to keep blacken-doc because ruff does not handle detection of python code inside .md and .rst. The direct link to the repo is now used to avoid a redirection. Manual fixes: - Lines that became too long - % formatting that was not done automatically - type: ignore that were moved around - noqa of hard to fix issues (UP031 generally) - fmt: off and fmt: on that is not really identical between black and ruff - autofix re-order in pre-commit from faster to slower Co-authored-by: Ran Benita <ran@unusedvar.com>
This commit is contained in:
@@ -3,13 +3,13 @@ import sys
|
||||
from types import FrameType
|
||||
from unittest import mock
|
||||
|
||||
import pytest
|
||||
from _pytest._code import Code
|
||||
from _pytest._code import ExceptionInfo
|
||||
from _pytest._code import Frame
|
||||
from _pytest._code import Source
|
||||
from _pytest._code.code import ExceptionChainRepr
|
||||
from _pytest._code.code import ReprFuncArgs
|
||||
import pytest
|
||||
|
||||
|
||||
def test_ne() -> None:
|
||||
|
||||
@@ -3,16 +3,15 @@ from __future__ import annotations
|
||||
import importlib
|
||||
import io
|
||||
import operator
|
||||
from pathlib import Path
|
||||
import queue
|
||||
import re
|
||||
import sys
|
||||
import textwrap
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import _pytest._code
|
||||
import pytest
|
||||
from _pytest._code.code import ExceptionChainRepr
|
||||
from _pytest._code.code import ExceptionInfo
|
||||
from _pytest._code.code import FormattedExcinfo
|
||||
@@ -22,6 +21,8 @@ from _pytest.pathlib import bestrelpath
|
||||
from _pytest.pathlib import import_path
|
||||
from _pytest.pytester import LineMatcher
|
||||
from _pytest.pytester import Pytester
|
||||
import pytest
|
||||
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from _pytest._code.code import _TracebackStyle
|
||||
@@ -1172,9 +1173,7 @@ raise ValueError()
|
||||
"funcargs": funcargs,
|
||||
"tbfilter": tbfilter,
|
||||
},
|
||||
id="style={},showlocals={},funcargs={},tbfilter={}".format(
|
||||
style, showlocals, funcargs, tbfilter
|
||||
),
|
||||
id=f"style={style},showlocals={showlocals},funcargs={funcargs},tbfilter={tbfilter}",
|
||||
)
|
||||
for style in ["long", "short", "line", "no", "native", "value", "auto"]
|
||||
for showlocals in (True, False)
|
||||
@@ -1338,7 +1337,7 @@ raise ValueError()
|
||||
"""
|
||||
raise_suffix = " from None" if mode == "from_none" else ""
|
||||
mod = importasmod(
|
||||
"""
|
||||
f"""
|
||||
def f():
|
||||
try:
|
||||
g()
|
||||
@@ -1346,9 +1345,7 @@ raise ValueError()
|
||||
raise AttributeError(){raise_suffix}
|
||||
def g():
|
||||
raise ValueError()
|
||||
""".format(
|
||||
raise_suffix=raise_suffix
|
||||
)
|
||||
"""
|
||||
)
|
||||
excinfo = pytest.raises(AttributeError, mod.f)
|
||||
r = excinfo.getrepr(style="long", chain=mode != "explicit_suppress")
|
||||
@@ -1360,9 +1357,7 @@ raise ValueError()
|
||||
assert tw_mock.lines[2] == " try:"
|
||||
assert tw_mock.lines[3] == " g()"
|
||||
assert tw_mock.lines[4] == " except Exception:"
|
||||
assert tw_mock.lines[5] == "> raise AttributeError(){}".format(
|
||||
raise_suffix
|
||||
)
|
||||
assert tw_mock.lines[5] == f"> raise AttributeError(){raise_suffix}"
|
||||
assert tw_mock.lines[6] == "E AttributeError"
|
||||
assert tw_mock.lines[7] == ""
|
||||
line = tw_mock.get_write_msg(8)
|
||||
@@ -1393,7 +1388,7 @@ raise ValueError()
|
||||
"""
|
||||
exc_handling_code = " from e" if reason == "cause" else ""
|
||||
mod = importasmod(
|
||||
"""
|
||||
f"""
|
||||
def f():
|
||||
try:
|
||||
g()
|
||||
@@ -1401,9 +1396,7 @@ raise ValueError()
|
||||
raise RuntimeError('runtime problem'){exc_handling_code}
|
||||
def g():
|
||||
raise ValueError('invalid value')
|
||||
""".format(
|
||||
exc_handling_code=exc_handling_code
|
||||
)
|
||||
"""
|
||||
)
|
||||
|
||||
with pytest.raises(RuntimeError) as excinfo:
|
||||
|
||||
Reference in New Issue
Block a user