mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Enable Ruff perflint (PERF) rules
This commit is contained in:
@@ -128,7 +128,12 @@ select = [
|
||||
# pandas-vet ('PD')
|
||||
# Pandas is not used in Sphinx
|
||||
# perflint ('PERF')
|
||||
# NOT YET USED
|
||||
"PERF101", # Do not cast an iterable to `list` before iterating over it
|
||||
"PERF102", # When using only the {subset} of a dict use the `{subset}()` method
|
||||
# "PERF203", # `try`-`except` within a loop incurs performance overhead
|
||||
# "PERF401", # Use a list comprehension to create a transformed list
|
||||
"PERF402", # Use `list` or `list.copy` to create a copy of a list
|
||||
"PERF403", # Use a dictionary comprehension instead of a for-loop
|
||||
# pygrep-hooks ('PGH')
|
||||
"PGH",
|
||||
# flake8-pie ('PIE')
|
||||
|
||||
@@ -69,13 +69,12 @@ def app_params(request: Any, test_params: dict, shared_result: SharedResult,
|
||||
|
||||
# ##### process pytest.mark.sphinx
|
||||
|
||||
pargs = {}
|
||||
pargs: dict[int, Any] = {}
|
||||
kwargs: dict[str, Any] = {}
|
||||
|
||||
# to avoid stacking positional args
|
||||
for info in reversed(list(request.node.iter_markers("sphinx"))):
|
||||
for i, a in enumerate(info.args):
|
||||
pargs[i] = a
|
||||
pargs |= dict(enumerate(info.args))
|
||||
kwargs.update(info.kwargs)
|
||||
|
||||
args = [pargs[i] for i in sorted(pargs.keys())]
|
||||
|
||||
@@ -26,8 +26,7 @@ def apidoc_params(request):
|
||||
kwargs = {}
|
||||
|
||||
for info in reversed(list(request.node.iter_markers("apidoc"))):
|
||||
for i, a in enumerate(info.args):
|
||||
pargs[i] = a
|
||||
pargs |= dict(enumerate(info.args))
|
||||
kwargs.update(info.kwargs)
|
||||
|
||||
args = [pargs[i] for i in sorted(pargs.keys())]
|
||||
|
||||
@@ -154,7 +154,7 @@ def test_get_items_summary(make_app, app_params):
|
||||
def new_get_items(self, names, *args, **kwargs):
|
||||
results = orig_get_items(self, names, *args, **kwargs)
|
||||
for name, result in zip(names, results):
|
||||
autosummary_items[name] = result
|
||||
autosummary_items[name] = result # NoQA: PERF403
|
||||
return results
|
||||
|
||||
def handler(app, what, name, obj, options, lines):
|
||||
|
||||
Reference in New Issue
Block a user