Cease using flake8 (#13204)

This commit is contained in:
Adam Turner 2025-01-02 21:01:20 +00:00 committed by GitHub
parent 4bf0b2b43a
commit bec014cf7e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
18 changed files with 93 additions and 157 deletions

38
.flake8
View File

@ -1,38 +0,0 @@
[flake8]
max-line-length = 95
ignore =
E116,
E203,
E241,
E251,
E501,
E741,
W503,
W504,
I101,
SIM102,
SIM103,
SIM105,
SIM114,
SIM115,
SIM117,
SIM223,
SIM401,
SIM907,
SIM910,
exclude =
.git,
.tox,
.venv,
venv,
node_modules/*,
tests/roots/*,
build/*,
doc/_build/*,
sphinx/search/*,
doc/usage/extensions/example*.py,
per-file-ignores =
doc/conf.py:W605
sphinx/events.py:E704,
tests/test_extensions/ext_napoleon_pep526_data_google.py:MLL001,
tests/test_extensions/ext_napoleon_pep526_data_numpy.py:MLL001,

View File

@ -45,28 +45,6 @@ jobs:
- name: Format with Ruff
run: ruff format . --diff
flake8:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3"
- name: Install uv
run: >
curl --no-progress-meter --location --fail
--proto '=https' --tlsv1.2
"https://astral.sh/uv/install.sh"
| sh
- name: Install dependencies
run: uv pip install --upgrade "flake8>=6.0"
- name: Lint with flake8
run: flake8 .
mypy:
runs-on: ubuntu-latest

View File

@ -77,7 +77,6 @@ ignore = [
"UP032", # Use f-string instead of `format` call
]
external = [ # Whitelist for RUF100 unknown code warnings
"E704",
"SIM113",
]
select = [

View File

@ -45,7 +45,6 @@ clean: clean
.PHONY: style-check
style-check:
@echo '[+] running flake8' ; flake8 .
@echo '[+] running ruff' ; ruff check .
.PHONY: format

View File

@ -81,7 +81,6 @@ docs = [
"sphinxcontrib-websupport",
]
lint = [
"flake8>=6.0",
"ruff==0.8.1",
"mypy==1.13.0",
"sphinx-lint>=0.9",

View File

@ -505,7 +505,7 @@ class Sphinx:
# ---- Core events -------------------------------------------------------
@overload
def connect( # NoQA: E704
def connect(
self,
event: Literal['config-inited'],
callback: Callable[[Sphinx, Config], None],
@ -513,7 +513,7 @@ class Sphinx:
) -> int: ...
@overload
def connect( # NoQA: E704
def connect(
self,
event: Literal['builder-inited'],
callback: Callable[[Sphinx], None],
@ -521,7 +521,7 @@ class Sphinx:
) -> int: ...
@overload
def connect( # NoQA: E704
def connect(
self,
event: Literal['env-get-outdated'],
callback: Callable[
@ -531,7 +531,7 @@ class Sphinx:
) -> int: ...
@overload
def connect( # NoQA: E704
def connect(
self,
event: Literal['env-before-read-docs'],
callback: Callable[[Sphinx, BuildEnvironment, list[str]], None],
@ -539,7 +539,7 @@ class Sphinx:
) -> int: ...
@overload
def connect( # NoQA: E704
def connect(
self,
event: Literal['env-purge-doc'],
callback: Callable[[Sphinx, BuildEnvironment, str], None],
@ -547,7 +547,7 @@ class Sphinx:
) -> int: ...
@overload
def connect( # NoQA: E704
def connect(
self,
event: Literal['source-read'],
callback: Callable[[Sphinx, str, list[str]], None],
@ -555,7 +555,7 @@ class Sphinx:
) -> int: ...
@overload
def connect( # NoQA: E704
def connect(
self,
event: Literal['include-read'],
callback: Callable[[Sphinx, Path, str, list[str]], None],
@ -563,7 +563,7 @@ class Sphinx:
) -> int: ...
@overload
def connect( # NoQA: E704
def connect(
self,
event: Literal['doctree-read'],
callback: Callable[[Sphinx, nodes.document], None],
@ -571,7 +571,7 @@ class Sphinx:
) -> int: ...
@overload
def connect( # NoQA: E704
def connect(
self,
event: Literal['env-merge-info'],
callback: Callable[
@ -581,7 +581,7 @@ class Sphinx:
) -> int: ...
@overload
def connect( # NoQA: E704
def connect(
self,
event: Literal['env-updated'],
callback: Callable[[Sphinx, BuildEnvironment], str],
@ -589,7 +589,7 @@ class Sphinx:
) -> int: ...
@overload
def connect( # NoQA: E704
def connect(
self,
event: Literal['env-get-updated'],
callback: Callable[[Sphinx, BuildEnvironment], Iterable[str]],
@ -597,7 +597,7 @@ class Sphinx:
) -> int: ...
@overload
def connect( # NoQA: E704
def connect(
self,
event: Literal['env-check-consistency'],
callback: Callable[[Sphinx, BuildEnvironment], None],
@ -605,7 +605,7 @@ class Sphinx:
) -> int: ...
@overload
def connect( # NoQA: E704
def connect(
self,
event: Literal['write-started'],
callback: Callable[[Sphinx, Builder], None],
@ -613,7 +613,7 @@ class Sphinx:
) -> int: ...
@overload
def connect( # NoQA: E704
def connect(
self,
event: Literal['doctree-resolved'],
callback: Callable[[Sphinx, nodes.document, str], None],
@ -621,7 +621,7 @@ class Sphinx:
) -> int: ...
@overload
def connect( # NoQA: E704
def connect(
self,
event: Literal['missing-reference'],
callback: Callable[
@ -632,7 +632,7 @@ class Sphinx:
) -> int: ...
@overload
def connect( # NoQA: E704
def connect(
self,
event: Literal['warn-missing-reference'],
callback: Callable[[Sphinx, Domain, addnodes.pending_xref], bool | None],
@ -640,7 +640,7 @@ class Sphinx:
) -> int: ...
@overload
def connect( # NoQA: E704
def connect(
self,
event: Literal['build-finished'],
callback: Callable[[Sphinx, Exception | None], None],
@ -650,7 +650,7 @@ class Sphinx:
# ---- Events from builtin builders --------------------------------------
@overload
def connect( # NoQA: E704
def connect(
self,
event: Literal['html-collect-pages'],
callback: Callable[[Sphinx], Iterable[tuple[str, dict[str, Any], str]]],
@ -658,7 +658,7 @@ class Sphinx:
) -> int: ...
@overload
def connect( # NoQA: E704
def connect(
self,
event: Literal['html-page-context'],
callback: Callable[
@ -668,7 +668,7 @@ class Sphinx:
) -> int: ...
@overload
def connect( # NoQA: E704
def connect(
self,
event: Literal['linkcheck-process-uri'],
callback: Callable[[Sphinx, str], str | None],
@ -678,7 +678,7 @@ class Sphinx:
# ---- Events from builtin extensions-- ----------------------------------
@overload
def connect( # NoQA: E704
def connect(
self,
event: Literal['object-description-transform'],
callback: Callable[[Sphinx, str, str, addnodes.desc_content], None],
@ -688,7 +688,7 @@ class Sphinx:
# ---- Events from first-party extensions --------------------------------
@overload
def connect( # NoQA: E704
def connect(
self,
event: Literal['autodoc-process-docstring'],
callback: _AutodocProcessDocstringListener,
@ -696,7 +696,7 @@ class Sphinx:
) -> int: ...
@overload
def connect( # NoQA: E704
def connect(
self,
event: Literal['autodoc-before-process-signature'],
callback: Callable[[Sphinx, Any, bool], None],
@ -704,7 +704,7 @@ class Sphinx:
) -> int: ...
@overload
def connect( # NoQA: E704
def connect(
self,
event: Literal['autodoc-process-signature'],
callback: Callable[
@ -725,7 +725,7 @@ class Sphinx:
) -> int: ...
@overload
def connect( # NoQA: E704
def connect(
self,
event: Literal['autodoc-process-bases'],
callback: Callable[[Sphinx, str, Any, dict[str, bool], list[str]], None],
@ -733,7 +733,7 @@ class Sphinx:
) -> int: ...
@overload
def connect( # NoQA: E704
def connect(
self,
event: Literal['autodoc-skip-member'],
callback: Callable[
@ -753,7 +753,7 @@ class Sphinx:
) -> int: ...
@overload
def connect( # NoQA: E704
def connect(
self,
event: Literal['todo-defined'],
callback: Callable[[Sphinx, todo_node], None],
@ -761,7 +761,7 @@ class Sphinx:
) -> int: ...
@overload
def connect( # NoQA: E704
def connect(
self,
event: Literal['viewcode-find-source'],
callback: Callable[
@ -772,7 +772,7 @@ class Sphinx:
) -> int: ...
@overload
def connect( # NoQA: E704
def connect(
self,
event: Literal['viewcode-follow-imported'],
callback: Callable[[Sphinx, str, str], str | None],
@ -782,7 +782,7 @@ class Sphinx:
# ---- Catch-all ---------------------------------------------------------
@overload
def connect( # NoQA: E704
def connect(
self,
event: str,
callback: Callable[..., Any],
@ -1405,7 +1405,7 @@ class Sphinx:
refs: `Transform Priority Range Categories`__
__ https://docutils.sourceforge.io/docs/ref/transforms.html#transform-priority-range-categories
""" # NoQA: E501,RUF100 # Flake8 thinks the URL is too long, Ruff special cases URLs.
"""
self.registry.add_transform(transform)
def add_post_transform(self, transform: type[Transform]) -> None:

View File

@ -32,7 +32,7 @@ if TYPE_CHECKING:
from typing import Protocol
class SupportsWrite(Protocol):
def write(self, text: str, /) -> int | None: ... # NoQA: E704
def write(self, text: str, /) -> int | None: ...
def handle_exception(

View File

@ -208,47 +208,47 @@ class _DomainsContainer:
# Mapping interface: builtin domains
@overload
def __getitem__(self, key: Literal['c']) -> CDomain: ... # NoQA: E704
def __getitem__(self, key: Literal['c']) -> CDomain: ...
@overload
def __getitem__(self, key: Literal['cpp']) -> CPPDomain: ... # NoQA: E704
def __getitem__(self, key: Literal['cpp']) -> CPPDomain: ...
@overload
def __getitem__(self, key: Literal['changeset']) -> ChangeSetDomain: ... # NoQA: E704
def __getitem__(self, key: Literal['changeset']) -> ChangeSetDomain: ...
@overload
def __getitem__(self, key: Literal['citation']) -> CitationDomain: ... # NoQA: E704
def __getitem__(self, key: Literal['citation']) -> CitationDomain: ...
@overload
def __getitem__(self, key: Literal['index']) -> IndexDomain: ... # NoQA: E704
def __getitem__(self, key: Literal['index']) -> IndexDomain: ...
@overload
def __getitem__(self, key: Literal['js']) -> JavaScriptDomain: ... # NoQA: E704
def __getitem__(self, key: Literal['js']) -> JavaScriptDomain: ...
@overload
def __getitem__(self, key: Literal['math']) -> MathDomain: ... # NoQA: E704
def __getitem__(self, key: Literal['math']) -> MathDomain: ...
@overload
def __getitem__(self, key: Literal['py']) -> PythonDomain: ... # NoQA: E704
def __getitem__(self, key: Literal['py']) -> PythonDomain: ...
@overload
def __getitem__(self, key: Literal['rst']) -> ReSTDomain: ... # NoQA: E704
def __getitem__(self, key: Literal['rst']) -> ReSTDomain: ...
@overload
def __getitem__(self, key: Literal['std']) -> StandardDomain: ... # NoQA: E704
def __getitem__(self, key: Literal['std']) -> StandardDomain: ...
# Mapping interface: first-party domains
@overload
def __getitem__(self, key: Literal['duration']) -> DurationDomain: ... # NoQA: E704
def __getitem__(self, key: Literal['duration']) -> DurationDomain: ...
@overload
def __getitem__(self, key: Literal['todo']) -> TodoDomain: ... # NoQA: E704
def __getitem__(self, key: Literal['todo']) -> TodoDomain: ...
# Mapping interface: third-party domains
@overload
def __getitem__(self, key: str) -> Domain: ... # NoQA: E704
def __getitem__(self, key: str) -> Domain: ...
def __getitem__(self, key: str) -> Domain:
if domain := getattr(self, key, None):

View File

@ -1073,10 +1073,7 @@ class CPPDomain(Domain):
try:
ast, is_shorthand = parser.parse_xref_object()
except DefinitionError as e:
# as arg to stop flake8 from complaining
def find_warning(e: Exception) -> tuple[str, Exception]:
if typ not in {'any', 'func'}:
return target, e
if typ in {'any', 'func'}:
# hax on top of the paren hax to try to get correct errors
parser2 = DefinitionParser(
target[:-2], location=node, config=env.config
@ -1084,13 +1081,16 @@ class CPPDomain(Domain):
try:
parser2.parse_xref_object()
except DefinitionError as e2:
return target[:-2], e2
# strange, that we don't get the error now, use the original
return target, e
target = target[:-2]
ex = e2
else:
# strange, that we don't get the error now, use the original
ex = e
else:
ex = e
t, ex = find_warning(e)
logger.warning(
'Unparseable C++ cross-reference: %r\n%s', t, ex, location=node
'Unparseable C++ cross-reference: %r\n%s', target, ex, location=node
)
return None, None
parent_key: LookupKey = node.get('cpp:parent_key', None)

View File

@ -29,11 +29,11 @@ OPERATORS: dict[type[ast.AST], str] = {
@overload
def unparse(node: None, code: str = '') -> None: ... # NoQA: E704
def unparse(node: None, code: str = '') -> None: ...
@overload
def unparse(node: ast.AST, code: str = '') -> str: ... # NoQA: E704
def unparse(node: ast.AST, code: str = '') -> str: ...
def unparse(node: ast.AST | None, code: str = '') -> str | None:

View File

@ -8,7 +8,7 @@ if TYPE_CHECKING:
from typing import Protocol
class SupportsWrite(Protocol):
def write(self, text: str, /) -> int | None: ... # NoQA: E704
def write(self, text: str, /) -> int | None: ...
class TeeStripANSI:

View File

@ -143,10 +143,10 @@ class _StrPathProperty:
self.instance_attr = f'_{name}' # i.e. '_srcdir'
@overload
def __get__(self, obj: None, objtype: None) -> _StrPathProperty: ... # NoQA: E704
def __get__(self, obj: None, objtype: None) -> _StrPathProperty: ...
@overload
def __get__(self, obj: object, objtype: type[object]) -> _StrPath: ... # NoQA: E704
def __get__(self, obj: object, objtype: type[object]) -> _StrPath: ...
def __get__(
self, obj: object | None, objtype: type[object] | None = None

View File

@ -12,30 +12,30 @@ if TYPE_CHECKING:
from typing import Final
# fmt: off
def reset(text: str) -> str: ... # NoQA: E704
def bold(text: str) -> str: ... # NoQA: E704
def faint(text: str) -> str: ... # NoQA: E704
def standout(text: str) -> str: ... # NoQA: E704
def underline(text: str) -> str: ... # NoQA: E704
def blink(text: str) -> str: ... # NoQA: E704
def reset(text: str) -> str: ...
def bold(text: str) -> str: ...
def faint(text: str) -> str: ...
def standout(text: str) -> str: ...
def underline(text: str) -> str: ...
def blink(text: str) -> str: ...
def black(text: str) -> str: ... # NoQA: E704
def white(text: str) -> str: ... # NoQA: E704
def red(text: str) -> str: ... # NoQA: E704
def green(text: str) -> str: ... # NoQA: E704
def yellow(text: str) -> str: ... # NoQA: E704
def blue(text: str) -> str: ... # NoQA: E704
def fuchsia(text: str) -> str: ... # NoQA: E704
def teal(text: str) -> str: ... # NoQA: E704
def black(text: str) -> str: ...
def white(text: str) -> str: ...
def red(text: str) -> str: ...
def green(text: str) -> str: ...
def yellow(text: str) -> str: ...
def blue(text: str) -> str: ...
def fuchsia(text: str) -> str: ...
def teal(text: str) -> str: ...
def darkgray(text: str) -> str: ... # NoQA: E704
def lightgray(text: str) -> str: ... # NoQA: E704
def darkred(text: str) -> str: ... # NoQA: E704
def darkgreen(text: str) -> str: ... # NoQA: E704
def brown(text: str) -> str: ... # NoQA: E704
def darkblue(text: str) -> str: ... # NoQA: E704
def purple(text: str) -> str: ... # NoQA: E704
def turquoise(text: str) -> str: ... # NoQA: E704
def darkgray(text: str) -> str: ...
def lightgray(text: str) -> str: ...
def darkred(text: str) -> str: ...
def darkgreen(text: str) -> str: ...
def brown(text: str) -> str: ...
def darkblue(text: str) -> str: ...
def purple(text: str) -> str: ...
def turquoise(text: str) -> str: ...
# fmt: on
try:

View File

@ -32,7 +32,7 @@ if TYPE_CHECKING:
from sphinx.environment import BuildEnvironment
class DateFormatter(Protocol):
def __call__( # NoQA: E704
def __call__(
self,
date: dt.date | None = ...,
format: str = ...,
@ -40,7 +40,7 @@ if TYPE_CHECKING:
) -> str: ...
class TimeFormatter(Protocol):
def __call__( # NoQA: E704
def __call__(
self,
time: dt.time | dt.datetime | float | None = ...,
format: str = ...,
@ -49,7 +49,7 @@ if TYPE_CHECKING:
) -> str: ...
class DatetimeFormatter(Protocol):
def __call__( # NoQA: E704
def __call__(
self,
datetime: dt.date | dt.time | float | None = ...,
format: str = ...,

View File

@ -56,11 +56,11 @@ def get_image_size(filename: str | PathLike[str]) -> tuple[int, int] | None:
@overload
def guess_mimetype(filename: PathLike[str] | str, default: str) -> str: ... # NoQA: E704
def guess_mimetype(filename: PathLike[str] | str, default: str) -> str: ...
@overload
def guess_mimetype( # NoQA: E704
def guess_mimetype(
filename: PathLike[str] | str, default: None = None
) -> str | None: ...

View File

@ -32,15 +32,15 @@ if TYPE_CHECKING:
from typing_extensions import TypeIs
class _SupportsGet(Protocol):
def __get__(self, instance: Any, owner: type | None = ..., /) -> Any: ... # NoQA: E704
def __get__(self, instance: Any, owner: type | None = ..., /) -> Any: ...
class _SupportsSet(Protocol):
# instance and value are contravariants but we do not need that precision
def __set__(self, instance: Any, value: Any, /) -> None: ... # NoQA: E704
def __set__(self, instance: Any, value: Any, /) -> None: ...
class _SupportsDelete(Protocol):
# instance is contravariant but we do not need that precision
def __delete__(self, instance: Any, /) -> None: ... # NoQA: E704
def __delete__(self, instance: Any, /) -> None: ...
_RoutineType: TypeAlias = (
types.FunctionType

View File

@ -95,7 +95,7 @@ PathMatcher: TypeAlias = Callable[[str], bool]
if TYPE_CHECKING:
class RoleFunction(Protocol):
def __call__( # NoQA: E704
def __call__(
self,
name: str,
rawtext: str,
@ -127,11 +127,11 @@ if TYPE_CHECKING:
_T_co = TypeVar('_T_co', str, bytes, covariant=True)
class _ReadableStream(Protocol[_T_co]): # NoQA: PYI046 (false positive)
def read(self, size: int = ...) -> _T_co: ... # NoQA: E704
def read(self, size: int = ...) -> _T_co: ...
def __enter__(self) -> Self: ... # NoQA: E704
def __enter__(self) -> Self: ...
def __exit__( # NoQA: E704
def __exit__(
self,
exc_type: type[BaseException] | None,
exc_val: BaseException | None,

View File

@ -37,7 +37,6 @@ extras =
# GitHub Workflow step
commands =
ruff check . --output-format github
flake8 .
mypy
pyright