Enable Ruff's pygrep-hooks checks

This commit is contained in:
Adam Turner 2022-12-29 23:39:39 +00:00
parent 6a132eba5a
commit b89c33fc0a
4 changed files with 7 additions and 4 deletions

View File

@ -157,6 +157,8 @@ ignore = [
# flake8-bugbear opinionated (disabled by default in flake8)
'B904',
'B905',
# pygrep-hooks
"PGH003",
]
external = [ # Whitelist for RUF100 unkown code warnings
"E704",
@ -170,8 +172,9 @@ select = [
# plugins:
"B", # flake8-bugbear
"C4", # flake8-comprehensions
"PGH", # pygrep-hooks
"SIM", # flake8-simplify
"RUF100" # yesqa
"RUF100", # yesqa
]
[tool.ruff.per-file-ignores]

View File

@ -383,7 +383,7 @@ Doctest summary
context: Dict[str, Any] = {}
if self.config.doctest_global_setup:
exec(self.config.doctest_global_setup, context)
should_skip = eval(condition, context)
should_skip = eval(condition, context) # NoQA: PGH001
if self.config.doctest_global_cleanup:
exec(self.config.doctest_global_cleanup, context)
return should_skip

View File

@ -53,7 +53,7 @@ def process_ifconfig_nodes(app: Sphinx, doctree: nodes.document, docname: str) -
ns['builder'] = app.builder.name
for node in list(doctree.findall(ifconfig)):
try:
res = eval(node['expr'], ns)
res = eval(node['expr'], ns) # NoQA: PGH001
except Exception as err:
# handle exceptions in a clean fashion
from traceback import format_exception_only

View File

@ -51,7 +51,7 @@ def encode_string(s: str) -> str:
def decode_string(s: str) -> str:
return ESCAPED.sub(lambda m: eval('"' + m.group() + '"'), s)
return ESCAPED.sub(lambda m: eval('"' + m.group() + '"'), s) # NoQA: PGH001
reswords = set("""\