[lint] bump ruff version (#12170)

Co-authored-by: daniel.eades <daniel.eades@seebyte.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
This commit is contained in:
danieleades
2024-03-22 09:33:42 +00:00
committed by GitHub
parent 4eede5c534
commit 6c92c5c0f3
15 changed files with 25 additions and 66 deletions

View File

@@ -82,7 +82,7 @@ docs = [
]
lint = [
"flake8>=3.5.0",
"ruff==0.3.3",
"ruff==0.3.4",
"mypy==1.9.0",
"sphinx-lint",
"docutils-stubs",

View File

@@ -1033,9 +1033,7 @@ class StandaloneHTMLBuilder(Builder):
return True
if name == 'search' and self.search:
return True
if name == 'genindex' and self.get_builder_config('use_index', 'html'):
return True
return False
return name == 'genindex' and self.get_builder_config('use_index', 'html')
ctx['hasdoc'] = hasdoc
ctx['toctree'] = lambda **kwargs: self._get_local_toctree(pagename, **kwargs)

View File

@@ -463,10 +463,7 @@ def valid_dir(d: dict) -> bool:
d['dot'] + 'templates',
d['master'] + d['suffix'],
]
if set(reserved_names) & set(os.listdir(dir)):
return False
return True
return not set(reserved_names) & set(os.listdir(dir))
def get_parser() -> argparse.ArgumentParser:

View File

@@ -112,7 +112,7 @@ class CObject(ObjectDescription[ASTDeclaration]):
except NoOldIdError:
assert i < _max_id
# let's keep the newest first
ids = list(reversed(ids))
ids.reverse()
newestId = ids[0]
assert newestId # shouldn't be None

View File

@@ -128,7 +128,7 @@ class CPPObject(ObjectDescription[ASTDeclaration]):
except NoOldIdError:
assert i < _max_id
# let's keep the newest first
ids = list(reversed(ids))
ids.reverse()
newestId = ids[0]
assert newestId # shouldn't be None
if not re.compile(r'^[a-zA-Z0-9_]*$').match(newestId):

View File

@@ -209,10 +209,8 @@ def is_skipped_module(filename: str, opts: Any, _excludes: Sequence[re.Pattern[s
if not path.exists(filename):
# skip if the file doesn't exist
return True
if path.basename(filename).startswith('_') and not opts.includeprivate:
# skip if the module has a "private" name
return True
return False
# skip if the module has a "private" name
return path.basename(filename).startswith('_') and not opts.includeprivate
def walk(rootpath: str, excludes: Sequence[re.Pattern[str]], opts: Any,

View File

@@ -461,9 +461,7 @@ class Documenter:
subject = inspect.unpartial(self.object)
modname = self.get_attr(subject, '__module__', None)
if modname and modname != self.modname:
return False
return True
return not modname or modname == self.modname
def format_args(self, **kwargs: Any) -> str:
"""Format the argument signature of *self.object*.
@@ -2472,9 +2470,7 @@ class RuntimeInstanceAttributeMixin(DataDocumenterMixinBase):
# An instance variable defined in __init__().
if self.get_attribute_comment(parent, self.objpath[-1]): # type: ignore[attr-defined]
return True
if self.is_runtime_instance_attribute_not_commented(parent):
return True
return False
return self.is_runtime_instance_attribute_not_commented(parent)
def is_runtime_instance_attribute_not_commented(self, parent: Any) -> bool:
"""Check the subject is an attribute defined in __init__() without comment."""
@@ -2613,9 +2609,7 @@ class AttributeDocumenter(GenericAliasMixin, SlotsMixin, # type: ignore[misc]
return False
if inspect.isattributedescriptor(member):
return True
if not inspect.isroutine(member) and not isinstance(member, type):
return True
return False
return not inspect.isroutine(member) and not isinstance(member, type)
def document_members(self, all_members: bool = False) -> None:
pass

View File

@@ -509,9 +509,7 @@ Doctest summary
old_f = runner.failures
self.type = 'exec' # the snippet may contain multiple statements
runner.run(sim_doctest, out=self._warn_out, clear_globs=False)
if runner.failures > old_f:
return False
return True
return runner.failures <= old_f
# run the setup code
if not run_setup_cleanup(self.setup_runner, group.setup, 'setup'):

View File

@@ -80,9 +80,7 @@ def is_supported_builder(builder: Builder) -> bool:
return False
if builder.name == 'singlehtml':
return False
if builder.name.startswith('epub') and not builder.config.viewcode_enable_epub:
return False
return True
return not (builder.name.startswith('epub') and not builder.config.viewcode_enable_epub)
def doctree_read(app: Sphinx, doctree: Node) -> None:

View File

@@ -47,10 +47,7 @@ class SphinxPostTransform(SphinxTransform):
"""Check this transform working for current builder."""
if self.builders and self.app.builder.name not in self.builders:
return False
if self.formats and self.app.builder.format not in self.formats:
return False
return True
return not self.formats or self.app.builder.format in self.formats
def run(self, **kwargs: Any) -> None:
"""Main method of post transforms.

View File

@@ -63,9 +63,7 @@ def color_terminal() -> bool:
if 'COLORTERM' in os.environ:
return True
term = os.environ.get('TERM', 'dumb').lower()
if term in ('xterm', 'linux') or 'color' in term:
return True
return False
return term in ('xterm', 'linux') or 'color' in term
def nocolor() -> None:

View File

@@ -34,9 +34,7 @@ def _is_single_paragraph(node: nodes.field_body) -> bool:
for subnode in node[1:]: # type: Node
if not isinstance(subnode, nodes.system_message):
return False
if isinstance(node[0], nodes.paragraph):
return True
return False
return isinstance(node[0], nodes.paragraph)
class Field:

View File

@@ -270,10 +270,8 @@ def isattributedescriptor(obj: Any) -> bool:
WrapperDescriptorType)):
# attribute must not be a method descriptor
return False
if type(unwrapped).__name__ == "instancemethod":
# attribute must not be an instancemethod (C-API)
return False
return True
# attribute must not be an instancemethod (C-API)
return type(unwrapped).__name__ != "instancemethod"
return False
@@ -538,12 +536,9 @@ class TypeAliasNamespace(dict[str, Any]):
def _should_unwrap(subject: Callable) -> bool:
"""Check the function should be unwrapped on getting signature."""
__globals__ = getglobals(subject)
if (__globals__.get('__name__') == 'contextlib' and
__globals__.get('__file__') == contextlib.__file__):
# contextmanger should be unwrapped
return True
return False
# contextmanger should be unwrapped
return (__globals__.get('__name__') == 'contextlib' and
__globals__.get('__file__') == contextlib.__file__)
def signature(

View File

@@ -236,10 +236,7 @@ def is_translatable(node: Node) -> bool:
return False
return True
if isinstance(node, nodes.meta): # type: ignore[attr-defined]
return True
return False
return isinstance(node, nodes.meta) # type: ignore[attr-defined]
LITERAL_TYPE_NODES = (
@@ -614,10 +611,7 @@ def is_smartquotable(node: Node) -> bool:
if pnode.get('support_smartquotes', None) is False:
return False
if getattr(node, 'support_smartquotes', None) is False:
return False
return True
return getattr(node, 'support_smartquotes', None) is not False
def process_only_nodes(document: Node, tags: Tags) -> None:

View File

@@ -444,9 +444,7 @@ def test_linkcheck_request_headers(app):
def check_headers(self):
if "X-Secret" in self.headers:
return False
if self.headers["Accept"] != "text/html":
return False
return True
return self.headers["Accept"] == "text/html"
with http_server(custom_handler(success_criteria=check_headers)):
app.build()
@@ -467,9 +465,7 @@ def test_linkcheck_request_headers_no_slash(app):
def check_headers(self):
if "X-Secret" in self.headers:
return False
if self.headers["Accept"] != "application/json":
return False
return True
return self.headers["Accept"] == "application/json"
with http_server(custom_handler(success_criteria=check_headers)):
app.build()
@@ -490,9 +486,7 @@ def test_linkcheck_request_headers_default(app):
def check_headers(self):
if self.headers["X-Secret"] != "open sesami":
return False
if self.headers["Accept"] == "application/json":
return False
return True
return self.headers["Accept"] != "application/json"
with http_server(custom_handler(success_criteria=check_headers)):
app.build()