sphinx-doc / sphinx

The Sphinx documentation generator
https://www.sphinx-doc.org/
Other
6.45k stars 2.1k forks source link

ruff: Add new refurb (FURB) rules #11834

Closed DimitriPapadopoulos closed 5 months ago

DimitriPapadopoulos commented 9 months ago

Is your feature request related to a problem? Please describe.

New refurb (FURB) rules have been added to ruff, add them to file .ruff.toml in Sphinx.

Describe the solution you'd like

Add all rules, review the errors, fix those that make sense, suppress the rest:

541 refurb issues (ruff 0.1.7) ``` sphinx/builders/gettext.py:244:17 [FURB101]: Replace `with open(x, ...) as f: y = f.read()` with `y = Path(x).read_text(...)` sphinx/cmd/quickstart.py:385:5 [FURB101]: Replace `with open(x, ...) as f: y = f.read()` with `y = Path(x).read_text(...)` sphinx/environment/__init__.py:603:13 [FURB101]: Replace `with open(x, ...) as f: y = f.read()` with `y = Path(x).read_bytes()` sphinx/ext/autosummary/generate.py:531:13 [FURB101]: Replace `with open(x, ...) as f: y = f.read()` with `y = Path(x).read_text(...)` sphinx/ext/graphviz.py:139:17 [FURB101]: Replace `with open(x, ...) as f: y = f.read()` with `y = Path(x).read_text(...)` sphinx/search/__init__.py:549:13 [FURB101]: Replace `with open(x, ...) as f: y = f.read()` with `y = Path(x).read_text(...)` sphinx/search/__init__.py:551:13 [FURB101]: Replace `with open(x, ...) as f: y = f.read()` with `y = Path(x).read_text(...)` sphinx/theming.py:47:13 [FURB103]: Replace `with open(x, ...) as f: f.write(y)` with `Path(x).write_bytes(y)` sphinx/transforms/post_transforms/images.py:86:21 [FURB103]: Replace `with open(x, ...) as f: f.write(y)` with `Path(x).write_bytes(y)` sphinx/transforms/post_transforms/images.py:135:9 [FURB103]: Replace `with open(x, ...) as f: f.write(y)` with `Path(x).write_bytes(y)` sphinx/environment/collectors/dependencies.py:35:15 [FURB104]: Replace `os.getcwd()` with `Path.cwd()` sphinx/util/osutil.py:139:27 [FURB104]: Replace `os.getcwd()` with `Path.cwd()` sphinx/builders/gettext.py:186:5 [FURB107]: Replace `try: ... except ValueError: pass` with `with suppress(ValueError): ...` sphinx/builders/html/__init__.py:404:13 [FURB107]: Replace `try: ... except OSError: pass` with `with suppress(OSError): ...` sphinx/builders/html/__init__.py:1113:9 [FURB107]: Replace `try: ... except AttributeError: pass` with `with suppress(AttributeError): ...` sphinx/builders/html/transforms.py:64:17 [FURB107]: Replace `try: ... except IndexError: pass` with `with suppress(IndexError): ...` sphinx/builders/text.py:51:13 [FURB107]: Replace `try: ... except OSError: pass` with `with suppress(OSError): ...` sphinx/builders/xml.py:56:13 [FURB107]: Replace `try: ... except OSError: pass` with `with suppress(OSError): ...` sphinx/ext/autodoc/__init__.py:477:13 [FURB107]: Replace `try: ... except TypeError: pass` with `with suppress(TypeError): ...` sphinx/ext/autodoc/__init__.py:920:13 [FURB107]: Replace `try: ... except PycodeError: pass` with `with suppress(PycodeError): ...` sphinx/ext/autodoc/__init__.py:1538:13 [FURB107]: Replace `try: ... except ValueError: pass` with `with suppress(ValueError): ...` sphinx/ext/autodoc/__init__.py:1554:13 [FURB107]: Replace `try: ... except ValueError: pass` with `with suppress(ValueError): ...` sphinx/ext/autodoc/__init__.py:1565:13 [FURB107]: Replace `try: ... except ValueError: pass` with `with suppress(ValueError): ...` sphinx/ext/autodoc/__init__.py:1577:9 [FURB107]: Replace `try: ... except ValueError: pass` with `with suppress(ValueError): ...` sphinx/ext/autodoc/__init__.py:1657:17 [FURB107]: Replace `try: ... except PycodeError: pass` with `with suppress(PycodeError): ...` sphinx/ext/autodoc/__init__.py:1758:21 [FURB107]: Replace `try: ... except PycodeError: pass` with `with suppress(PycodeError): ...` sphinx/ext/autodoc/__init__.py:1862:13 [FURB107]: Replace `try: ... except PycodeError: pass` with `with suppress(PycodeError): ...` sphinx/ext/autodoc/__init__.py:1870:13 [FURB107]: Replace `try: ... except AttributeError: pass` with `with suppress(AttributeError): ...` sphinx/ext/autodoc/__init__.py:1985:13 [FURB107]: Replace `try: ... except ImportError: pass` with `with suppress(ImportError): ...` sphinx/ext/autodoc/__init__.py:2036:9 [FURB107]: Replace `try: ... except PycodeError: pass` with `with suppress(PycodeError): ...` sphinx/ext/autodoc/__init__.py:2085:13 [FURB107]: Replace `try: ... except ValueError: pass` with `with suppress(ValueError): ...` sphinx/ext/autodoc/__init__.py:2103:9 [FURB107]: Replace `try: ... except PycodeError: pass` with `with suppress(PycodeError): ...` sphinx/ext/autodoc/__init__.py:2450:13 [FURB107]: Replace `try: ... except (AttributeError, PycodeError): pass` with `with suppress(AttributeError, PycodeError): ...` sphinx/ext/autodoc/__init__.py:2471:13 [FURB107]: Replace `try: ... except ImportError: pass` with `with suppress(ImportError): ...` sphinx/ext/autodoc/__init__.py:2524:13 [FURB107]: Replace `try: ... except ImportError: pass` with `with suppress(ImportError): ...` sphinx/ext/autodoc/__init__.py:2589:9 [FURB107]: Replace `try: ... except (AttributeError, TypeError): pass` with `with suppress(AttributeError, TypeError): ...` sphinx/ext/autodoc/__init__.py:2594:17 [FURB107]: Replace `try: ... except (AttributeError, PycodeError): pass` with `with suppress(AttributeError, PycodeError): ...` sphinx/ext/autodoc/__init__.py:2655:13 [FURB107]: Replace `try: ... except ValueError: pass` with `with suppress(ValueError): ...` sphinx/ext/autodoc/__init__.py:2667:13 [FURB107]: Replace `try: ... except (AttributeError, PycodeError): pass` with `with suppress(AttributeError, PycodeError): ...` sphinx/ext/autodoc/importer.py:35:5 [FURB107]: Replace `try: ... except AttributeError: pass` with `with suppress(AttributeError): ...` sphinx/ext/autodoc/importer.py:46:5 [FURB107]: Replace `try: ... except AttributeError: pass` with `with suppress(AttributeError): ...` sphinx/ext/autodoc/importer.py:208:5 [FURB107]: Replace `try: ... except (TypeError, ValueError): pass` with `with suppress(TypeError, ValueError): ...` sphinx/ext/autodoc/importer.py:269:5 [FURB107]: Replace `try: ... except (TypeError, ValueError): pass` with `with suppress(TypeError, ValueError): ...` sphinx/ext/autodoc/importer.py:296:5 [FURB107]: Replace `try: ... except AttributeError: pass` with `with suppress(AttributeError): ...` sphinx/ext/autodoc/mock.py:178:5 [FURB107]: Replace `try: ... except AttributeError: pass` with `with suppress(AttributeError): ...` sphinx/ext/autodoc/typehints.py:30:5 [FURB107]: Replace `try: ... except (TypeError, ValueError): pass` with `with suppress(TypeError, ValueError): ...` sphinx/ext/autosummary/__init__.py:131:5 [FURB107]: Replace `try: ... except IndexError: pass` with `with suppress(IndexError): ...` sphinx/ext/autosummary/__init__.py:412:21 [FURB107]: Replace `try: ... except IndexError: pass` with `with suppress(IndexError): ...` sphinx/ext/autosummary/generate.py:417:5 [FURB107]: Replace `try: ... except PycodeError: pass` with `with suppress(PycodeError): ...` sphinx/ext/autosummary/generate.py:444:9 [FURB107]: Replace `try: ... except ImportError: pass` with `with suppress(ImportError): ...` sphinx/ext/inheritance_diagram.py:200:13 [FURB107]: Replace `try: ... except Exception: pass` with `with suppress(Exception): ...` sphinx/ext/todo.py:172:9 [FURB107]: Replace `try: ... except NoUri: pass` with `with suppress(NoUri): ...` sphinx/ext/viewcode.py:232:5 [FURB107]: Replace `try: ... except OSError: pass` with `with suppress(OSError): ...` sphinx/jinja2glue.py:217:13 [FURB107]: Replace `try: ... except TemplateNotFound: pass` with `with suppress(TemplateNotFound): ...` sphinx/locale/__init__.py:124:9 [FURB107]: Replace `try: ... except Exception: pass` with `with suppress(Exception): ...` sphinx/pycode/__init__.py:43:13 [FURB107]: Replace `try: ... except ImportError: pass` with `with suppress(ImportError): ...` sphinx/pycode/parser.py:286:13 [FURB107]: Replace `try: ... except NotImplementedError: pass` with `with suppress(NotImplementedError): ...` sphinx/pycode/parser.py:302:13 [FURB107]: Replace `try: ... except NotImplementedError: pass` with `with suppress(NotImplementedError): ...` sphinx/pycode/parser.py:408:13 [FURB107]: Replace `try: ... except TypeError: pass` with `with suppress(TypeError): ...` sphinx/registry.py:487:9 [FURB107]: Replace `try: ... except KeyError: pass` with `with suppress(KeyError): ...` sphinx/testing/fixtures.py:212:5 [FURB107]: Replace `try: ... except OSError: pass` with `with suppress(OSError): ...` sphinx/theming.py:198:9 [FURB107]: Replace `try: ... except KeyError: pass` with `with suppress(KeyError): ...` sphinx/transforms/post_transforms/code.py:122:13 [FURB107]: Replace `try: ... except Exception: pass` with `with suppress(Exception): ...` sphinx/util/inspect.py:334:9 [FURB107]: Replace `try: ... except Exception: pass` with `with suppress(Exception): ...` sphinx/util/inspect.py:560:5 [FURB107]: Replace `try: ... except Exception: pass` with `with suppress(Exception): ...` sphinx/util/inspect.py:608:9 [FURB107]: Replace `try: ... except (NameError, TypeError): pass` with `with suppress(NameError, TypeError): ...` sphinx/util/osutil.py:184:9 [FURB107]: Replace `try: ... except OSError: pass` with `with suppress(OSError): ...` sphinx/util/template.py:131:13 [FURB107]: Replace `try: ... except TemplateNotFound: pass` with `with suppress(TemplateNotFound): ...` sphinx/versioning.py:157:13 [FURB107]: Replace `try: ... except OSError: pass` with `with suppress(OSError): ...` sphinx/writers/latex.py:1437:13 [FURB107]: Replace `try: ... except KeyError: pass` with `with suppress(KeyError): ...` sphinx/writers/texinfo.py:661:9 [FURB107]: Replace `try: ... except (IndexError, AttributeError): pass` with `with suppress(IndexError, AttributeError): ...` sphinx/domains/cpp.py:4562:21 [FURB108]: Replace `x == y or z == y` with `y in (x, z)` sphinx/ext/autodoc/__init__.py:1796:18 [FURB108]: Replace `x == y or z == y` with `y in (x, z)` sphinx/ext/autodoc/__init__.py:1807:22 [FURB108]: Replace `x == y or z == y` with `y in (x, z)` sphinx/ext/autodoc/__init__.py:2323:18 [FURB108]: Replace `x == y or z == y` with `y in (x, z)` sphinx/ext/autodoc/__init__.py:2336:18 [FURB108]: Replace `x == y or z == y` with `y in (x, z)` sphinx/writers/text.py:221:24 [FURB108]: Replace `x == y or z == y` with `y in (x, z)` sphinx/builders/html/__init__.py:891:53 [FURB109]: Replace `in [x, y, z]` with `in (x, y, z)` sphinx/domains/c.py:2243:22 [FURB109]: Replace `in [x, y, z]` with `in (x, y, z)` sphinx/domains/cpp.py:5304:22 [FURB109]: Replace `in [x, y, z]` with `in (x, y, z)` sphinx/ext/imgmath.py:143:34 [FURB109]: Replace `not in [x, y, z]` with `not in (x, y, z)` sphinx/ext/imgmath.py:152:34 [FURB109]: Replace `in [x, y, z]` with `in (x, y, z)` sphinx/pycode/ast.py:118:48 [FURB109]: Replace `in [x, y, z]` with `in (x, y, z)` sphinx/util/inspect.py:223:21 [FURB109]: Replace `in [x, y, z]` with `in (x, y, z)` sphinx/writers/latex.py:2125:23 [FURB109]: Replace `in [x, y, z]` with `in (x, y, z)` sphinx/writers/latex.py:2128:25 [FURB109]: Replace `in [x, y, z]` with `in (x, y, z)` sphinx/writers/latex.py:2131:25 [FURB109]: Replace `in [x, y, z]` with `in (x, y, z)` sphinx/util/cfamily.py:110:32 [FURB111]: Replace `lambda ast: str(ast)` with `str` sphinx/builders/latex/__init__.py:377:21 [FURB113]: Use `x.extend(...)` instead of repeatedly calling `x.append()` sphinx/builders/texinfo.py:168:21 [FURB113]: Use `x.extend(...)` instead of repeatedly calling `x.append()` sphinx/domains/c.py:544:9 [FURB113]: Use `x.extend(...)` instead of repeatedly calling `x.append()` sphinx/domains/c.py:568:13 [FURB113]: Use `x.extend(...)` instead of repeatedly calling `x.append()` sphinx/domains/c.py:599:13 [FURB113]: Use `x.extend(...)` instead of repeatedly calling `x.append()` sphinx/domains/c.py:673:13 [FURB113]: Use `x.extend(...)` instead of repeatedly calling `x.append()` sphinx/domains/c.py:730:13 [FURB113]: Use `x.extend(...)` instead of repeatedly calling `x.append()` sphinx/domains/c.py:1021:9 [FURB113]: Use `x.extend(...)` instead of repeatedly calling `x.append()` sphinx/domains/c.py:1128:9 [FURB113]: Use `x.extend(...)` instead of repeatedly calling `x.append()` sphinx/domains/c.py:1421:13 [FURB113]: Use `x.extend(...)` instead of repeatedly calling `x.append()` sphinx/domains/c.py:2183:13 [FURB113]: Use `x.extend(...)` instead of repeatedly calling `x.append()` sphinx/domains/c.py:2443:21 [FURB113]: Use `x.extend(...)` instead of repeatedly calling `x.append()` sphinx/domains/c.py:3155:17 [FURB113]: Use `x.extend(...)` instead of repeatedly calling `x.append()` sphinx/domains/cpp.py:1016:13 [FURB113]: Use `x.extend(...)` instead of repeatedly calling `x.append()` sphinx/domains/cpp.py:1022:13 [FURB113]: Use `x.extend(...)` instead of repeatedly calling `x.append()` sphinx/domains/cpp.py:1237:9 [FURB113]: Use `x.extend(...)` instead of repeatedly calling `x.append()` sphinx/domains/cpp.py:1424:9 [FURB113]: Use `x.extend(...)` instead of repeatedly calling `x.append()` sphinx/domains/cpp.py:1492:9 [FURB113]: Use `x.extend(...)` instead of repeatedly calling `x.append()` sphinx/domains/cpp.py:1519:13 [FURB113]: Use `x.extend(...)` instead of repeatedly calling `x.append()` sphinx/domains/cpp.py:1529:13 [FURB113]: Use `x.extend(...)` instead of repeatedly calling `x.append()` sphinx/domains/cpp.py:1557:9 [FURB113]: Use `x.extend(...)` instead of repeatedly calling `x.append()` sphinx/domains/cpp.py:1567:9 [FURB113]: Use `x.extend(...)` instead of repeatedly calling `x.append()` sphinx/domains/cpp.py:1626:9 [FURB113]: Use `x.extend(...)` instead of repeatedly calling `x.append()` sphinx/domains/cpp.py:1636:9 [FURB113]: Use `x.extend(...)` instead of repeatedly calling `x.append()` sphinx/domains/cpp.py:1665:13 [FURB113]: Use `x.extend(...)` instead of repeatedly calling `x.append()` sphinx/domains/cpp.py:1848:13 [FURB113]: Use `x.extend(...)` instead of repeatedly calling `x.append()` sphinx/domains/cpp.py:1994:13 [FURB113]: Use `x.extend(...)` instead of repeatedly calling `x.append()` sphinx/domains/cpp.py:1998:13 [FURB113]: Use `x.extend(...)` instead of repeatedly calling `x.append()` sphinx/domains/cpp.py:2135:13 [FURB113]: Use `x.extend(...)` instead of repeatedly calling `x.append()` sphinx/domains/cpp.py:2138:13 [FURB113]: Use `x.extend(...)` instead of repeatedly calling `x.append()` sphinx/domains/cpp.py:2141:13 [FURB113]: Use `x.extend(...)` instead of repeatedly calling `x.append()` sphinx/domains/cpp.py:2148:13 [FURB113]: Use `x.extend(...)` instead of repeatedly calling `x.append()` sphinx/domains/cpp.py:2151:13 [FURB113]: Use `x.extend(...)` instead of repeatedly calling `x.append()` sphinx/domains/cpp.py:2231:13 [FURB113]: Use `x.extend(...)` instead of repeatedly calling `x.append()` sphinx/domains/cpp.py:2542:13 [FURB113]: Use `x.extend(...)` instead of repeatedly calling `x.append()` sphinx/domains/cpp.py:2611:9 [FURB113]: Use `x.extend(...)` instead of repeatedly calling `x.append()` sphinx/domains/cpp.py:2899:9 [FURB113]: Use `x.extend(...)` instead of repeatedly calling `x.append()` sphinx/domains/cpp.py:2997:9 [FURB113]: Use `x.extend(...)` instead of repeatedly calling `x.append()` sphinx/domains/cpp.py:3136:21 [FURB113]: Use `x.extend(...)` instead of repeatedly calling `x.append()` sphinx/domains/cpp.py:3150:17 [FURB113]: Use `x.extend(...)` instead of repeatedly calling `x.append()` sphinx/domains/cpp.py:3169:25 [FURB113]: Use `x.extend(...)` instead of repeatedly calling `x.append()` sphinx/domains/cpp.py:3307:13 [FURB113]: Use `x.extend(...)` instead of repeatedly calling `x.append()` sphinx/domains/cpp.py:3367:13 [FURB113]: Use `x.extend(...)` instead of repeatedly calling `x.append()` sphinx/domains/cpp.py:3485:13 [FURB113]: Use `x.extend(...)` instead of repeatedly calling `x.append()` sphinx/domains/cpp.py:3492:13 [FURB113]: Use `x.extend(...)` instead of repeatedly calling `x.append()` sphinx/domains/cpp.py:3528:13 [FURB113]: Use `x.extend(...)` instead of repeatedly calling `x.append()` sphinx/domains/cpp.py:3607:13 [FURB113]: Use `x.extend(...)` instead of repeatedly calling `x.append()` sphinx/domains/cpp.py:3777:13 [FURB113]: Use `x.extend(...)` instead of repeatedly calling `x.append()` sphinx/domains/cpp.py:3784:9 [FURB113]: Use `x.extend(...)` instead of repeatedly calling `x.append()` sphinx/domains/cpp.py:3788:13 [FURB113]: Use `x.extend(...)` instead of repeatedly calling `x.append()` sphinx/domains/cpp.py:3909:9 [FURB113]: Use `x.extend(...)` instead of repeatedly calling `x.append()` sphinx/domains/cpp.py:3916:9 [FURB113]: Use `x.extend(...)` instead of repeatedly calling `x.append()` sphinx/domains/cpp.py:3922:9 [FURB113]: Use `x.extend(...)` instead of repeatedly calling `x.append()` sphinx/domains/cpp.py:4094:13 [FURB113]: Use `x.extend(...)` instead of repeatedly calling `x.append()` sphinx/domains/cpp.py:4100:13 [FURB113]: Use `x.extend(...)` instead of repeatedly calling `x.append()` sphinx/domains/cpp.py:5211:17 [FURB113]: Use `x.extend(...)` instead of repeatedly calling `x.append()` sphinx/domains/cpp.py:5224:17 [FURB113]: Use `x.extend(...)` instead of repeatedly calling `x.append()` sphinx/domains/cpp.py:5227:13 [FURB113]: Use `x.extend(...)` instead of repeatedly calling `x.append()` sphinx/domains/cpp.py:5556:21 [FURB113]: Use `x.extend(...)` instead of repeatedly calling `x.append()` sphinx/domains/cpp.py:5583:21 [FURB113]: Use `x.extend(...)` instead of repeatedly calling `x.append()` sphinx/domains/cpp.py:5743:21 [FURB113]: Use `x.extend(...)` instead of repeatedly calling `x.append()` sphinx/domains/cpp.py:6759:13 [FURB113]: Use `x.extend(...)` instead of repeatedly calling `x.append()` sphinx/domains/cpp.py:6897:17 [FURB113]: Use `x.extend(...)` instead of repeatedly calling `x.append()` sphinx/domains/cpp.py:7197:17 [FURB113]: Use `x.extend(...)` instead of repeatedly calling `x.append()` sphinx/domains/cpp.py:7219:17 [FURB113]: Use `x.extend(...)` instead of repeatedly calling `x.append()` sphinx/domains/python.py:181:21 [FURB113]: Use `x.extend(...)` instead of repeatedly calling `x.append()` sphinx/domains/python.py:214:21 [FURB113]: Use `x.extend(...)` instead of repeatedly calling `x.append()` sphinx/domains/python.py:1088:13 [FURB113]: Use `x.extend(...)` instead of repeatedly calling `x.append()` sphinx/domains/python.py:1091:13 [FURB113]: Use `x.extend(...)` instead of repeatedly calling `x.append()` sphinx/domains/python.py:1094:13 [FURB113]: Use `x.extend(...)` instead of repeatedly calling `x.append()` sphinx/domains/python.py:1097:13 [FURB113]: Use `x.extend(...)` instead of repeatedly calling `x.append()` sphinx/domains/python.py:1100:13 [FURB113]: Use `x.extend(...)` instead of repeatedly calling `x.append()` sphinx/domains/python.py:1235:13 [FURB113]: Use `x.extend(...)` instead of repeatedly calling `x.append()` sphinx/domains/python.py:1238:13 [FURB113]: Use `x.extend(...)` instead of repeatedly calling `x.append()` sphinx/domains/python.py:1241:9 [FURB113]: Use `x.extend(...)` instead of repeatedly calling `x.append()` sphinx/domains/python.py:1312:13 [FURB113]: Use `x.extend(...)` instead of repeatedly calling `x.append()` sphinx/ext/inheritance_diagram.py:313:9 [FURB113]: Use `x.extend(...)` instead of repeatedly calling `x.append()` sphinx/roles.py:299:21 [FURB113]: Use `x.extend(...)` instead of repeatedly calling `x.append()` sphinx/search/ja.py:426:9 [FURB113]: Use `x.extend(...)` instead of repeatedly calling `x.append()` sphinx/util/cfamily.py:268:17 [FURB113]: Use `x.extend(...)` instead of repeatedly calling `x.append()` sphinx/util/cfamily.py:273:21 [FURB113]: Use `x.extend(...)` instead of repeatedly calling `x.append()` sphinx/writers/latex.py:480:13 [FURB113]: Use `x.extend(...)` instead of repeatedly calling `x.append()` sphinx/builders/linkcheck.py:339:12 [FURB115]: Replace `len(x) == 0` with `not x` sphinx/directives/code.py:290:16 [FURB115]: Replace `x == []` with `not x` sphinx/domains/c.py:149:16 [FURB115]: Replace `len(x) != 0` with `x` sphinx/domains/c.py:195:16 [FURB115]: Replace `len(x) > 0` with `x` sphinx/domains/c.py:249:45 [FURB115]: Replace `len(x) == 0` with `not x` sphinx/domains/c.py:559:16 [FURB115]: Replace `len(x) > 0` with `x` sphinx/domains/c.py:590:16 [FURB115]: Replace `len(x) > 0` with `x` sphinx/domains/c.py:644:16 [FURB115]: Replace `len(x) != 0` with `x` sphinx/domains/c.py:813:16 [FURB115]: Replace `len(x) != 0` with `x` sphinx/domains/c.py:817:12 [FURB115]: Replace `len(x) != 0` with `x` sphinx/domains/c.py:852:12 [FURB115]: Replace `len(x) > 0` with `x` sphinx/domains/c.py:855:16 [FURB115]: Replace `len(x) > 0` with `x` sphinx/domains/c.py:859:16 [FURB115]: Replace `len(x) > 0` with `x` sphinx/domains/c.py:860:20 [FURB115]: Replace `len(x) > 0` with `x` sphinx/domains/c.py:875:16 [FURB115]: Replace `len(x) > 0` with `x` sphinx/domains/c.py:881:16 [FURB115]: Replace `len(x) > 0` with `x` sphinx/domains/c.py:1240:58 [FURB115]: Replace `len(x) > 0` with `x` sphinx/domains/c.py:1256:17 [FURB115]: Replace `len(x) > 0` with `x` sphinx/domains/c.py:1891:12 [FURB115]: Replace `len(x) == 0` with `not x` sphinx/domains/c.py:1955:12 [FURB115]: Replace `len(x) == 0` with `not x` sphinx/domains/c.py:1991:12 [FURB115]: Replace `len(x) == 0` with `not x` sphinx/domains/c.py:2164:12 [FURB115]: Replace `len(x) == 0` with `not x` sphinx/domains/c.py:2577:21 [FURB115]: Replace `len(x) == 0` with `not x` sphinx/domains/c.py:2581:22 [FURB115]: Replace `len(x) > 0` with `x` sphinx/domains/c.py:2584:16 [FURB115]: Replace `len(x) > 0` with `x` sphinx/domains/c.py:2639:12 [FURB115]: Replace `len(x) == 0` with `not x` sphinx/domains/c.py:2842:30 [FURB115]: Replace `len(x) == 0` with `not x` sphinx/domains/cpp.py:615:16 [FURB115]: Replace `len(x) != 0` with `x` sphinx/domains/cpp.py:678:20 [FURB115]: Replace `len(x) == 0` with `not x` sphinx/domains/cpp.py:679:20 [FURB115]: Replace `len(x) == 0` with `not x` sphinx/domains/cpp.py:725:16 [FURB115]: Replace `len(x) > 0` with `x` sphinx/domains/cpp.py:753:35 [FURB115]: Replace `len(x) > 0` with `x` sphinx/domains/cpp.py:758:35 [FURB115]: Replace `len(x) > 0` with `x` sphinx/domains/cpp.py:824:45 [FURB115]: Replace `len(x) == 0` with `not x` sphinx/domains/cpp.py:1510:16 [FURB115]: Replace `len(x) > 0` with `x` sphinx/domains/cpp.py:1655:16 [FURB115]: Replace `len(x) > 0` with `x` sphinx/domains/cpp.py:1902:16 [FURB115]: Replace `len(x) != 0` with `x` sphinx/domains/cpp.py:2379:12 [FURB115]: Replace `len(x) > 0` with `x` sphinx/domains/cpp.py:2382:16 [FURB115]: Replace `len(x) > 0` with `x` sphinx/domains/cpp.py:2386:16 [FURB115]: Replace `len(x) > 0` with `x` sphinx/domains/cpp.py:2387:20 [FURB115]: Replace `len(x) > 0` with `x` sphinx/domains/cpp.py:2407:16 [FURB115]: Replace `len(x) > 0` with `x` sphinx/domains/cpp.py:3188:58 [FURB115]: Replace `len(x) > 0` with `x` sphinx/domains/cpp.py:3204:17 [FURB115]: Replace `len(x) > 0` with `x` sphinx/domains/cpp.py:3898:16 [FURB115]: Replace `len(x) > 0` with `x` sphinx/domains/cpp.py:4713:12 [FURB115]: Replace `len(x) == 0` with `not x` sphinx/domains/cpp.py:4781:12 [FURB115]: Replace `len(x) == 0` with `not x` sphinx/domains/cpp.py:4822:12 [FURB115]: Replace `len(x) == 0` with `not x` sphinx/domains/cpp.py:4895:16 [FURB115]: Replace `len(x) == 0` with `not x` sphinx/domains/cpp.py:5130:12 [FURB115]: Replace `len(x) != 0` with `x` sphinx/domains/cpp.py:5184:12 [FURB115]: Replace `len(x) == 0` with `not x` sphinx/domains/cpp.py:5903:21 [FURB115]: Replace `len(x) == 0` with `not x` sphinx/domains/cpp.py:5907:22 [FURB115]: Replace `len(x) > 0` with `x` sphinx/domains/cpp.py:5910:16 [FURB115]: Replace `len(x) > 0` with `x` sphinx/domains/cpp.py:6024:16 [FURB115]: Replace `len(x) > 0` with `x` sphinx/domains/cpp.py:6034:42 [FURB115]: Replace `len(x) > 0` with `x` sphinx/domains/cpp.py:6088:20 [FURB115]: Replace `len(x) != 0` with `x` sphinx/domains/cpp.py:6092:20 [FURB115]: Replace `len(x) != 0` with `x` sphinx/domains/cpp.py:6100:12 [FURB115]: Replace `len(x) == 0` with `not x` sphinx/domains/cpp.py:6110:16 [FURB115]: Replace `len(x) != 0` with `x` sphinx/domains/cpp.py:6115:16 [FURB115]: Replace `len(x) != 0` with `x` sphinx/domains/cpp.py:6123:16 [FURB115]: Replace `len(x) != 0` with `x` sphinx/domains/cpp.py:6128:16 [FURB115]: Replace `len(x) != 0` with `x` sphinx/domains/cpp.py:6458:34 [FURB115]: Replace `len(x) == 0` with `not x` sphinx/domains/cpp.py:7038:51 [FURB115]: Replace `len(x) == 0` with `not x` sphinx/domains/cpp.py:7048:44 [FURB115]: Replace `len(x) > 0` with `x` sphinx/domains/cpp.py:7052:12 [FURB115]: Replace `len(x) == 0` with `not x` sphinx/domains/cpp.py:7054:12 [FURB115]: Replace `len(x) == 0` with `not x` sphinx/domains/cpp.py:7770:16 [FURB115]: Replace `len(x) == 0` with `not x` sphinx/domains/rst.py:120:12 [FURB115]: Replace `len(x) > 0` with `x` sphinx/domains/std.py:413:8 [FURB115]: Replace `len(x) != 0` with `x` sphinx/domains/std.py:484:20 [FURB115]: Replace `len(x) != 0` with `x` sphinx/ext/autodoc/typehints.py:63:12 [FURB115]: Replace `x == []` with `not x` sphinx/ext/autosummary/__init__.py:538:8 [FURB115]: Replace `x == []` with `not x` sphinx/ext/autosummary/__init__.py:717:12 [FURB115]: Replace `len(x) == 0` with `not x` sphinx/ext/coverage.py:287:16 [FURB115]: Replace `len(x)` with `x` sphinx/ext/intersphinx.py:240:12 [FURB115]: Replace `x == []` with `not x` sphinx/io.py:49:12 [FURB115]: Replace `len(x) > 0` with `x` sphinx/util/cfamily.py:260:16 [FURB115]: Replace `len(x) > 0` with `x` sphinx/util/cfamily.py:271:24 [FURB115]: Replace `len(x) == 0` with `not x` sphinx/util/cfamily.py:385:16 [FURB115]: Replace `len(x) == 0` with `not x` sphinx/util/cfamily.py:389:18 [FURB115]: Replace `len(x) > 0` with `x` sphinx/util/docstrings.py:59:8 [FURB115]: Replace `len(x)` with `x` sphinx/util/inspect.py:586:16 [FURB115]: Replace `len(x) > 0` with `x` sphinx/util/math.py:40:8 [FURB115]: Replace `len(x) == 0` with `not x` sphinx/writers/texinfo.py:527:19 [FURB116]: Replace `hex(num)[2:]` with `f"{num:x}"` sphinx/domains/c.py:3678:59 [FURB123]: Replace `str(x)` with `x` sphinx/domains/cpp.py:7851:59 [FURB123]: Replace `str(x)` with `x` sphinx/environment/adapters/toctree.py:86:22 [FURB123]: Replace `int(x)` with `x` sphinx/environment/collectors/toctree.py:204:34 [FURB123]: Replace `list(x)` with `x.copy()` sphinx/ext/autodoc/importer.py:100:19 [FURB123]: Replace `list(x)` with `x.copy()` sphinx/ext/napoleon/docstring.py:1289:33 [FURB123]: Replace `list(x)` with `x.copy()` sphinx/jinja2glue.py:63:11 [FURB123]: Replace `list(x)` with `x.copy()` sphinx/util/nodes.py:463:12 [FURB123]: Replace `str(x)` with `x` sphinx/writers/latex.py:464:37 [FURB123]: Replace `str(x)` with `x` sphinx/domains/c.py:2317:16 [FURB124]: Replace `x == y and y == z` with `x == y == z` sphinx/domains/c.py:2483:24 [FURB124]: Replace `x == y and z == y` with `x == y == z` sphinx/domains/cpp.py:5441:16 [FURB124]: Replace `x == y and y == z` with `x == y == z` sphinx/domains/cpp.py:5786:24 [FURB124]: Replace `x == y and z == y` with `x == y == z` sphinx/ext/apidoc.py:71:8 [FURB124]: Replace `x is y and z is y` with `x is y is z` sphinx/ext/napoleon/docstring.py:1178:12 [FURB124]: Replace `x is y and z is y` with `x is y is z` sphinx/pycode/parser.py:479:29 [FURB124]: Replace `x == y and z == y` with `x == y == z` sphinx/directives/__init__.py:121:9 [FURB125]: Return is redundant here sphinx/search/__init__.py:511:13 [FURB125]: Return is redundant here sphinx/addnodes.py:174:13 [FURB126]: Replace `else: return x` with `return x` sphinx/application.py:307:13 [FURB126]: Replace `else: return x` with `return x` sphinx/builders/__init__.py:226:17 [FURB126]: Replace `else: return x` with `return x` sphinx/builders/html/__init__.py:99:9 [FURB126]: Replace `else: return x` with `return x` sphinx/builders/html/transforms.py:76:13 [FURB126]: Replace `else: return x` with `return x` sphinx/builders/linkcheck.py:479:13 [FURB126]: Replace `else: return x` with `return x` sphinx/builders/singlehtml.py:46:13 [FURB126]: Replace `else: return x` with `return x` sphinx/cmd/build.py:389:9 [FURB126]: Replace `else: return x` with `return x` sphinx/cmd/quickstart.py:89:9 [FURB126]: Replace `else: return x` with `return x` sphinx/cmd/quickstart.py:192:13 [FURB126]: Replace `else: return x` with `return x` sphinx/config.py:70:13 [FURB126]: Replace `else: return x` with `return x` sphinx/directives/__init__.py:101:13 [FURB126]: Replace `else: return x` with `return x` sphinx/directives/code.py:382:13 [FURB126]: Replace `else: return x` with `return x` sphinx/domains/c.py:211:13 [FURB126]: Replace `else: return x` with `return x` sphinx/domains/c.py:295:13 [FURB126]: Replace `else: return x` with `return x` sphinx/domains/c.py:330:13 [FURB126]: Replace `else: return x` with `return x` sphinx/domains/c.py:478:13 [FURB126]: Replace `else: return x` with `return x` sphinx/domains/c.py:699:13 [FURB126]: Replace `else: return x` with `return x` sphinx/domains/c.py:1206:13 [FURB126]: Replace `else: return x` with `return x` sphinx/domains/c.py:1249:13 [FURB126]: Replace `else: return x` with `return x` sphinx/domains/c.py:1305:13 [FURB126]: Replace `else: return x` with `return x` sphinx/domains/c.py:1474:13 [FURB126]: Replace `else: return x` with `return x` sphinx/domains/citation.py:101:13 [FURB126]: Replace `else: return x` with `return x` sphinx/domains/cpp.py:641:17 [FURB126]: Replace `else: return x` with `return x` sphinx/domains/cpp.py:898:13 [FURB126]: Replace `else: return x` with `return x` sphinx/domains/cpp.py:904:13 [FURB126]: Replace `else: return x` with `return x` sphinx/domains/cpp.py:959:13 [FURB126]: Replace `else: return x` with `return x` sphinx/domains/cpp.py:1292:13 [FURB126]: Replace `else: return x` with `return x` sphinx/domains/cpp.py:1766:13 [FURB126]: Replace `else: return x` with `return x` sphinx/domains/cpp.py:1803:13 [FURB126]: Replace `else: return x` with `return x` sphinx/domains/cpp.py:2038:13 [FURB126]: Replace `else: return x` with `return x` sphinx/domains/cpp.py:2044:13 [FURB126]: Replace `else: return x` with `return x` sphinx/domains/cpp.py:2118:13 [FURB126]: Replace `else: return x` with `return x` sphinx/domains/cpp.py:2424:13 [FURB126]: Replace `else: return x` with `return x` sphinx/domains/cpp.py:2437:13 [FURB126]: Replace `else: return x` with `return x` sphinx/domains/cpp.py:2531:13 [FURB126]: Replace `else: return x` with `return x` sphinx/domains/cpp.py:2781:13 [FURB126]: Replace `else: return x` with `return x` sphinx/domains/cpp.py:2845:13 [FURB126]: Replace `else: return x` with `return x` sphinx/domains/cpp.py:3091:13 [FURB126]: Replace `else: return x` with `return x` sphinx/domains/cpp.py:3197:13 [FURB126]: Replace `else: return x` with `return x` sphinx/domains/cpp.py:3236:13 [FURB126]: Replace `else: return x` with `return x` sphinx/domains/cpp.py:3655:13 [FURB126]: Replace `else: return x` with `return x` sphinx/domains/cpp.py:3694:13 [FURB126]: Replace `else: return x` with `return x` sphinx/domains/cpp.py:3733:13 [FURB126]: Replace `else: return x` with `return x` sphinx/domains/cpp.py:3870:17 [FURB126]: Replace `else: return x` with `return x` sphinx/domains/cpp.py:3879:13 [FURB126]: Replace `else: return x` with `return x` sphinx/domains/cpp.py:5149:13 [FURB126]: Replace `else: return x` with `return x` sphinx/domains/cpp.py:5872:13 [FURB126]: Replace `else: return x` with `return x` sphinx/domains/cpp.py:7004:17 [FURB126]: Replace `else: return x` with `return x` sphinx/domains/cpp.py:7024:13 [FURB126]: Replace `else: return x` with `return x` sphinx/domains/cpp.py:7057:13 [FURB126]: Replace `else: return x` with `return x` sphinx/domains/javascript.py:142:13 [FURB126]: Replace `else: return x` with `return x` sphinx/domains/javascript.py:495:13 [FURB126]: Replace `else: return x` with `return x` sphinx/domains/math.py:70:13 [FURB126]: Replace `else: return x` with `return x` sphinx/domains/math.py:122:13 [FURB126]: Replace `else: return x` with `return x` sphinx/domains/math.py:131:13 [FURB126]: Replace `else: return x` with `return x` sphinx/domains/python.py:843:13 [FURB126]: Replace `else: return x` with `return x` sphinx/domains/python.py:961:13 [FURB126]: Replace `else: return x` with `return x` sphinx/domains/python.py:1037:13 [FURB126]: Replace `else: return x` with `return x` sphinx/domains/python.py:1057:13 [FURB126]: Replace `else: return x` with `return x` sphinx/domains/python.py:1067:13 [FURB126]: Replace `else: return x` with `return x` sphinx/domains/python.py:1121:13 [FURB126]: Replace `else: return x` with `return x` sphinx/domains/python.py:1725:13 [FURB126]: Replace `else: return x` with `return x` sphinx/domains/rst.py:108:9 [FURB126]: Replace `else: return x` with `return x` sphinx/domains/rst.py:195:13 [FURB126]: Replace `else: return x` with `return x` sphinx/domains/std.py:957:17 [FURB126]: Replace `else: return x` with `return x` sphinx/errors.py:57:13 [FURB126]: Replace `else: return x` with `return x` sphinx/ext/autodoc/__init__.py:100:9 [FURB126]: Replace `else: return x` with `return x` sphinx/ext/autodoc/__init__.py:117:9 [FURB126]: Replace `else: return x` with `return x` sphinx/ext/autodoc/__init__.py:146:9 [FURB126]: Replace `else: return x` with `return x` sphinx/ext/autodoc/__init__.py:519:13 [FURB126]: Replace `else: return x` with `return x` sphinx/ext/autodoc/__init__.py:583:13 [FURB126]: Replace `else: return x` with `return x` sphinx/ext/autodoc/__init__.py:1117:21 [FURB126]: Replace `else: return x` with `return x` sphinx/ext/autodoc/__init__.py:1122:13 [FURB126]: Replace `else: return x` with `return x` sphinx/ext/autodoc/__init__.py:1261:13 [FURB126]: Replace `else: return x` with `return x` sphinx/ext/autodoc/__init__.py:1427:13 [FURB126]: Replace `else: return x` with `return x` sphinx/ext/autodoc/__init__.py:1683:13 [FURB126]: Replace `else: return x` with `return x` sphinx/ext/autodoc/__init__.py:1745:13 [FURB126]: Replace `else: return x` with `return x` sphinx/ext/autodoc/__init__.py:2011:13 [FURB126]: Replace `else: return x` with `return x` sphinx/ext/autodoc/__init__.py:2120:13 [FURB126]: Replace `else: return x` with `return x` sphinx/ext/autodoc/__init__.py:2376:13 [FURB126]: Replace `else: return x` with `return x` sphinx/ext/autodoc/__init__.py:2405:13 [FURB126]: Replace `else: return x` with `return x` sphinx/ext/autodoc/__init__.py:2499:13 [FURB126]: Replace `else: return x` with `return x` sphinx/ext/autodoc/mock.py:198:9 [FURB126]: Replace `else: return x` with `return x` sphinx/ext/autodoc/type_comment.py:80:9 [FURB126]: Replace `else: return x` with `return x` sphinx/ext/autosummary/__init__.py:203:9 [FURB126]: Replace `else: return x` with `return x` sphinx/ext/autosummary/generate.py:257:9 [FURB126]: Replace `else: return x` with `return x` sphinx/ext/autosummary/generate.py:350:9 [FURB126]: Replace `else: return x` with `return x` sphinx/ext/graphviz.py:86:13 [FURB126]: Replace `else: return x` with `return x` sphinx/ext/intersphinx.py:520:13 [FURB126]: Replace `else: return x` with `return x` sphinx/ext/intersphinx.py:591:13 [FURB126]: Replace `else: return x` with `return x` sphinx/ext/intersphinx.py:609:13 [FURB126]: Replace `else: return x` with `return x` sphinx/ext/napoleon/docstring.py:356:13 [FURB126]: Replace `else: return x` with `return x` sphinx/ext/napoleon/docstring.py:398:13 [FURB126]: Replace `else: return x` with `return x` sphinx/ext/napoleon/docstring.py:421:13 [FURB126]: Replace `else: return x` with `return x` sphinx/ext/napoleon/docstring.py:439:13 [FURB126]: Replace `else: return x` with `return x` sphinx/ext/napoleon/docstring.py:716:13 [FURB126]: Replace `else: return x` with `return x` sphinx/ext/napoleon/docstring.py:726:13 [FURB126]: Replace `else: return x` with `return x` sphinx/ext/napoleon/docstring.py:953:13 [FURB126]: Replace `else: return x` with `return x` sphinx/ext/napoleon/docstring.py:1191:13 [FURB126]: Replace `else: return x` with `return x` sphinx/highlighting.py:116:13 [FURB126]: Replace `else: return x` with `return x` sphinx/highlighting.py:192:13 [FURB126]: Replace `else: return x` with `return x` sphinx/highlighting.py:199:13 [FURB126]: Replace `else: return x` with `return x` sphinx/pycode/ast.py:64:13 [FURB126]: Replace `else: return x` with `return x` sphinx/pycode/ast.py:185:13 [FURB126]: Replace `else: return x` with `return x` sphinx/pycode/parser.py:32:9 [FURB126]: Replace `else: return x` with `return x` sphinx/pycode/parser.py:90:9 [FURB126]: Replace `else: return x` with `return x` sphinx/roles.py:109:13 [FURB126]: Replace `else: return x` with `return x` sphinx/roles.py:207:13 [FURB126]: Replace `else: return x` with `return x` sphinx/roles.py:241:13 [FURB126]: Replace `else: return x` with `return x` sphinx/search/__init__.py:540:13 [FURB126]: Replace `else: return x` with `return x` sphinx/search/__init__.py:556:13 [FURB126]: Replace `else: return x` with `return x` sphinx/theming.py:98:13 [FURB126]: Replace `else: return x` with `return x` sphinx/transforms/i18n.py:91:9 [FURB126]: Replace `else: return x` with `return x` sphinx/transforms/i18n.py:314:17 [FURB126]: Replace `else: return x` with `return x` sphinx/transforms/post_transforms/images.py:237:13 [FURB126]: Replace `else: return x` with `return x` sphinx/util/console.py:48:9 [FURB126]: Replace `else: return x` with `return x` sphinx/util/console.py:92:13 [FURB126]: Replace `else: return x` with `return x` sphinx/util/i18n.py:124:9 [FURB126]: Replace `else: return x` with `return x` sphinx/util/i18n.py:252:9 [FURB126]: Replace `else: return x` with `return x` sphinx/util/inspect.py:94:9 [FURB126]: Replace `else: return x` with `return x` sphinx/util/inspect.py:103:9 [FURB126]: Replace `else: return x` with `return x` sphinx/util/inspect.py:112:9 [FURB126]: Replace `else: return x` with `return x` sphinx/util/inspect.py:127:9 [FURB126]: Replace `else: return x` with `return x` sphinx/util/inspect.py:798:13 [FURB126]: Replace `else: return x` with `return x` sphinx/util/logging.py:116:13 [FURB126]: Replace `else: return x` with `return x` sphinx/util/logging.py:541:13 [FURB126]: Replace `else: return x` with `return x` sphinx/util/math.py:25:9 [FURB126]: Replace `else: return x` with `return x` sphinx/util/nodes.py:303:9 [FURB126]: Replace `else: return x` with `return x` sphinx/util/rst.py:48:13 [FURB126]: Replace `else: return x` with `return x` sphinx/util/texescape.py:110:9 [FURB126]: Replace `else: return x` with `return x` sphinx/util/texescape.py:119:9 [FURB126]: Replace `else: return x` with `return x` sphinx/util/typing.py:384:9 [FURB126]: Replace `else: return x` with `return x` sphinx/versioning.py:122:9 [FURB126]: Replace `else: return x` with `return x` sphinx/writers/latex.py:158:13 [FURB126]: Replace `else: return x` with `return x` sphinx/writers/latex.py:189:13 [FURB126]: Replace `else: return x` with `return x` sphinx/writers/latex.py:452:13 [FURB126]: Replace `else: return x` with `return x` sphinx/writers/latex.py:533:13 [FURB126]: Replace `else: return x` with `return x` sphinx/writers/latex.py:1242:17 [FURB126]: Replace `else: return x` with `return x` sphinx/writers/latex.py:1684:17 [FURB126]: Replace `else: return x` with `return x` sphinx/ext/apidoc.py:278:17 [FURB131]: Replace `del x[:]` with `x.clear()` sphinx/ext/napoleon/docstring.py:1290:13 [FURB131]: Replace `del x[:]` with `x.clear()` sphinx/directives/other.py:154:13 [FURB132]: Replace `if x in s: s.remove(x)` with `s.discard(x)` sphinx/domains/citation.py:52:13 [FURB132]: Replace `if x in s: s.remove(x)` with `s.discard(x)` sphinx/search/__init__.py:441:10 [FURB134]: Replace `@functools.lru_cache(maxsize=None)` with `@functools.cache` sphinx/builders/html/__init__.py:711:9 [FURB138]: Consider using list comprehension sphinx/builders/html/__init__.py:1058:13 [FURB138]: Consider using list comprehension sphinx/domains/c.py:1710:9 [FURB138]: Consider using list comprehension sphinx/domains/cpp.py:3976:9 [FURB138]: Consider using list comprehension sphinx/domains/cpp.py:7090:13 [FURB138]: Consider using list comprehension sphinx/ext/inheritance_diagram.py:126:9 [FURB138]: Consider using list comprehension sphinx/pycode/ast.py:88:9 [FURB138]: Consider using list comprehension sphinx/transforms/compact_bullet_list.py:32:9 [FURB138]: Consider using list comprehension sphinx/ext/napoleon/docstring.py:1339:17 [FURB140]: Replace `[f(...) for ... in x]` with `list(starmap(f, x))` sphinx/transforms/post_transforms/__init__.py:157:37 [FURB140]: Replace `f(...) for ... in x` with `starmap(f, x)` sphinx/application.py:160:12 [FURB141]: Replace `os.path.exists(x)` with `Path(x).exists()` sphinx/application.py:304:28 [FURB141]: Replace `os.path.exists(x)` with `Path(x).exists()` sphinx/builders/gettext.py:184:12 [FURB141]: Replace `os.path.exists(x)` with `Path(x).exists()` sphinx/builders/html/__init__.py:1256:16 [FURB141]: Replace `os.path.exists(x)` with `Path(x).exists()` sphinx/builders/html/__init__.py:1269:16 [FURB141]: Replace `os.path.exists(x)` with `Path(x).exists()` sphinx/builders/linkcheck.py:347:16 [FURB141]: Replace `os.path.exists(x)` with `Path(x).exists()` sphinx/cmd/make_mode.py:77:16 [FURB141]: Replace `os.path.exists(x)` with `Path(x).exists()` sphinx/cmd/quickstart.py:185:43 [FURB141]: Replace `os.path.exists(x)` with `Path(x).exists()` sphinx/cmd/quickstart.py:446:12 [FURB141]: Replace `os.path.exists(x)` with `Path(x).exists()` sphinx/cmd/quickstart.py:456:16 [FURB141]: Replace `os.path.exists(x)` with `Path(x).exists()` sphinx/directives/patches.py:65:16 [FURB141]: Replace `os.path.exists(x)` with `Path(x).exists()` sphinx/ext/apidoc.py:209:12 [FURB141]: Replace `os.path.exists(x)` with `Path(x).exists()` sphinx/ext/imgmath.py:111:12 [FURB141]: Replace `os.path.exists(x)` with `Path(x).exists()` sphinx/search/ja.py:89:16 [FURB141]: Replace `os.path.exists(x)` with `Path(x).exists()` sphinx/testing/path.py:194:16 [FURB141]: Replace `os.path.exists(x)` with `Path(x).exists()` sphinx/transforms/post_transforms/images.py:74:16 [FURB141]: Replace `os.path.exists(x)` with `Path(x).exists()` sphinx/util/docutils.py:405:47 [FURB141]: Replace `os.path.exists(x)` with `Path(x).exists()` sphinx/util/fileutil.py:31:12 [FURB141]: Replace `os.path.exists(x)` with `Path(x).exists()` sphinx/util/fileutil.py:70:12 [FURB141]: Replace `os.path.exists(x)` with `Path(x).exists()` sphinx/util/i18n.py:55:17 [FURB141]: Replace `os.path.exists(x)` with `Path(x).exists()` sphinx/util/i18n.py:91:16 [FURB141]: Replace `os.path.exists(x)` with `Path(x).exists()` sphinx/util/i18n.py:249:8 [FURB141]: Replace `os.path.exists(x)` with `Path(x).exists()` sphinx/util/images.py:71:8 [FURB141]: Replace `os.path.exists(x)` with `Path(x).exists()` sphinx/util/osutil.py:92:12 [FURB141]: Replace `os.path.exists(x)` with `Path(x).exists()` sphinx/writers/latex.py:522:16 [FURB141]: Replace `os.path.exists(x)` with `Path(x).exists()` sphinx/builders/__init__.py:317:9 [FURB142]: Replace `for x in y: s.add(docname)` with `s.update(y)` sphinx/builders/texinfo.py:125:46 [FURB143]: Replace `x or ""` with `x` sphinx/builders/texinfo.py:126:49 [FURB143]: Replace `x or ""` with `x` sphinx/builders/texinfo.py:127:52 [FURB143]: Replace `x or ""` with `x` sphinx/ext/autodoc/__init__.py:1010:17 [FURB143]: Replace `x or ""` with `x` sphinx/ext/intersphinx.py:722:27 [FURB143]: Replace `x or {}` with `x` sphinx/application.py:362:17 [FURB144]: Replace `os.unlink(x)` with `Path(x).unlink()` sphinx/ext/githubpages.py:52:13 [FURB144]: Replace `os.unlink(x)` with `Path(x).unlink()` sphinx/testing/path.py:141:9 [FURB144]: Replace `os.unlink(x)` with `Path(x).unlink()` sphinx/testing/util.py:140:13 [FURB144]: Replace `os.remove(x)` with `Path(x).unlink()` sphinx/util/osutil.py:217:9 [FURB144]: Replace `os.remove(x)` with `Path(x).unlink()` sphinx/domains/changeset.py:129:30 [FURB145]: Replace `x[:]` with `x.copy()` sphinx/events.py:80:29 [FURB145]: Replace `x[:]` with `x.copy()` sphinx/ext/apidoc.py:171:19 [FURB145]: Replace `x[:]` with `x.copy()` sphinx/ext/apidoc.py:271:22 [FURB145]: Replace `x[:]` with `x.copy()` sphinx/ext/autodoc/__init__.py:224:22 [FURB145]: Replace `x[:]` with `x.copy()` sphinx/ext/napoleon/__init__.py:389:16 [FURB145]: Replace `x[:]` with `x.copy()` sphinx/testing/fixtures.py:177:15 [FURB145]: Replace `x[:]` with `x.copy()` sphinx/testing/util.py:112:28 [FURB145]: Replace `x[:]` with `x.copy()` sphinx/util/fileutil.py:84:20 [FURB145]: Replace `x[:]` with `x.copy()` sphinx/writers/latex.py:324:29 [FURB145]: Replace `x[:]` with `x.copy()` sphinx/application.py:361:16 [FURB146]: Replace `os.path.isfile(x)` with `Path(x).is_file()` sphinx/builders/__init__.py:261:20 [FURB146]: Replace `os.path.isfile(x)` with `Path(x).is_file()` sphinx/builders/__init__.py:483:12 [FURB146]: Replace `os.path.isfile(x)` with `Path(x).is_file()` sphinx/builders/html/__init__.py:249:16 [FURB146]: Replace `os.path.isfile(x)` with `Path(x).is_file()` sphinx/builders/latex/theming.py:129:16 [FURB146]: Replace `os.path.isfile(x)` with `Path(x).is_file()` sphinx/cmd/quickstart.py:98:12 [FURB146]: Replace `os.path.isdir(x)` with `Path(x).is_dir()` sphinx/cmd/quickstart.py:373:29 [FURB146]: Replace `os.path.isfile(x)` with `Path(x).is_file()` sphinx/config.py:179:16 [FURB146]: Replace `os.path.isfile(x)` with `Path(x).is_file()` sphinx/environment/__init__.py:478:24 [FURB146]: Replace `os.path.isfile(x)` with `Path(x).is_file()` sphinx/environment/__init__.py:501:32 [FURB146]: Replace `os.path.isfile(x)` with `Path(x).is_file()` sphinx/ext/apidoc.py:88:27 [FURB146]: Replace `os.path.isfile(x)` with `Path(x).is_file()` sphinx/ext/apidoc.py:194:12 [FURB146]: Replace `os.path.isdir(x)` with `Path(x).is_dir()` sphinx/ext/autosummary/generate.py:530:12 [FURB146]: Replace `os.path.isfile(x)` with `Path(x).is_file()` sphinx/ext/graphviz.py:274:8 [FURB146]: Replace `os.path.isfile(x)` with `Path(x).is_file()` sphinx/ext/graphviz.py:309:12 [FURB146]: Replace `os.path.isfile(x)` with `Path(x).is_file()` sphinx/ext/imgmath.py:254:8 [FURB146]: Replace `os.path.isfile(x)` with `Path(x).is_file()` sphinx/theming.py:61:12 [FURB146]: Replace `os.path.isdir(x)` with `Path(x).is_dir()` sphinx/theming.py:73:16 [FURB146]: Replace `os.path.isfile(x)` with `Path(x).is_file()` sphinx/theming.py:209:16 [FURB146]: Replace `os.path.isdir(x)` with `Path(x).is_dir()` sphinx/theming.py:214:16 [FURB146]: Replace `os.path.isfile(x)` with `Path(x).is_file()` sphinx/util/osutil.py:214:8 [FURB146]: Replace `os.path.isdir(x)` with `Path(x).is_dir()` sphinx/directives/code.py:322:16 [FURB149]: Replace `x is True` with `x` sphinx/directives/code.py:351:16 [FURB149]: Replace `x is True` with `x` sphinx/domains/python.py:1512:34 [FURB149]: Replace `x is False` with `not x` sphinx/ext/autosummary/generate.py:240:20 [FURB149]: Replace `x is False` with `not x` sphinx/ext/autosummary/generate.py:400:20 [FURB149]: Replace `x is True` with `x` sphinx/ext/autosummary/generate.py:402:22 [FURB149]: Replace `x is False` with `not x` sphinx/util/inspect.py:697:13 [FURB149]: Replace `x is False` with `not x` sphinx/util/inspect.py:698:13 [FURB149]: Replace `x is False` with `not x` sphinx/util/logging.py:279:8 [FURB149]: Replace `x is False` with `not x` sphinx/testing/path.py:207:9 [FURB150]: Replace `os.makedirs(x, ...)` with `Path(x).mkdir(..., parents=True)` sphinx/util/osutil.py:69:5 [FURB150]: Replace `os.makedirs(x, ...)` with `Path(x).mkdir(..., parents=True)` sphinx/builders/html/__init__.py:401:31 [FURB155]: Replace `os.path.getmtime(x)` with `Path(x).stat().st_mtime` sphinx/builders/text.py:48:31 [FURB155]: Replace `os.path.getmtime(x)` with `Path(x).stat().st_mtime` sphinx/builders/xml.py:53:31 [FURB155]: Replace `os.path.getmtime(x)` with `Path(x).stat().st_mtime` sphinx/ext/viewcode.py:233:46 [FURB155]: Replace `os.path.getmtime(x)` with `Path(x).stat().st_mtime` sphinx/jinja2glue.py:134:17 [FURB155]: Replace `os.path.getmtime(x)` with `Path(x).stat().st_mtime` sphinx/jinja2glue.py:138:24 [FURB155]: Replace `os.path.getmtime(x)` with `Path(x).stat().st_mtime` sphinx/transforms/post_transforms/images.py:75:41 [FURB155]: Replace `os.stat(x)` with `Path(x).stat()` sphinx/domains/c.py:104:58 [FURB167]: Replace `re.S` with `re.DOTALL` sphinx/domains/cpp.py:315:58 [FURB167]: Replace `re.S` with `re.DOTALL` sphinx/domains/std.py:37:44 [FURB167]: Replace `re.U` with `re.UNICODE` sphinx/ext/napoleon/docstring.py:148:66 [FURB167]: Replace `re.X` with `re.VERBOSE` sphinx/roles.py:327:37 [FURB167]: Replace `re.S` with `re.DOTALL` sphinx/roles.py:331:40 [FURB167]: Replace `re.S` with `re.DOTALL` sphinx/transforms/post_transforms/images.py:64:24 [FURB170]: Replace `re.sub(x, ..., ...)` with `x.sub(..., ...)` sphinx/transforms/post_transforms/images.py:146:16 [FURB170]: Replace `re.sub(x, ..., ...)` with `x.sub(..., ...)` sphinx/builders/_epub_base.py:420:20 [FURB171]: Replace `x in (y,)` with `x == y` sphinx/environment/collectors/metadata.py:53:20 [FURB171]: Replace `x in (y,)` with `x == y` sphinx/ext/autosummary/generate.py:334:8 [FURB171]: Replace `x in (y,)` with `x == y` sphinx/ext/imgmath.py:143:8 [FURB171]: Replace `x not in [y]` with `x != y` sphinx/writers/latex.py:2125:12 [FURB171]: Replace `x in [y]` with `x == y` sphinx/writers/latex.py:2128:14 [FURB171]: Replace `x in [y]` with `x == y` sphinx/writers/latex.py:2131:14 [FURB171]: Replace `x in [y]` with `x == y` sphinx/builders/html/_assets.py:30:48 [FURB173]: Replace `{..., **x1}` with `{...} | x1` sphinx/domains/python.py:188:20 [FURB179]: Replace `sum(x, [])` with `chain.from_iterable(x)` sphinx/ext/autodoc/__init__.py:926:33 [FURB179]: Replace `sum(x, [])` with `chain.from_iterable(x)` sphinx/ext/autodoc/__init__.py:2057:63 [FURB179]: Replace `sum(x, [])` with `chain.from_iterable(x)` sphinx/ext/autodoc/__init__.py:2628:67 [FURB179]: Replace `sum(x, [])` with `chain.from_iterable(x)` sphinx/ext/autosummary/__init__.py:654:39 [FURB179]: Replace `sum(x, [])` with `chain.from_iterable(x)` sphinx/ext/todo.py:132:34 [FURB179]: Replace `sum(x, [])` with `chain.from_iterable(x)` sphinx/pycode/parser.py:353:35 [FURB179]: Replace `sum(x, [])` with `chain.from_iterable(x)` sphinx/builders/linkcheck.py:422:32 [FURB183]: Replace `f"{response.url}"` with `str(response.url)` sphinx/ext/coverage.py:298:17 [FURB183]: Replace `f"{x}"` with `str(x)` sphinx/util/logging.py:497:39 [FURB183]: Replace `f"{self.app.env.doc2path(docname)}"` with `str(self.app.env.doc2path(docname))` sphinx/util/logging.py:503:31 [FURB183]: Replace `f"{self.app.env.doc2path(location)}"` with `str(self.app.env.doc2path(location))` ```

Describe alternatives you've considered

Just add a few other new rules in #11833.

Additional context

picnixz commented 9 months ago

There are some checks that are really needed like x == [] (here we really want to match the empty list and not just a falsey object) so not all checks are good.

Instead, we should correct the errors one by one in a PR. For instance a PR could ywitch to suppress but I wouldn't recommend it in a performance critical section since the context manager being created is reentrant and is likely to be slower than the pure try/catch (though I don't think it's by much). I know that CPython now has 0-cost exceptions when they don't occur meaning that the cost of the try/catch is 0 if there is no exception. However the cost of creating the context manager is not nonzero amd if it's called a lot of times, we might end up slowing down builds (which are already quite slow..)

DimitriPapadopoulos commented 9 months ago

There are some checks that are really needed like x == [] (here we really want to match the empty list and not just a falsey object) so not all checks are good.

If x is a Python list, x is false if and only if it is empty.

https://docs.python.org/3/library/stdtypes.html#truth-value-testing

Any object can be tested for truth value, for use in an if or while condition or as operand of the Boolean operations below.

By default, an object is considered true unless its class defines either a __bool__() method that returns False or a __len__() method that returns zero, when called with the object. 1 Here are most of the built-in objects considered false:

  • constants defined to be false: None and False
  • zero of any numeric type: 0, 0.0, 0j, Decimal(0), Fraction(0, 1)
  • empty sequences and collections: '', (), [], {}, set(), range(0)
picnixz commented 9 months ago

Actually it's probably for formatting reasons that we do that. Like, we don't know about the type of the object and we only want to match a real empty list and not just empty sequences or falsey objects

electric-coder commented 9 months ago

I'm not sure of the current mypy defaults but:

`[FURB126]: Replace `else: return x` with `return x``

There was a time when mypy issued a warning for incomplete if/else chains.

DimitriPapadopoulos commented 9 months ago

I am not fond of FURB126 any way. If you ask me, I'd leave the code as is, it's often more readable. It's up to you maintainers to decide :smile:

DimitriPapadopoulos commented 9 months ago

Actually it's probably for formatting reasons that we do that. Like, we don't know about the type of the object and we only want to match a real empty list and not just empty sequences or falsey objects

When refurb suggest these changes, it usually knows the object is a list/set, and I think not by looking at the MyPy types, but by analysing the actual code.

picnixz commented 9 months ago

Well for these cases we need to check each of them separately (again I don't have time for that so someone knowledgeable with the code base should do it if possible)

I am nitpicky because there were some ruff alternatives that would have introduced runtime bugs.

picnixz commented 9 months ago

Thanks for all these small PRs. Can you wait until we adressed them before creating new related ones?

DimitriPapadopoulos commented 9 months ago

Sure. I have finished my first batch of changes, changes that I feel do improve the code or uncover actual design issues. I am not really sure about remaining refurb suggestions.