{
  "id": "task_libraries:code-formatter/python",
  "path": "/exapedia/python-code-formatter-libraries",
  "template": {
    "id": "task_libraries",
    "version": 4
  },
  "title": "Python code formatter libraries",
  "answer": [
    {
      "t": "text",
      "text": "Python code formatters rewrite source files in one consistent style. These libraries format code on save or in a pre-commit hook so that review diffs show changes in behavior rather than style."
    }
  ],
  "breadcrumb": [
    {
      "label": "Tools"
    },
    {
      "label": "Python code formatter libraries"
    }
  ],
  "sections": [
    {
      "id": "libraries_popularity",
      "anchor": "popularity",
      "heading": "Popularity",
      "blocks": [
        {
          "b": "table",
          "columns": [
            "Library",
            "Monthly downloads",
            "Stars",
            "Last release",
            "License"
          ],
          "rows": [
            [
              [
                {
                  "t": "link",
                  "href": "#ruff",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F152"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F153"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F159"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F156"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F154"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#black",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F166"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F167"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F173"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F170"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F168"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#isort",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F180"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F181"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F187"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F184"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F182"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#autopep",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F194"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F195"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F201"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F198"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F196"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#yapf",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F208"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F209"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F215"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F212"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F210"
                }
              ]
            ]
          ],
          "variant": "pop",
          "caption": [
            {
              "t": "text",
              "text": "Downloads: "
            },
            {
              "t": "text",
              "text": "PyPI"
            },
            {
              "t": "text",
              "text": ", last thirty days. Stars and releases: GitHub. Amber: no release in over a year."
            }
          ]
        }
      ],
      "note": [
        {
          "t": "link",
          "href": "#ruff",
          "label": [
            {
              "t": "fact",
              "fact": "F152"
            }
          ]
        },
        {
          "t": "text",
          "text": " has the most installs and the most GitHub stars."
        }
      ]
    },
    {
      "id": "libraries_capabilities",
      "anchor": "capabilities",
      "heading": "Capabilities",
      "blocks": [
        {
          "b": "table",
          "columns": [
            "Library",
            "Python formatting API",
            "Line-range formatting"
          ],
          "rows": [
            [
              [
                {
                  "t": "link",
                  "href": "#ruff",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F152"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F160"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F161"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#black",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F166"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F174"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F175"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#isort",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F180"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F188"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F189"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#autopep",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F194"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F202"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F203"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#yapf",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F208"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F216"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F217"
                }
              ]
            ]
          ],
          "variant": "cap"
        }
      ]
    },
    {
      "id": "libraries_entries",
      "anchor": "libraries",
      "heading": "Libraries",
      "blocks": [
        {
          "b": "entry",
          "anchor": "ruff",
          "name": [
            {
              "t": "fact",
              "fact": "F152"
            }
          ],
          "links": [
            {
              "label": "GitHub",
              "href": "https://github.com/astral-sh/ruff"
            },
            {
              "label": "PyPI",
              "href": "https://pypi.org/project/ruff"
            },
            {
              "label": "Docs",
              "href": "https://docs.astral.sh/ruff/formatter/"
            }
          ],
          "what": [
            {
              "t": "text",
              "text": "Ruff's formatter is a Python code formatter that runs as "
            },
            {
              "t": "code",
              "text": "ruff format"
            },
            {
              "t": "text",
              "text": ", a subcommand of the Ruff linter. The formatter is a drop-in replacement for "
            },
            {
              "t": "link",
              "href": "#black",
              "label": [
                {
                  "t": "text",
                  "text": "Black"
                }
              ]
            },
            {
              "t": "text",
              "text": ". On large Black-formatted projects such as Django and Zulip, nearly every line comes out identical. Unlike Black, Ruff lets a project set the quote style, the indent style, and line endings. With "
            },
            {
              "t": "code",
              "text": "docstring-code-format"
            },
            {
              "t": "text",
              "text": " turned on, the formatter also reformats code examples inside docstrings. The "
            },
            {
              "t": "code",
              "text": "--check"
            },
            {
              "t": "text",
              "text": " flag lists unformatted files and exits with an error status, leaving the files unchanged."
            }
          ],
          "facts": [
            {
              "label": "Downloads / mo",
              "value": [
                {
                  "t": "fact",
                  "fact": "F153"
                }
              ]
            },
            {
              "label": "Stars",
              "value": [
                {
                  "t": "fact",
                  "fact": "F159"
                }
              ]
            },
            {
              "label": "Last release",
              "value": [
                {
                  "t": "fact",
                  "fact": "F155"
                }
              ]
            },
            {
              "label": "License",
              "value": [
                {
                  "t": "fact",
                  "fact": "F154"
                }
              ]
            },
            {
              "label": "Capabilities",
              "value": [
                {
                  "t": "link",
                  "href": "https://docs.astral.sh/ruff/formatter/",
                  "label": [
                    {
                      "t": "text",
                      "text": "From the "
                    },
                    {
                      "t": "fact",
                      "fact": "F152"
                    },
                    {
                      "t": "text",
                      "text": " docs"
                    }
                  ]
                }
              ]
            }
          ],
          "pros": [
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F12"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F13"
                }
              ]
            },
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F14"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F15"
                }
              ]
            }
          ],
          "cons": [
            {
              "lead": [
                {
                  "t": "text",
                  "text": "No import sorting"
                }
              ],
              "body": [
                {
                  "t": "text",
                  "text": "The formatter leaves import order alone. Sorting imports takes the linter's import rules first, with "
                },
                {
                  "t": "code",
                  "text": "ruff check --select I --fix"
                },
                {
                  "t": "text",
                  "text": "."
                }
              ]
            },
            {
              "lead": [
                {
                  "t": "text",
                  "text": "Not interchangeable with Black"
                }
              ],
              "body": [
                {
                  "t": "text",
                  "text": "Ruff differs from Black in a few deliberate ways. A project uses one of the two formatters for all its files."
                }
              ]
            }
          ],
          "tabs": [
            {
              "label": [
                {
                  "t": "fact",
                  "fact": "F164"
                }
              ],
              "stars": [
                {
                  "t": "fact",
                  "fact": "F165"
                }
              ],
              "usedBy": [
                {
                  "t": "link",
                  "href": "https://github.com/matkuki/ExCo",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F164"
                    }
                  ]
                },
                {
                  "t": "text",
                  "text": " "
                }
              ],
              "language": "python",
              "code": "def format_ruff_python(code: str) -> str:\n    with tempfile.TemporaryDirectory() as tmpdir:  # type: ignore\n        file_path: pathlib.Path = pathlib.Path(tmpdir) / \"temp_ruff_formatting_file.py\"\n        file_path.write_text(code, encoding=\"utf-8\")\n\n        result: subprocess.CompletedProcess[str] = subprocess.run(\n            [\"ruff\", \"format\", str(file_path)],\n            capture_output=True,\n            text=True,\n            encoding=\"utf-8\",  # Ensure subprocess handles UTF-8 output\n        )\n\n        if result.returncode != 0:\n            raise RuntimeError(f\"Ruff error:\\n{result.stderr}\")\n\n        return file_path.read_text(encoding=\"utf-8\")\n",
              "prov": [
                {
                  "t": "link",
                  "href": "https://github.com/matkuki/ExCo/blob/a201970286d6ddaa1de922f394290d8f456c4505/codequality.py#L144-L159",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F163"
                    }
                  ]
                }
              ],
              "more": [
                {
                  "t": "link",
                  "href": "https://dashboard.exa.ai/playground/search?q=Python%20projects%20using%20ruff%20for%20source%20formatting%2C%20generated%20modules%20and%20editor%20integrations&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D",
                  "label": [
                    {
                      "t": "text",
                      "text": "More projects using "
                    },
                    {
                      "t": "fact",
                      "fact": "F152"
                    },
                    {
                      "t": "text",
                      "text": " →"
                    }
                  ]
                }
              ]
            },
            {
              "label": [
                {
                  "t": "text",
                  "text": "Quickstart"
                }
              ],
              "language": "python",
              "code": "ruff format                   # Format all files in the current directory.\n",
              "prov": [
                {
                  "t": "text",
                  "text": "From "
                },
                {
                  "t": "link",
                  "href": "https://docs.astral.sh/ruff/formatter/",
                  "label": [
                    {
                      "t": "text",
                      "text": "formatter.md"
                    }
                  ]
                }
              ]
            }
          ],
          "install": [
            {
              "t": "fact",
              "fact": "F157"
            }
          ]
        },
        {
          "b": "entry",
          "anchor": "black",
          "name": [
            {
              "t": "fact",
              "fact": "F166"
            }
          ],
          "links": [
            {
              "label": "GitHub",
              "href": "https://github.com/psf/black"
            },
            {
              "label": "PyPI",
              "href": "https://pypi.org/project/black"
            },
            {
              "label": "Docs",
              "href": "https://black.readthedocs.io/en/stable/usage_and_configuration/the_basics.html"
            }
          ],
          "what": [
            {
              "t": "text",
              "text": "Black is a Python code formatter with almost no style settings. A project that adopts Black gives up control over formatting details. In return, every Black-formatted codebase looks alike. The "
            },
            {
              "t": "code",
              "text": "black"
            },
            {
              "t": "text",
              "text": " command takes files or directories and rewrites the code in place, keeping diffs as small as possible. Jupyter notebook support comes from installing the "
            },
            {
              "t": "code",
              "text": "jupyter"
            },
            {
              "t": "text",
              "text": " extra, as in "
            },
            {
              "t": "code",
              "text": "pip install \"black[jupyter]\""
            },
            {
              "t": "text",
              "text": ". "
            },
            {
              "t": "link",
              "href": "#ruff",
              "label": [
                {
                  "t": "text",
                  "text": "Ruff"
                }
              ]
            },
            {
              "t": "text",
              "text": " follows Black's style closely as a drop-in replacement."
            }
          ],
          "facts": [
            {
              "label": "Downloads / mo",
              "value": [
                {
                  "t": "fact",
                  "fact": "F167"
                }
              ]
            },
            {
              "label": "Stars",
              "value": [
                {
                  "t": "fact",
                  "fact": "F173"
                }
              ]
            },
            {
              "label": "Last release",
              "value": [
                {
                  "t": "fact",
                  "fact": "F169"
                }
              ]
            },
            {
              "label": "License",
              "value": [
                {
                  "t": "fact",
                  "fact": "F168"
                }
              ]
            },
            {
              "label": "Capabilities",
              "value": [
                {
                  "t": "link",
                  "href": "https://black.readthedocs.io/en/stable/usage_and_configuration/the_basics.html",
                  "label": [
                    {
                      "t": "text",
                      "text": "From the "
                    },
                    {
                      "t": "fact",
                      "fact": "F166"
                    },
                    {
                      "t": "text",
                      "text": " docs"
                    }
                  ]
                }
              ]
            }
          ],
          "pros": [
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F32"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F33"
                }
              ]
            },
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F34"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F35"
                }
              ]
            }
          ],
          "cons": [
            {
              "lead": [
                {
                  "t": "text",
                  "text": "Few settings"
                }
              ],
              "body": [
                {
                  "t": "text",
                  "text": "Choices such as quote style and indent style are fixed. "
                },
                {
                  "t": "link",
                  "href": "#ruff",
                  "label": [
                    {
                      "t": "text",
                      "text": "Ruff"
                    }
                  ]
                },
                {
                  "t": "text",
                  "text": " lets a project configure both."
                }
              ]
            }
          ],
          "tabs": [
            {
              "label": [
                {
                  "t": "fact",
                  "fact": "F178"
                }
              ],
              "stars": [
                {
                  "t": "fact",
                  "fact": "F179"
                }
              ],
              "usedBy": [
                {
                  "t": "link",
                  "href": "https://github.com/SDXorg/pysd",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F178"
                    }
                  ]
                },
                {
                  "t": "text",
                  "text": " "
                }
              ],
              "language": "python",
              "code": "def _build_separate_module(self, elements: list, module_name: str,\n                           module_dir: str) -> None:\n    \"\"\"\n    Constructs and writes the Python representation of a specific model\n    module, when the split_views=True in the read_vensim function.\n\n    Parameters\n    ----------\n    elements: list\n        Elements belonging to the module module_name.\n\n    module_name: str\n        Name of the module\n\n    module_dir: str\n        Path of the directory where module files will be stored.\n\n    Returns\n    -------\n    None\n\n    \"\"\"\n    text = textwrap.dedent('''\n    \"\"\"\n    Module %(module_name)s\n    Translated using PySD version %(version)s\n    \"\"\"\n    ''' % {\n        \"module_name\": \".\".join(module_name.parts[1:]),\n        \"version\": __version__,\n    })\n    funcs = self._generate_functions(elements)\n    text += funcs\n    text = black.format_file_contents(\n        text, fast=True, mode=black.FileMode())\n\n    outfile_name = module_dir / module_name.with_suffix(\".py\")\n\n    with outfile_name.open(\"w\", encoding=\"UTF-8\") as out:\n        out.write(text)\n",
              "prov": [
                {
                  "t": "link",
                  "href": "https://github.com/SDXorg/pysd/blob/8991d119e139029d4dec712d257cf5fcc3549b8f/pysd/builders/python/python_model_builder.py#L242-L281",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F177"
                    }
                  ]
                }
              ],
              "more": [
                {
                  "t": "link",
                  "href": "https://dashboard.exa.ai/playground/search?q=Python%20projects%20using%20black%20for%20source%20formatting%2C%20generated%20modules%20and%20editor%20integrations&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D",
                  "label": [
                    {
                      "t": "text",
                      "text": "More projects using "
                    },
                    {
                      "t": "fact",
                      "fact": "F166"
                    },
                    {
                      "t": "text",
                      "text": " →"
                    }
                  ]
                }
              ]
            },
            {
              "label": [
                {
                  "t": "text",
                  "text": "Quickstart"
                }
              ],
              "language": "python",
              "code": "black {source_file_or_directory}\n",
              "prov": [
                {
                  "t": "text",
                  "text": "From "
                },
                {
                  "t": "link",
                  "href": "https://github.com/psf/black/blob/main/README.md",
                  "label": [
                    {
                      "t": "text",
                      "text": "README.md"
                    }
                  ]
                }
              ]
            }
          ],
          "install": [
            {
              "t": "fact",
              "fact": "F171"
            }
          ]
        },
        {
          "b": "entry",
          "anchor": "isort",
          "name": [
            {
              "t": "fact",
              "fact": "F180"
            }
          ],
          "links": [
            {
              "label": "GitHub",
              "href": "https://github.com/PyCQA/isort"
            },
            {
              "label": "PyPI",
              "href": "https://pypi.org/project/isort"
            },
            {
              "label": "Docs",
              "href": "https://raw.githubusercontent.com/PyCQA/isort/main/README.md"
            }
          ],
          "what": [
            {
              "t": "text",
              "text": "isort sorts Python imports alphabetically and separates them into sections for the standard library, third-party packages, and project modules. The "
            },
            {
              "t": "code",
              "text": "isort"
            },
            {
              "t": "text",
              "text": " command rewrites files in place. With "
            },
            {
              "t": "code",
              "text": "--diff"
            },
            {
              "t": "text",
              "text": ", the command prints the proposed changes instead of applying them. From Python, "
            },
            {
              "t": "code",
              "text": "isort.code"
            },
            {
              "t": "text",
              "text": " returns a copy of a source string with the imports sorted. A "
            },
            {
              "t": "code",
              "text": "black"
            },
            {
              "t": "text",
              "text": " profile makes isort wrap long imports the way "
            },
            {
              "t": "link",
              "href": "#black",
              "label": [
                {
                  "t": "text",
                  "text": "Black"
                }
              ]
            },
            {
              "t": "text",
              "text": " does. With that profile set, the two tools agree on import layout."
            }
          ],
          "facts": [
            {
              "label": "Downloads / mo",
              "value": [
                {
                  "t": "fact",
                  "fact": "F181"
                }
              ]
            },
            {
              "label": "Stars",
              "value": [
                {
                  "t": "fact",
                  "fact": "F187"
                }
              ]
            },
            {
              "label": "Last release",
              "value": [
                {
                  "t": "fact",
                  "fact": "F183"
                }
              ]
            },
            {
              "label": "License",
              "value": [
                {
                  "t": "fact",
                  "fact": "F182"
                }
              ]
            },
            {
              "label": "Capabilities",
              "value": [
                {
                  "t": "link",
                  "href": "https://raw.githubusercontent.com/PyCQA/isort/main/README.md",
                  "label": [
                    {
                      "t": "text",
                      "text": "From the "
                    },
                    {
                      "t": "fact",
                      "fact": "F180"
                    },
                    {
                      "t": "text",
                      "text": " docs"
                    }
                  ]
                }
              ]
            }
          ],
          "pros": [
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F56"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F57"
                }
              ]
            },
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F58"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F59"
                }
              ]
            }
          ],
          "cons": [
            {
              "lead": [
                {
                  "t": "text",
                  "text": "Imports only"
                }
              ],
              "body": [
                {
                  "t": "link",
                  "href": "#black",
                  "label": [
                    {
                      "t": "text",
                      "text": "Black"
                    }
                  ]
                },
                {
                  "t": "text",
                  "text": " or "
                },
                {
                  "t": "link",
                  "href": "#ruff",
                  "label": [
                    {
                      "t": "text",
                      "text": "Ruff"
                    }
                  ]
                },
                {
                  "t": "text",
                  "text": " formats the rest of each file."
                }
              ]
            },
            {
              "lead": [
                {
                  "t": "text",
                  "text": "Atomic mode off"
                }
              ],
              "body": [
                {
                  "t": "text",
                  "text": "The "
                },
                {
                  "t": "code",
                  "text": "--atomic"
                },
                {
                  "t": "text",
                  "text": " flag skips changes that would introduce syntax errors. The flag is off by default because it stops isort from running on code written for a different Python version."
                }
              ]
            }
          ],
          "tabs": [
            {
              "label": [
                {
                  "t": "fact",
                  "fact": "F192"
                }
              ],
              "stars": [
                {
                  "t": "fact",
                  "fact": "F193"
                }
              ],
              "usedBy": [
                {
                  "t": "link",
                  "href": "https://github.com/matkuki/ExCo",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F192"
                    }
                  ]
                },
                {
                  "t": "text",
                  "text": " "
                }
              ],
              "language": "python",
              "code": "def format_python_code(code: str, library: str) -> str:\n    # Choose formatter based on the specified library\n    if library == \"black\":\n        # Format code using Black with default settings\n        formatted_code: str = black.format_str(code, mode=black.FileMode())\n\n    elif library == \"autopep8\":\n        # Format code using autopep8\n        formatted_code = autopep8.fix_code(code)\n\n    elif library == \"yapf\":\n        # Format code using yapf; returns (formatted_code, changed_flag)\n        formatted_code, _ = yapf.yapf_api.FormatCode(code)\n\n    elif library == \"ruff\":\n        # Format code using a custom wrapper for Ruff (assumes string input/output)\n        formatted_code = format_ruff_python(code)\n\n    else:\n        # Raise a ValueError for unrecognized formatter names\n        raise ValueError(\n            f\"[PYTHON-CODE-FORMATTING] Unknown formatting library selected: {library}\"\n        )\n\n    # Sort and format imports using isort with Black compatibility\n    formatted_code = isort.code(formatted_code, config=isort.Config(profile=\"black\"))\n\n    return formatted_code\n",
              "prov": [
                {
                  "t": "link",
                  "href": "https://github.com/matkuki/ExCo/blob/a201970286d6ddaa1de922f394290d8f456c4505/codequality.py#L225-L252",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F191"
                    }
                  ]
                }
              ],
              "more": [
                {
                  "t": "link",
                  "href": "https://dashboard.exa.ai/playground/search?q=Python%20projects%20using%20isort%20for%20source%20formatting%2C%20generated%20modules%20and%20editor%20integrations&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D",
                  "label": [
                    {
                      "t": "text",
                      "text": "More projects using "
                    },
                    {
                      "t": "fact",
                      "fact": "F180"
                    },
                    {
                      "t": "text",
                      "text": " →"
                    }
                  ]
                }
              ]
            },
            {
              "label": [
                {
                  "t": "text",
                  "text": "Quickstart"
                }
              ],
              "language": "python",
              "code": "import isort\n\nsorted_code = isort.code(\"import b\\nimport a\\n\")\n",
              "prov": [
                {
                  "t": "text",
                  "text": "From "
                },
                {
                  "t": "link",
                  "href": "https://raw.githubusercontent.com/PyCQA/isort/main/README.md",
                  "label": [
                    {
                      "t": "text",
                      "text": "README.md"
                    }
                  ]
                }
              ]
            }
          ],
          "install": [
            {
              "t": "fact",
              "fact": "F185"
            }
          ]
        },
        {
          "b": "entry",
          "anchor": "autopep",
          "name": [
            {
              "t": "fact",
              "fact": "F194"
            }
          ],
          "links": [
            {
              "label": "GitHub",
              "href": "https://github.com/hhatto/autopep8"
            },
            {
              "label": "PyPI",
              "href": "https://pypi.org/project/autopep8"
            },
            {
              "label": "Docs",
              "href": "https://raw.githubusercontent.com/hhatto/autopep8/main/README.rst"
            }
          ],
          "what": [
            {
              "t": "fact",
              "fact": "F70"
            },
            {
              "t": "text",
              "text": " rewrites Python code to fix the style problems that pycodestyle, a Python style checker, reports when code breaks the official Python style guide. By default, the fixes change only whitespace. Each "
            },
            {
              "t": "code",
              "text": "--aggressive"
            },
            {
              "t": "text",
              "text": " flag allows further fixes, such as replacing "
            },
            {
              "t": "code",
              "text": "x == None"
            },
            {
              "t": "text",
              "text": " with "
            },
            {
              "t": "code",
              "text": "x is None"
            },
            {
              "t": "text",
              "text": ". From Python, the "
            },
            {
              "t": "code",
              "text": "fix_code"
            },
            {
              "t": "text",
              "text": " function takes a string of source and returns the fixed string. Unlike "
            },
            {
              "t": "link",
              "href": "#black",
              "label": [
                {
                  "t": "text",
                  "text": "Black"
                }
              ]
            },
            {
              "t": "text",
              "text": ", which reformats every line in its own style, "
            },
            {
              "t": "fact",
              "fact": "F70"
            },
            {
              "t": "text",
              "text": " changes only the lines pycodestyle flags."
            }
          ],
          "facts": [
            {
              "label": "Downloads / mo",
              "value": [
                {
                  "t": "fact",
                  "fact": "F195"
                }
              ]
            },
            {
              "label": "Stars",
              "value": [
                {
                  "t": "fact",
                  "fact": "F201"
                }
              ]
            },
            {
              "label": "Last release",
              "value": [
                {
                  "t": "fact",
                  "fact": "F197"
                }
              ]
            },
            {
              "label": "License",
              "value": [
                {
                  "t": "fact",
                  "fact": "F196"
                }
              ]
            },
            {
              "label": "Capabilities",
              "value": [
                {
                  "t": "link",
                  "href": "https://raw.githubusercontent.com/hhatto/autopep8/main/README.rst",
                  "label": [
                    {
                      "t": "text",
                      "text": "From the "
                    },
                    {
                      "t": "fact",
                      "fact": "F194"
                    },
                    {
                      "t": "text",
                      "text": " docs"
                    }
                  ]
                }
              ]
            }
          ],
          "pros": [
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F81"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F82"
                }
              ]
            },
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F83"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F84"
                }
              ]
            }
          ],
          "cons": [
            {
              "lead": [
                {
                  "t": "text",
                  "text": "Behavior-changing fixes"
                }
              ],
              "body": [
                {
                  "t": "text",
                  "text": "Changing "
                },
                {
                  "t": "code",
                  "text": "x == None"
                },
                {
                  "t": "text",
                  "text": " to "
                },
                {
                  "t": "code",
                  "text": "x is None"
                },
                {
                  "t": "text",
                  "text": " changes behavior when a class overrides "
                },
                {
                  "t": "code",
                  "text": "__eq__"
                },
                {
                  "t": "text",
                  "text": ". Fixes of that kind run only with "
                },
                {
                  "t": "code",
                  "text": "--aggressive"
                },
                {
                  "t": "text",
                  "text": "."
                }
              ]
            },
            {
              "lead": [
                {
                  "t": "text",
                  "text": "Some reports stay unfixed"
                }
              ],
              "body": [
                {
                  "t": "text",
                  "text": "Bad indentation that breaks syntax, and comments that look like code, are left for a person to fix."
                }
              ]
            }
          ],
          "tabs": [
            {
              "label": [
                {
                  "t": "fact",
                  "fact": "F206"
                }
              ],
              "stars": [
                {
                  "t": "fact",
                  "fact": "F207"
                }
              ],
              "usedBy": [
                {
                  "t": "link",
                  "href": "https://github.com/coala/coala-bears",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F206"
                    }
                  ]
                },
                {
                  "t": "text",
                  "text": " "
                }
              ],
              "language": "python",
              "code": "def autopep8_fix_code_cell(source, options=None, apply_config=None):\n    \"\"\"\n    Applies autopep8.fix_code and takes care of newline characters.\n\n    autopep8.fix_code automatically adds a final newline at the end,\n    e.g. ``autopep8.fix_code('a=1')`` yields 'a = 1\\\\n'.\n    Note that this is not related to the 'W292' flag, i.e.\n    ``autopep8.fix_code('a=1', options=dict(ignore=('W292',)))`` gives\n    the same result.\n    For notebook code cells, this behaviour does not make sense, hence\n    newline is removed if ``source`` does not end with one.\n    \"\"\"\n    source_corrected = autopep8.fix_code(source,\n                                         apply_config=apply_config,\n                                         options=options)\n\n    if not source.endswith('\\n'):\n        return source_corrected[:-1]\n\n    return source_corrected\n",
              "prov": [
                {
                  "t": "link",
                  "href": "https://github.com/coala/coala-bears/blob/7d21a59891b6ad048bbe28de097cbb5693c648c7/bears/python/PEP8NotebookBear.py#L44-L63",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F205"
                    }
                  ]
                }
              ],
              "more": [
                {
                  "t": "link",
                  "href": "https://dashboard.exa.ai/playground/search?q=Python%20projects%20using%20autopep8%20for%20source%20formatting%2C%20generated%20modules%20and%20editor%20integrations&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D",
                  "label": [
                    {
                      "t": "text",
                      "text": "More projects using "
                    },
                    {
                      "t": "fact",
                      "fact": "F194"
                    },
                    {
                      "t": "text",
                      "text": " →"
                    }
                  ]
                }
              ]
            },
            {
              "label": [
                {
                  "t": "text",
                  "text": "Quickstart"
                }
              ],
              "language": "python",
              "code": "import autopep8\nautopep8.fix_code('x= 123\\n')\n",
              "prov": [
                {
                  "t": "text",
                  "text": "From "
                },
                {
                  "t": "link",
                  "href": "https://raw.githubusercontent.com/hhatto/autopep8/main/README.rst",
                  "label": [
                    {
                      "t": "text",
                      "text": "README.rst"
                    }
                  ]
                }
              ]
            }
          ],
          "install": [
            {
              "t": "fact",
              "fact": "F199"
            }
          ]
        },
        {
          "b": "entry",
          "anchor": "yapf",
          "name": [
            {
              "t": "fact",
              "fact": "F208"
            }
          ],
          "links": [
            {
              "label": "GitHub",
              "href": "https://github.com/google/yapf"
            },
            {
              "label": "PyPI",
              "href": "https://pypi.org/project/yapf"
            },
            {
              "label": "Docs",
              "href": "https://github.com/google/yapf/blob/main/README.md"
            }
          ],
          "what": [
            {
              "t": "text",
              "text": "YAPF is a Python formatter derived from clang-format. For each piece of code, the algorithm computes the layout that best fits the configured style. That style starts from a predefined one, such as Google's, with individual settings in a "
            },
            {
              "t": "code",
              "text": ".style.yapf"
            },
            {
              "t": "text",
              "text": " file or "
            },
            {
              "t": "code",
              "text": "pyproject.toml"
            },
            {
              "t": "text",
              "text": ". Two calls make up the library API. "
            },
            {
              "t": "code",
              "text": "FormatCode"
            },
            {
              "t": "text",
              "text": " formats a string of code, while "
            },
            {
              "t": "code",
              "text": "FormatFile"
            },
            {
              "t": "text",
              "text": " reads and formats a file. Both accept a "
            },
            {
              "t": "code",
              "text": "lines"
            },
            {
              "t": "text",
              "text": " argument that limits formatting to chosen line ranges, the way editors format a selection. YAPF exposes dozens of style settings, compared with the handful in "
            },
            {
              "t": "link",
              "href": "#black",
              "label": [
                {
                  "t": "text",
                  "text": "Black"
                }
              ]
            },
            {
              "t": "text",
              "text": "."
            }
          ],
          "facts": [
            {
              "label": "Downloads / mo",
              "value": [
                {
                  "t": "fact",
                  "fact": "F209"
                }
              ]
            },
            {
              "label": "Stars",
              "value": [
                {
                  "t": "fact",
                  "fact": "F215"
                }
              ]
            },
            {
              "label": "Last release",
              "value": [
                {
                  "t": "fact",
                  "fact": "F211"
                }
              ]
            },
            {
              "label": "License",
              "value": [
                {
                  "t": "fact",
                  "fact": "F210"
                }
              ]
            },
            {
              "label": "Capabilities",
              "value": [
                {
                  "t": "link",
                  "href": "https://github.com/google/yapf/blob/main/README.md",
                  "label": [
                    {
                      "t": "text",
                      "text": "From the "
                    },
                    {
                      "t": "fact",
                      "fact": "F208"
                    },
                    {
                      "t": "text",
                      "text": " docs"
                    }
                  ]
                }
              ]
            }
          ],
          "pros": [
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F106"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F107"
                }
              ]
            },
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F108"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F109"
                }
              ]
            }
          ],
          "cons": [
            {
              "lead": [
                {
                  "t": "text",
                  "text": "Newer syntax missing"
                }
              ],
              "body": [
                {
                  "t": "text",
                  "text": "Type parameter syntax and the formalized f-string grammar from recent Python releases aren't supported yet."
                }
              ]
            },
            {
              "lead": [
                {
                  "t": "text",
                  "text": "Large data literals"
                }
              ],
              "body": [
                {
                  "t": "text",
                  "text": "Large data literals can come out badly formatted. The README suggests wrapping them in "
                },
                {
                  "t": "code",
                  "text": "# yapf: disable"
                },
                {
                  "t": "text",
                  "text": " and "
                },
                {
                  "t": "code",
                  "text": "# yapf: enable"
                },
                {
                  "t": "text",
                  "text": " comments."
                }
              ]
            },
            {
              "lead": [
                {
                  "t": "text",
                  "text": "Beta releases"
                }
              ],
              "body": [
                {
                  "t": "text",
                  "text": "The README describes YAPF as beta. Released versions may change often."
                }
              ]
            }
          ],
          "tabs": [
            {
              "label": [
                {
                  "t": "fact",
                  "fact": "F220"
                }
              ],
              "stars": [
                {
                  "t": "fact",
                  "fact": "F221"
                }
              ],
              "usedBy": [
                {
                  "t": "link",
                  "href": "https://github.com/python-lsp/python-lsp-server",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F220"
                    }
                  ]
                },
                {
                  "t": "text",
                  "text": " "
                }
              ],
              "language": "python",
              "code": "def get_style_config(document_path, options=None):\n    # Exclude file if it follows the patterns for that\n    exclude_patterns_from_ignore_file = file_resources.GetExcludePatternsForDir(\n        os.getcwd()\n    )\n    if file_resources.IsIgnored(document_path, exclude_patterns_from_ignore_file):\n        return []\n\n    # Get the default styles as a string\n    # for a preset configuration, i.e. \"pep8\"\n    style_config = file_resources.GetDefaultStyleForDir(os.path.dirname(document_path))\n    if options is None:\n        return style_config\n\n    # We have options passed from LSP format request\n    # let's pass them to the formatter.\n    # First we want to get a dictionary of the preset style\n    # to pass instead of a string so that we can modify it\n    style_config = style.CreateStyleFromConfig(style_config)\n\n    use_tabs = style_config[\"USE_TABS\"]\n    indent_width = style_config[\"INDENT_WIDTH\"]\n\n    if options.get(\"tabSize\") is not None:\n        indent_width = max(int(options.get(\"tabSize\")), 1)\n\n    if options.get(\"insertSpaces\") is not None:\n        # TODO is it guaranteed to be a boolean, or can it be a string?\n        use_tabs = not options.get(\"insertSpaces\")\n\n        if use_tabs:\n            # Indent width doesn't make sense when using tabs\n            # the specifications state: \"Size of a tab in spaces\"\n            indent_width = 1\n\n    style_config[\"USE_TABS\"] = use_tabs\n    style_config[\"INDENT_WIDTH\"] = indent_width\n    style_config[\"CONTINUATION_INDENT_WIDTH\"] = indent_width\n\n    for style_option, value in options.items():\n        # Apply arbitrary options passed as formatter options\n        if style_option not in style_config:\n            # ignore if it's not a known yapf config\n            continue\n\n        style_config[style_option] = value\n\n    return style_config\n",
              "prov": [
                {
                  "t": "link",
                  "href": "https://github.com/python-lsp/python-lsp-server/blob/a3620069a607a63ed52569fde188e9301feae93a/pylsp/plugins/yapf_format.py#L43-L90",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F219"
                    }
                  ]
                }
              ],
              "more": [
                {
                  "t": "link",
                  "href": "https://dashboard.exa.ai/playground/search?q=Python%20projects%20using%20yapf%20for%20source%20formatting%2C%20generated%20modules%20and%20editor%20integrations&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D",
                  "label": [
                    {
                      "t": "text",
                      "text": "More projects using "
                    },
                    {
                      "t": "fact",
                      "fact": "F208"
                    },
                    {
                      "t": "text",
                      "text": " →"
                    }
                  ]
                }
              ]
            },
            {
              "label": [
                {
                  "t": "text",
                  "text": "Quickstart"
                }
              ],
              "language": "python",
              "code": "from yapf.yapflib.yapf_api import FormatCode  # reformat a string of code\nformatted_code, changed = FormatCode(\"f ( a = 1, b = 2 )\")\n",
              "prov": [
                {
                  "t": "text",
                  "text": "From "
                },
                {
                  "t": "link",
                  "href": "https://github.com/google/yapf/blob/main/README.md",
                  "label": [
                    {
                      "t": "text",
                      "text": "README.md"
                    }
                  ]
                }
              ]
            }
          ],
          "install": [
            {
              "t": "fact",
              "fact": "F213"
            }
          ]
        }
      ]
    }
  ],
  "questions": [
    {
      "q": "Which Python formatter should I use?",
      "a": [
        {
          "t": "text",
          "text": "Use "
        },
        {
          "t": "link",
          "href": "#ruff",
          "label": [
            {
              "t": "text",
              "text": "Ruff"
            }
          ]
        },
        {
          "t": "text",
          "text": " for a new project. It formats and lints in one tool, and its formatter is a drop-in replacement for Black. Keep "
        },
        {
          "t": "link",
          "href": "#black",
          "label": [
            {
              "t": "text",
              "text": "Black"
            }
          ]
        },
        {
          "t": "text",
          "text": " in projects that already run it, and add "
        },
        {
          "t": "link",
          "href": "#isort",
          "label": [
            {
              "t": "text",
              "text": "isort"
            }
          ]
        },
        {
          "t": "text",
          "text": " with the Black profile to sort imports."
        }
      ]
    },
    {
      "q": "Ruff vs Black: which should I use?",
      "a": [
        {
          "t": "text",
          "text": "Both give nearly the same output, because Ruff's formatter is a drop-in replacement for Black, but it differs in a few deliberate ways, so pick one and don't alternate. Ruff also lints in the same tool, and its formatter doesn't sort imports, so run "
        },
        {
          "t": "code",
          "text": "ruff check --select I --fix"
        },
        {
          "t": "text",
          "text": " before "
        },
        {
          "t": "code",
          "text": "ruff format"
        },
        {
          "t": "text",
          "text": "."
        }
      ]
    },
    {
      "q": "How do I run ruff format?",
      "a": [
        {
          "t": "text",
          "text": "Run "
        },
        {
          "t": "code",
          "text": "ruff format"
        },
        {
          "t": "text",
          "text": " to format every Python file in the current directory. In CI, add "
        },
        {
          "t": "code",
          "text": "--check"
        },
        {
          "t": "text",
          "text": " to fail on unformatted files without writing any changes."
        }
      ]
    },
    {
      "q": "autopep8 vs Black: which should I use?",
      "a": [
        {
          "t": "text",
          "text": "Use Black to reformat whole files in one opinionated style. Use "
        },
        {
          "t": "link",
          "href": "#autopep",
          "label": [
            {
              "t": "fact",
              "fact": "F70"
            }
          ]
        },
        {
          "t": "text",
          "text": " to fix only the problems pycodestyle reports: by default it changes whitespace and leaves the rest of the layout as written."
        }
      ]
    },
    {
      "q": "YAPF vs Black: which should I use?",
      "a": [
        {
          "t": "text",
          "text": "Use Black for one fixed style with little to configure. Choose YAPF to match a custom house style through its many style settings, but its last release was in "
        },
        {
          "t": "fact",
          "fact": "F212"
        },
        {
          "t": "text",
          "text": ", and it doesn't support some newer Python syntax yet."
        }
      ]
    }
  ],
  "facts": {
    "F1": {
      "label": "Library name, ruff",
      "display": "Ruff",
      "asOf": "2026-11-18"
    },
    "F2": {
      "label": "Monthly downloads, ruff",
      "display": "417.6M",
      "asOf": "2026-11-17"
    },
    "F3": {
      "label": "License, ruff",
      "display": "MIT",
      "asOf": "2026-11-18"
    },
    "F4": {
      "label": "Package release, ruff",
      "display": "0.17.5",
      "asOf": "2026-11-12"
    },
    "F5": {
      "label": "Package release date, ruff",
      "display": "Nov 2026",
      "asOf": "2026-11-12"
    },
    "F6": {
      "label": "Repository stars, ruff",
      "display": "51.3K",
      "asOf": "2026-11-18"
    },
    "F7": {
      "label": "Python formatting API, ruff",
      "display": "Unsupported",
      "asOf": "2026-11-18"
    },
    "F8": {
      "label": "Line-range formatting, ruff",
      "display": "Built-in",
      "asOf": "2026-11-18"
    },
    "F9": {
      "label": "Diff preview, ruff",
      "display": "Built-in",
      "asOf": "2026-11-18"
    },
    "F10": {
      "label": "Install, ruff",
      "display": "pip install ruff",
      "asOf": "2026-11-18"
    },
    "F11": {
      "label": "What it does, ruff",
      "display": "A drop-in replacement for Black that runs as ruff format, in the same tool as the Ruff linter.",
      "asOf": "2026-11-18"
    },
    "F12": {
      "label": "strengths lead, ruff",
      "display": "Formats docstring examples",
      "asOf": "2026-11-18"
    },
    "F13": {
      "label": "strengths, ruff",
      "display": "Turn on docstring code formatting to format the Python examples inside docstrings.",
      "asOf": "2026-11-18"
    },
    "F14": {
      "label": "strengths lead, ruff",
      "display": "Formats notebooks natively",
      "asOf": "2026-11-18"
    },
    "F15": {
      "label": "strengths, ruff",
      "display": "Run ruff format on Jupyter notebooks without a separate wrapper.",
      "asOf": "2026-11-18"
    },
    "F16": {
      "label": "limitations lead, ruff",
      "display": "Don't alternate with Black",
      "asOf": "2026-11-18"
    },
    "F17": {
      "label": "limitations, ruff",
      "display": "Ruff deviates from Black in a few deliberate ways, so use one formatter per project.",
      "asOf": "2026-11-18"
    },
    "F18": {
      "label": "limitations lead, ruff",
      "display": "Lines can exceed line-length",
      "asOf": "2026-11-18"
    },
    "F19": {
      "label": "limitations, ruff",
      "display": "Wrapping is best effort, so the E501 rule can still flag formatted lines.",
      "asOf": "2026-11-18"
    },
    "F20": {
      "label": "Quickstart, ruff",
      "display": "ruff format                   # Format all files in the current directory.\nruff format path/to/code/     # Format all files in `path/to/code` (and any subdirectories).\nruff format path/to/file.py   # Format a single file.\n\n",
      "asOf": "2026-11-18"
    },
    "F21": {
      "label": "Library name, black",
      "display": "Black",
      "asOf": "2026-11-18"
    },
    "F22": {
      "label": "Monthly downloads, black",
      "display": "114.4M",
      "asOf": "2026-11-17"
    },
    "F23": {
      "label": "License, black",
      "display": "MIT",
      "asOf": "2026-11-18"
    },
    "F24": {
      "label": "Package release, black",
      "display": "26.10.1",
      "asOf": "2026-10-10"
    },
    "F25": {
      "label": "Package release date, black",
      "display": "Oct 2026",
      "asOf": "2026-10-10"
    },
    "F26": {
      "label": "Repository stars, black",
      "display": "42.2K",
      "asOf": "2026-11-18"
    },
    "F27": {
      "label": "Python formatting API, black",
      "display": "Built-in",
      "asOf": "2026-11-18"
    },
    "F28": {
      "label": "Line-range formatting, black",
      "display": "Built-in",
      "asOf": "2026-11-18"
    },
    "F29": {
      "label": "Diff preview, black",
      "display": "Built-in",
      "asOf": "2026-11-18"
    },
    "F30": {
      "label": "Install, black",
      "display": "pip install black",
      "asOf": "2026-11-18"
    },
    "F31": {
      "label": "What it does, black",
      "display": "Reformats Python code in one uncompromising style.",
      "asOf": "2026-11-18"
    },
    "F32": {
      "label": "strengths lead, black",
      "display": "Checks the code still matches",
      "asOf": "2026-11-18"
    },
    "F33": {
      "label": "strengths, black",
      "display": "After formatting, Black confirms the AST is unchanged. The --fast flag skips this check.",
      "asOf": "2026-11-18"
    },
    "F34": {
      "label": "strengths lead, black",
      "display": "Formats Jupyter notebooks",
      "asOf": "2026-11-18"
    },
    "F35": {
      "label": "strengths, black",
      "display": "Pass --ipynb to format any input as a notebook, such as code piped on standard input.",
      "asOf": "2026-11-18"
    },
    "F36": {
      "label": "limitations lead, black",
      "display": "Line ranges can spill over",
      "asOf": "2026-11-18"
    },
    "F37": {
      "label": "limitations, black",
      "display": "Black can still reformat lines outside the range when a statement spans several lines.",
      "asOf": "2026-11-18"
    },
    "F38": {
      "label": "limitations lead, black",
      "display": "One pyproject.toml per run",
      "asOf": "2026-11-18"
    },
    "F39": {
      "label": "limitations, black",
      "display": "Black reads one pyproject.toml per run and never merges settings from nested files.",
      "asOf": "2026-11-18"
    },
    "F40": {
      "label": "Quickstart, black",
      "display": "black {source_file_or_directory}\n",
      "asOf": "2026-11-18"
    },
    "F41": {
      "label": "Project function, black",
      "display": "def _build_separate_module(self, elements: list, module_name: str,\n                           module_dir: str) -> None:\n    \"\"\"\n    Constructs and writes the Python representation of a specific model\n    module, when the split_views=True in the read_vensim function.\n\n    Parameters\n    ----------\n    elements: list\n        Elements belonging to the module module_name.\n\n    module_name: str\n        Name of the module\n\n    module_dir: str\n        Path of the directory where module files will be stored.\n\n    Returns\n    -------\n    None\n\n    \"\"\"\n    text = textwrap.dedent('''\n    \"\"\"\n    Module %(module_name)s\n    Translated using PySD version %(version)s\n    \"\"\"\n    ''' % {\n        \"module_name\": \".\".join(module_name.parts[1:]),\n        \"version\": __version__,\n    })\n    funcs = self._generate_functions(elements)\n    text += funcs\n    text = black.format_file_contents(\n        text, fast=True, mode=black.FileMode())\n\n    outfile_name = module_dir / module_name.with_suffix(\".py\")\n\n    with outfile_name.open(\"w\", encoding=\"UTF-8\") as out:\n        out.write(text)\n",
      "asOf": "2026-11-18"
    },
    "F42": {
      "label": "Project function reference, black",
      "display": "python_model_builder.py · _build_separate_module()",
      "asOf": "2026-11-18"
    },
    "F43": {
      "label": "Project repository, black",
      "display": "SDXorg/pysd",
      "asOf": "2026-11-18"
    },
    "F44": {
      "label": "Project stars, SDXorg/pysd",
      "display": "467",
      "asOf": "2026-11-18"
    },
    "F45": {
      "label": "Project push date, SDXorg/pysd",
      "display": "Oct 2026",
      "asOf": "2026-10-05"
    },
    "F46": {
      "label": "Library name, isort",
      "display": "isort",
      "asOf": "2026-11-18"
    },
    "F47": {
      "label": "Monthly downloads, isort",
      "display": "97.0M",
      "asOf": "2026-11-17"
    },
    "F48": {
      "label": "License, isort",
      "display": "MIT",
      "asOf": "2026-11-18"
    },
    "F49": {
      "label": "Package release, isort",
      "display": "9.0.2",
      "asOf": "2026-09-28"
    },
    "F50": {
      "label": "Package release date, isort",
      "display": "Sep 2026",
      "asOf": "2026-09-28"
    },
    "F51": {
      "label": "Repository stars, isort",
      "display": "7.0K",
      "asOf": "2026-11-18"
    },
    "F52": {
      "label": "Python formatting API, isort",
      "display": "Built-in",
      "asOf": "2026-11-18"
    },
    "F53": {
      "label": "Diff preview, isort",
      "display": "Built-in",
      "asOf": "2026-11-18"
    },
    "F54": {
      "label": "Install, isort",
      "display": "pip install isort",
      "asOf": "2026-11-18"
    },
    "F55": {
      "label": "What it does, isort",
      "display": "Sorts imports alphabetically and groups them into sections.",
      "asOf": "2026-11-18"
    },
    "F56": {
      "label": "strengths lead, isort",
      "display": "Sorts imports in a string",
      "asOf": "2026-11-18"
    },
    "F57": {
      "label": "strengths, isort",
      "display": "Call isort.code with source text to get it back with imports sorted.",
      "asOf": "2026-11-18"
    },
    "F58": {
      "label": "strengths lead, isort",
      "display": "Works alongside Black",
      "asOf": "2026-11-18"
    },
    "F59": {
      "label": "strengths, isort",
      "display": "Set the isort profile to black, and the two tools agree on import layout.",
      "asOf": "2026-11-18"
    },
    "F60": {
      "label": "limitations lead, isort",
      "display": "Imports only",
      "asOf": "2026-11-18"
    },
    "F61": {
      "label": "limitations, isort",
      "display": "Run a formatter alongside it for the rest of the file.",
      "asOf": "2026-11-18"
    },
    "F62": {
      "label": "limitations lead, isort",
      "display": "Black compatibility needs a profile",
      "asOf": "2026-11-18"
    },
    "F63": {
      "label": "limitations, isort",
      "display": "Set profile to black so import wrapping matches Black.",
      "asOf": "2026-11-18"
    },
    "F64": {
      "label": "Quickstart, isort",
      "display": "import isort\n\nsorted_code = isort.code(\"import b\\nimport a\\n\")\n",
      "asOf": "2026-11-18"
    },
    "F65": {
      "label": "Project function, isort",
      "display": "def format_python_code(code: str, library: str) -> str:\n    # Choose formatter based on the specified library\n    if library == \"black\":\n        # Format code using Black with default settings\n        formatted_code: str = black.format_str(code, mode=black.FileMode())\n\n    elif library == \"autopep8\":\n        # Format code using autopep8\n        formatted_code = autopep8.fix_code(code)\n\n    elif library == \"yapf\":\n        # Format code using yapf; returns (formatted_code, changed_flag)\n        formatted_code, _ = yapf.yapf_api.FormatCode(code)\n\n    elif library == \"ruff\":\n        # Format code using a custom wrapper for Ruff (assumes string input/output)\n        formatted_code = format_ruff_python(code)\n\n    else:\n        # Raise a ValueError for unrecognized formatter names\n        raise ValueError(\n            f\"[PYTHON-CODE-FORMATTING] Unknown formatting library selected: {library}\"\n        )\n\n    # Sort and format imports using isort with Black compatibility\n    formatted_code = isort.code(formatted_code, config=isort.Config(profile=\"black\"))\n\n    return formatted_code\n",
      "asOf": "2026-11-18"
    },
    "F66": {
      "label": "Project function reference, isort",
      "display": "codequality.py · format_python_code()",
      "asOf": "2026-11-18"
    },
    "F67": {
      "label": "Project repository, isort",
      "display": "matkuki/ExCo",
      "asOf": "2026-11-18"
    },
    "F68": {
      "label": "Project stars, matkuki/ExCo",
      "display": "163",
      "asOf": "2026-11-18"
    },
    "F69": {
      "label": "Project push date, matkuki/ExCo",
      "display": "Nov 2026",
      "asOf": "2026-11-15"
    },
    "F70": {
      "label": "Library name, autopep8",
      "display": "autopep8",
      "asOf": "2026-11-18"
    },
    "F71": {
      "label": "Monthly downloads, autopep8",
      "display": "8.0M",
      "asOf": "2026-11-17"
    },
    "F72": {
      "label": "License, autopep8",
      "display": "MIT",
      "asOf": "2026-11-18"
    },
    "F73": {
      "label": "Package release, autopep8",
      "display": "2.3.2",
      "asOf": "2025-01-14"
    },
    "F74": {
      "label": "Package release date, autopep8",
      "display": "Jan 2025",
      "asOf": "2025-01-14"
    },
    "F75": {
      "label": "Repository stars, autopep8",
      "display": "4.7K",
      "asOf": "2026-11-18"
    },
    "F76": {
      "label": "Python formatting API, autopep8",
      "display": "Built-in",
      "asOf": "2026-11-18"
    },
    "F77": {
      "label": "Line-range formatting, autopep8",
      "display": "Built-in",
      "asOf": "2026-11-18"
    },
    "F78": {
      "label": "Diff preview, autopep8",
      "display": "Built-in",
      "asOf": "2026-11-18"
    },
    "F79": {
      "label": "Install, autopep8",
      "display": "pip install autopep8",
      "asOf": "2026-11-18"
    },
    "F80": {
      "label": "What it does, autopep8",
      "display": "Fixes the style problems pycodestyle reports, so code follows PEP 8.",
      "asOf": "2026-11-18"
    },
    "F81": {
      "label": "strengths lead, autopep8",
      "display": "Fixes selected rules",
      "asOf": "2026-11-18"
    },
    "F82": {
      "label": "strengths, autopep8",
      "display": "Pass --select or --ignore with pycodestyle codes to choose which fixes run.",
      "asOf": "2026-11-18"
    },
    "F83": {
      "label": "strengths lead, autopep8",
      "display": "Formats code strings",
      "asOf": "2026-11-18"
    },
    "F84": {
      "label": "strengths, autopep8",
      "display": "Call autopep8.fix_code() on a string of source code.",
      "asOf": "2026-11-18"
    },
    "F85": {
      "label": "limitations lead, autopep8",
      "display": "Aggressive fixes can change meaning",
      "asOf": "2026-11-18"
    },
    "F86": {
      "label": "limitations, autopep8",
      "display": "At higher aggressiveness, x == True becomes x, which can change behavior.",
      "asOf": "2026-11-18"
    },
    "F87": {
      "label": "limitations lead, autopep8",
      "display": "Whitespace-only by default",
      "asOf": "2026-11-18"
    },
    "F88": {
      "label": "limitations, autopep8",
      "display": "Add --aggressive to make changes beyond whitespace.",
      "asOf": "2026-11-18"
    },
    "F89": {
      "label": "Quickstart, autopep8",
      "display": "import autopep8\nautopep8.fix_code('x= 123\\n')\n",
      "asOf": "2026-11-18"
    },
    "F90": {
      "label": "Project function, autopep8",
      "display": "def autopep8_fix_code_cell(source, options=None, apply_config=None):\n    \"\"\"\n    Applies autopep8.fix_code and takes care of newline characters.\n\n    autopep8.fix_code automatically adds a final newline at the end,\n    e.g. ``autopep8.fix_code('a=1')`` yields 'a = 1\\\\n'.\n    Note that this is not related to the 'W292' flag, i.e.\n    ``autopep8.fix_code('a=1', options=dict(ignore=('W292',)))`` gives\n    the same result.\n    For notebook code cells, this behaviour does not make sense, hence\n    newline is removed if ``source`` does not end with one.\n    \"\"\"\n    source_corrected = autopep8.fix_code(source,\n                                         apply_config=apply_config,\n                                         options=options)\n\n    if not source.endswith('\\n'):\n        return source_corrected[:-1]\n\n    return source_corrected\n",
      "asOf": "2026-11-18"
    },
    "F91": {
      "label": "Project function reference, autopep8",
      "display": "PEP8NotebookBear.py · autopep8_fix_code_cell()",
      "asOf": "2026-11-18"
    },
    "F92": {
      "label": "Project repository, autopep8",
      "display": "coala/coala-bears",
      "asOf": "2026-11-18"
    },
    "F93": {
      "label": "Project stars, coala/coala-bears",
      "display": "297",
      "asOf": "2026-11-18"
    },
    "F94": {
      "label": "Project push date, coala/coala-bears",
      "display": "Oct 2022",
      "asOf": "2022-10-18"
    },
    "F95": {
      "label": "Library name, yapf",
      "display": "YAPF",
      "asOf": "2026-11-18"
    },
    "F96": {
      "label": "Monthly downloads, yapf",
      "display": "5.6M",
      "asOf": "2026-11-17"
    },
    "F97": {
      "label": "License, yapf",
      "display": "Apache",
      "asOf": "2026-11-18"
    },
    "F98": {
      "label": "Package release, yapf",
      "display": "0.43.0",
      "asOf": "2024-11-14"
    },
    "F99": {
      "label": "Package release date, yapf",
      "display": "Nov 2024",
      "asOf": "2024-11-14"
    },
    "F100": {
      "label": "Repository stars, yapf",
      "display": "14.0K",
      "asOf": "2026-11-18"
    },
    "F101": {
      "label": "Python formatting API, yapf",
      "display": "Built-in",
      "asOf": "2026-11-18"
    },
    "F102": {
      "label": "Line-range formatting, yapf",
      "display": "Built-in",
      "asOf": "2026-11-18"
    },
    "F103": {
      "label": "Diff preview, yapf",
      "display": "Built-in",
      "asOf": "2026-11-18"
    },
    "F104": {
      "label": "Install, yapf",
      "display": "pip install yapf",
      "asOf": "2026-11-18"
    },
    "F105": {
      "label": "What it does, yapf",
      "display": "Reformats Python code to a configured style, through its FormatCode and FormatFile APIs.",
      "asOf": "2026-11-18"
    },
    "F106": {
      "label": "strengths lead, yapf",
      "display": "Many style settings",
      "asOf": "2026-11-18"
    },
    "F107": {
      "label": "strengths, yapf",
      "display": "Tune individual formatting knobs; the style.py module lists every one.",
      "asOf": "2026-11-18"
    },
    "F108": {
      "label": "strengths lead, yapf",
      "display": "Formats chosen lines",
      "asOf": "2026-11-18"
    },
    "F109": {
      "label": "strengths, yapf",
      "display": "Pass a lines argument to format a snippet instead of the whole file, as editors do.",
      "asOf": "2026-11-18"
    },
    "F110": {
      "label": "limitations lead, yapf",
      "display": "Lags on newer syntax",
      "asOf": "2026-11-18"
    },
    "F111": {
      "label": "limitations, yapf",
      "display": "Python 3.12 type parameter syntax and PEP 701 f-strings aren't supported yet.",
      "asOf": "2026-11-18"
    },
    "F112": {
      "label": "limitations lead, yapf",
      "display": "Large data literals suffer",
      "asOf": "2026-11-18"
    },
    "F113": {
      "label": "limitations, yapf",
      "display": "Large data literals can come out badly formatted, so format those by hand.",
      "asOf": "2026-11-18"
    },
    "F114": {
      "label": "Quickstart, yapf",
      "display": "from yapf.yapflib.yapf_api import FormatCode  # reformat a string of code\nformatted_code, changed = FormatCode(\"f ( a = 1, b = 2 )\")\nformatted_code\nchanged\n",
      "asOf": "2026-11-18"
    },
    "F115": {
      "label": "Project function, yapf",
      "display": "def get_style_config(document_path, options=None):\n    # Exclude file if it follows the patterns for that\n    exclude_patterns_from_ignore_file = file_resources.GetExcludePatternsForDir(\n        os.getcwd()\n    )\n    if file_resources.IsIgnored(document_path, exclude_patterns_from_ignore_file):\n        return []\n\n    # Get the default styles as a string\n    # for a preset configuration, i.e. \"pep8\"\n    style_config = file_resources.GetDefaultStyleForDir(os.path.dirname(document_path))\n    if options is None:\n        return style_config\n\n    # We have options passed from LSP format request\n    # let's pass them to the formatter.\n    # First we want to get a dictionary of the preset style\n    # to pass instead of a string so that we can modify it\n    style_config = style.CreateStyleFromConfig(style_config)\n\n    use_tabs = style_config[\"USE_TABS\"]\n    indent_width = style_config[\"INDENT_WIDTH\"]\n\n    if options.get(\"tabSize\") is not None:\n        indent_width = max(int(options.get(\"tabSize\")), 1)\n\n    if options.get(\"insertSpaces\") is not None:\n        # TODO is it guaranteed to be a boolean, or can it be a string?\n        use_tabs = not options.get(\"insertSpaces\")\n\n        if use_tabs:\n            # Indent width doesn't make sense when using tabs\n            # the specifications state: \"Size of a tab in spaces\"\n            indent_width = 1\n\n    style_config[\"USE_TABS\"] = use_tabs\n    style_config[\"INDENT_WIDTH\"] = indent_width\n    style_config[\"CONTINUATION_INDENT_WIDTH\"] = indent_width\n\n    for style_option, value in options.items():\n        # Apply arbitrary options passed as formatter options\n        if style_option not in style_config:\n            # ignore if it's not a known yapf config\n            continue\n\n        style_config[style_option] = value\n\n    return style_config\n",
      "asOf": "2026-11-18"
    },
    "F116": {
      "label": "Project function reference, yapf",
      "display": "yapf_format.py · get_style_config()",
      "asOf": "2026-11-18"
    },
    "F117": {
      "label": "Project repository, yapf",
      "display": "python-lsp/python-lsp-server",
      "asOf": "2026-11-18"
    },
    "F118": {
      "label": "Project stars, python-lsp/python-lsp-server",
      "display": "2.6K",
      "asOf": "2026-11-18"
    },
    "F119": {
      "label": "Project push date, python-lsp/python-lsp-server",
      "display": "Jul 2026",
      "asOf": "2026-07-27"
    },
    "F120": {
      "label": "Developer need",
      "display": "Formatting and linting together",
      "asOf": "2026-11-18"
    },
    "F121": {
      "label": "Why choose ruff",
      "display": "formats and lints with one tool",
      "asOf": "2026-11-18"
    },
    "F122": {
      "label": "Developer need in introduction",
      "display": "one toolchain for Python linting and formatting",
      "asOf": "2026-11-18"
    },
    "F123": {
      "label": "When to consider black",
      "display": "for a formatter with a stable yearly style",
      "asOf": "2026-11-18"
    },
    "F124": {
      "label": "Developer need",
      "display": "An existing Black setup",
      "asOf": "2026-11-18"
    },
    "F125": {
      "label": "Why choose black",
      "display": "keeps existing Black formatting unchanged",
      "asOf": "2026-11-18"
    },
    "F126": {
      "label": "Developer need in introduction",
      "display": "an existing Black-formatted codebase",
      "asOf": "2026-11-18"
    },
    "F127": {
      "label": "When to consider ruff",
      "display": "to add linting in the same tool",
      "asOf": "2026-11-18"
    },
    "F128": {
      "label": "Developer need",
      "display": "Fixing only PEP 8 errors",
      "asOf": "2026-11-18"
    },
    "F129": {
      "label": "Why choose autopep8",
      "display": "fixes only the selected PEP 8 rules",
      "asOf": "2026-11-18"
    },
    "F130": {
      "label": "Developer need in introduction",
      "display": "targeted fixes for selected PEP 8 violations",
      "asOf": "2026-11-18"
    },
    "F131": {
      "label": "When to consider black",
      "display": "to reformat every file",
      "asOf": "2026-11-18"
    },
    "F132": {
      "label": "Developer need",
      "display": "A custom house style",
      "asOf": "2026-11-18"
    },
    "F133": {
      "label": "Why choose yapf",
      "display": "exposes many style settings",
      "asOf": "2026-11-18"
    },
    "F134": {
      "label": "Developer need in introduction",
      "display": "an established style requiring layout customization",
      "asOf": "2026-11-18"
    },
    "F135": {
      "label": "When to consider black",
      "display": "for a fixed style with no settings",
      "asOf": "2026-11-18"
    },
    "F136": {
      "label": "Developer need",
      "display": "Sorted imports",
      "asOf": "2026-11-18"
    },
    "F137": {
      "label": "Why choose isort",
      "display": "sorts and groups imports, nothing else",
      "asOf": "2026-11-18"
    },
    "F138": {
      "label": "Developer need in introduction",
      "display": "import sorting alongside another formatter",
      "asOf": "2026-11-18"
    },
    "F139": {
      "label": "When to consider ruff",
      "display": "for projects already on Ruff, which sorts imports too",
      "asOf": "2026-11-18"
    },
    "F140": {
      "label": "Page introduction",
      "display": "Python code formatter libraries let developers apply consistent formatting to source code.",
      "asOf": "2026-11-18"
    },
    "F141": {
      "label": "Page introduction",
      "display": "Start with Ruff when adopting Python linting and formatting together.",
      "asOf": "2026-11-18"
    },
    "F142": {
      "label": "Page introduction",
      "display": "Keep Black when an existing project already follows its formatting workflow.",
      "asOf": "2026-11-18"
    },
    "F143": {
      "label": "FAQ: Which Python formatter should I use?",
      "display": "Start with Ruff for a shared linting and formatting toolchain.",
      "asOf": "2026-11-18"
    },
    "F144": {
      "label": "FAQ: Which Python formatter should I use?",
      "display": "Keep Black for an established Black formatting workflow.",
      "asOf": "2026-11-18"
    },
    "F145": {
      "label": "FAQ: Which Python formatter should I use?",
      "display": "Choose YAPF when your project needs configurable layout rules.",
      "asOf": "2026-11-18"
    },
    "F146": {
      "label": "FAQ: Should I replace Black with Ruff?",
      "display": "Consider Ruff when consolidating linting and formatting into one toolchain; keeping an established Black workflow is also reasonable.",
      "asOf": "2026-11-18"
    },
    "F147": {
      "label": "FAQ: Should I replace Black with Ruff?",
      "display": "Choose one formatter for the project: Ruff explicitly advises against alternating with Black.",
      "asOf": "2026-11-18"
    },
    "F148": {
      "label": "FAQ: How do I check Python formatting in CI without changing files?",
      "display": "Use ruff format --check to check formatting without rewriting the files.",
      "asOf": "2026-11-18"
    },
    "F149": {
      "label": "FAQ: How do I check Python formatting in CI without changing files?",
      "display": "Black also provides --check, which returns a status instead of writing files.",
      "asOf": "2026-11-18"
    },
    "F150": {
      "label": "FAQ: Do I need isort if I already use Ruff?",
      "display": "Ruff’s formatter does not sort imports; enable the linter’s import-sorting fixes before formatting.",
      "asOf": "2026-11-18"
    },
    "F151": {
      "label": "FAQ: Do I need isort if I already use Ruff?",
      "display": "Keep isort when its additional configuration options are required.",
      "asOf": "2026-11-18"
    },
    "F152": {
      "label": "Library name, ruff",
      "display": "Ruff",
      "asOf": "2026-11-18"
    },
    "F153": {
      "label": "Monthly downloads, ruff",
      "display": "428.0M",
      "asOf": "2026-11-18"
    },
    "F154": {
      "label": "License, ruff",
      "display": "MIT",
      "asOf": "2026-11-18"
    },
    "F155": {
      "label": "Package release, ruff",
      "display": "0.17.5",
      "asOf": "2026-11-18"
    },
    "F156": {
      "label": "Package release date, ruff",
      "display": "Nov 2026",
      "asOf": "2026-11-18"
    },
    "F157": {
      "label": "Install, ruff",
      "display": "pip install ruff",
      "asOf": "2026-11-18"
    },
    "F158": {
      "label": "Quickstart, ruff",
      "display": "ruff format                   # Format all files in the current directory.\n",
      "asOf": "2026-11-18"
    },
    "F159": {
      "label": "Repository stars, ruff",
      "display": "51.3K",
      "asOf": "2026-11-18"
    },
    "F160": {
      "label": "Python formatting API, ruff",
      "display": "No",
      "asOf": "2026-11-18"
    },
    "F161": {
      "label": "Line-range formatting, ruff",
      "display": "Yes",
      "asOf": "2026-11-18"
    },
    "F162": {
      "label": "Project function, ruff",
      "display": "def format_ruff_python(code: str) -> str:\n    with tempfile.TemporaryDirectory() as tmpdir:  # type: ignore\n        file_path: pathlib.Path = pathlib.Path(tmpdir) / \"temp_ruff_formatting_file.py\"\n        file_path.write_text(code, encoding=\"utf-8\")\n\n        result: subprocess.CompletedProcess[str] = subprocess.run(\n            [\"ruff\", \"format\", str(file_path)],\n            capture_output=True,\n            text=True,\n            encoding=\"utf-8\",  # Ensure subprocess handles UTF-8 output\n        )\n\n        if result.returncode != 0:\n            raise RuntimeError(f\"Ruff error:\\n{result.stderr}\")\n\n        return file_path.read_text(encoding=\"utf-8\")\n",
      "asOf": "2026-11-18"
    },
    "F163": {
      "label": "Project source file, ruff",
      "display": "codequality.py",
      "asOf": "2026-11-18"
    },
    "F164": {
      "label": "Project full_name, ruff",
      "display": "matkuki/ExCo",
      "asOf": "2026-11-18"
    },
    "F165": {
      "label": "Project stargazers_count, ruff",
      "display": "163",
      "asOf": "2026-11-18"
    },
    "F166": {
      "label": "Library name, black",
      "display": "Black",
      "asOf": "2026-11-18"
    },
    "F167": {
      "label": "Monthly downloads, black",
      "display": "116.2M",
      "asOf": "2026-11-18"
    },
    "F168": {
      "label": "License, black",
      "display": "MIT",
      "asOf": "2026-11-18"
    },
    "F169": {
      "label": "Package release, black",
      "display": "26.10.1",
      "asOf": "2026-11-18"
    },
    "F170": {
      "label": "Package release date, black",
      "display": "Oct 2026",
      "asOf": "2026-11-18"
    },
    "F171": {
      "label": "Install, black",
      "display": "pip install black",
      "asOf": "2026-11-18"
    },
    "F172": {
      "label": "Quickstart, black",
      "display": "black {source_file_or_directory}\n",
      "asOf": "2026-11-18"
    },
    "F173": {
      "label": "Repository stars, black",
      "display": "42.2K",
      "asOf": "2026-11-18"
    },
    "F174": {
      "label": "Python formatting API, black",
      "display": "Yes",
      "asOf": "2026-11-18"
    },
    "F175": {
      "label": "Line-range formatting, black",
      "display": "Yes",
      "asOf": "2026-11-18"
    },
    "F176": {
      "label": "Project function, black",
      "display": "def _build_separate_module(self, elements: list, module_name: str,\n                           module_dir: str) -> None:\n    \"\"\"\n    Constructs and writes the Python representation of a specific model\n    module, when the split_views=True in the read_vensim function.\n\n    Parameters\n    ----------\n    elements: list\n        Elements belonging to the module module_name.\n\n    module_name: str\n        Name of the module\n\n    module_dir: str\n        Path of the directory where module files will be stored.\n\n    Returns\n    -------\n    None\n\n    \"\"\"\n    text = textwrap.dedent('''\n    \"\"\"\n    Module %(module_name)s\n    Translated using PySD version %(version)s\n    \"\"\"\n    ''' % {\n        \"module_name\": \".\".join(module_name.parts[1:]),\n        \"version\": __version__,\n    })\n    funcs = self._generate_functions(elements)\n    text += funcs\n    text = black.format_file_contents(\n        text, fast=True, mode=black.FileMode())\n\n    outfile_name = module_dir / module_name.with_suffix(\".py\")\n\n    with outfile_name.open(\"w\", encoding=\"UTF-8\") as out:\n        out.write(text)\n",
      "asOf": "2026-11-18"
    },
    "F177": {
      "label": "Project source file, black",
      "display": "pysd/builders/python/python_model_builder.py",
      "asOf": "2026-11-18"
    },
    "F178": {
      "label": "Project full_name, black",
      "display": "SDXorg/pysd",
      "asOf": "2026-11-18"
    },
    "F179": {
      "label": "Project stargazers_count, black",
      "display": "467",
      "asOf": "2026-11-18"
    },
    "F180": {
      "label": "Library name, isort",
      "display": "isort",
      "asOf": "2026-11-18"
    },
    "F181": {
      "label": "Monthly downloads, isort",
      "display": "98.7M",
      "asOf": "2026-11-18"
    },
    "F182": {
      "label": "License, isort",
      "display": "MIT",
      "asOf": "2026-11-18"
    },
    "F183": {
      "label": "Package release, isort",
      "display": "9.0.2",
      "asOf": "2026-11-18"
    },
    "F184": {
      "label": "Package release date, isort",
      "display": "Sep 2026",
      "asOf": "2026-11-18"
    },
    "F185": {
      "label": "Install, isort",
      "display": "pip install isort",
      "asOf": "2026-11-18"
    },
    "F186": {
      "label": "Quickstart, isort",
      "display": "import isort\n\nsorted_code = isort.code(\"import b\\nimport a\\n\")\n",
      "asOf": "2026-11-18"
    },
    "F187": {
      "label": "Repository stars, isort",
      "display": "7.0K",
      "asOf": "2026-11-18"
    },
    "F188": {
      "label": "Python formatting API, isort",
      "display": "Yes",
      "asOf": "2026-11-18"
    },
    "F189": {
      "label": "Line-range formatting, isort",
      "display": "Undocumented",
      "asOf": "2026-11-18"
    },
    "F190": {
      "label": "Project function, isort",
      "display": "def format_python_code(code: str, library: str) -> str:\n    # Choose formatter based on the specified library\n    if library == \"black\":\n        # Format code using Black with default settings\n        formatted_code: str = black.format_str(code, mode=black.FileMode())\n\n    elif library == \"autopep8\":\n        # Format code using autopep8\n        formatted_code = autopep8.fix_code(code)\n\n    elif library == \"yapf\":\n        # Format code using yapf; returns (formatted_code, changed_flag)\n        formatted_code, _ = yapf.yapf_api.FormatCode(code)\n\n    elif library == \"ruff\":\n        # Format code using a custom wrapper for Ruff (assumes string input/output)\n        formatted_code = format_ruff_python(code)\n\n    else:\n        # Raise a ValueError for unrecognized formatter names\n        raise ValueError(\n            f\"[PYTHON-CODE-FORMATTING] Unknown formatting library selected: {library}\"\n        )\n\n    # Sort and format imports using isort with Black compatibility\n    formatted_code = isort.code(formatted_code, config=isort.Config(profile=\"black\"))\n\n    return formatted_code\n",
      "asOf": "2026-11-18"
    },
    "F191": {
      "label": "Project source file, isort",
      "display": "codequality.py",
      "asOf": "2026-11-18"
    },
    "F192": {
      "label": "Project full_name, isort",
      "display": "matkuki/ExCo",
      "asOf": "2026-11-18"
    },
    "F193": {
      "label": "Project stargazers_count, isort",
      "display": "163",
      "asOf": "2026-11-18"
    },
    "F194": {
      "label": "Library name, autopep8",
      "display": "autopep8",
      "asOf": "2026-11-18"
    },
    "F195": {
      "label": "Monthly downloads, autopep8",
      "display": "8.2M",
      "asOf": "2026-11-18"
    },
    "F196": {
      "label": "License, autopep8",
      "display": "MIT License",
      "asOf": "2026-11-18"
    },
    "F197": {
      "label": "Package release, autopep8",
      "display": "2.3.2",
      "asOf": "2026-11-18"
    },
    "F198": {
      "label": "Package release date, autopep8",
      "display": "Jan 2025",
      "asOf": "2026-11-18"
    },
    "F199": {
      "label": "Install, autopep8",
      "display": "pip install --upgrade autopep8",
      "asOf": "2026-11-18"
    },
    "F200": {
      "label": "Quickstart, autopep8",
      "display": "import autopep8\nautopep8.fix_code('x= 123\\n')\n",
      "asOf": "2026-11-18"
    },
    "F201": {
      "label": "Repository stars, autopep8",
      "display": "4.7K",
      "asOf": "2026-11-18"
    },
    "F202": {
      "label": "Python formatting API, autopep8",
      "display": "Yes",
      "asOf": "2026-11-18"
    },
    "F203": {
      "label": "Line-range formatting, autopep8",
      "display": "Yes",
      "asOf": "2026-11-18"
    },
    "F204": {
      "label": "Project function, autopep8",
      "display": "def autopep8_fix_code_cell(source, options=None, apply_config=None):\n    \"\"\"\n    Applies autopep8.fix_code and takes care of newline characters.\n\n    autopep8.fix_code automatically adds a final newline at the end,\n    e.g. ``autopep8.fix_code('a=1')`` yields 'a = 1\\\\n'.\n    Note that this is not related to the 'W292' flag, i.e.\n    ``autopep8.fix_code('a=1', options=dict(ignore=('W292',)))`` gives\n    the same result.\n    For notebook code cells, this behaviour does not make sense, hence\n    newline is removed if ``source`` does not end with one.\n    \"\"\"\n    source_corrected = autopep8.fix_code(source,\n                                         apply_config=apply_config,\n                                         options=options)\n\n    if not source.endswith('\\n'):\n        return source_corrected[:-1]\n\n    return source_corrected\n",
      "asOf": "2026-11-18"
    },
    "F205": {
      "label": "Project source file, autopep8",
      "display": "bears/python/PEP8NotebookBear.py",
      "asOf": "2026-11-18"
    },
    "F206": {
      "label": "Project full_name, autopep8",
      "display": "coala/coala-bears",
      "asOf": "2026-11-18"
    },
    "F207": {
      "label": "Project stargazers_count, autopep8",
      "display": "297",
      "asOf": "2026-11-18"
    },
    "F208": {
      "label": "Library name, yapf",
      "display": "YAPF",
      "asOf": "2026-11-18"
    },
    "F209": {
      "label": "Monthly downloads, yapf",
      "display": "5.7M",
      "asOf": "2026-11-18"
    },
    "F210": {
      "label": "License, yapf",
      "display": "Apache Software License",
      "asOf": "2026-11-18"
    },
    "F211": {
      "label": "Package release, yapf",
      "display": "0.43.0",
      "asOf": "2026-11-18"
    },
    "F212": {
      "label": "Package release date, yapf",
      "display": "Nov 2024",
      "asOf": "2026-11-18"
    },
    "F213": {
      "label": "Install, yapf",
      "display": "pip install yapf",
      "asOf": "2026-11-18"
    },
    "F214": {
      "label": "Quickstart, yapf",
      "display": "from yapf.yapflib.yapf_api import FormatCode  # reformat a string of code\nformatted_code, changed = FormatCode(\"f ( a = 1, b = 2 )\")\n",
      "asOf": "2026-11-18"
    },
    "F215": {
      "label": "Repository stars, yapf",
      "display": "14.0K",
      "asOf": "2026-11-18"
    },
    "F216": {
      "label": "Python formatting API, yapf",
      "display": "Yes",
      "asOf": "2026-11-18"
    },
    "F217": {
      "label": "Line-range formatting, yapf",
      "display": "Yes",
      "asOf": "2026-11-18"
    },
    "F218": {
      "label": "Project function, yapf",
      "display": "def get_style_config(document_path, options=None):\n    # Exclude file if it follows the patterns for that\n    exclude_patterns_from_ignore_file = file_resources.GetExcludePatternsForDir(\n        os.getcwd()\n    )\n    if file_resources.IsIgnored(document_path, exclude_patterns_from_ignore_file):\n        return []\n\n    # Get the default styles as a string\n    # for a preset configuration, i.e. \"pep8\"\n    style_config = file_resources.GetDefaultStyleForDir(os.path.dirname(document_path))\n    if options is None:\n        return style_config\n\n    # We have options passed from LSP format request\n    # let's pass them to the formatter.\n    # First we want to get a dictionary of the preset style\n    # to pass instead of a string so that we can modify it\n    style_config = style.CreateStyleFromConfig(style_config)\n\n    use_tabs = style_config[\"USE_TABS\"]\n    indent_width = style_config[\"INDENT_WIDTH\"]\n\n    if options.get(\"tabSize\") is not None:\n        indent_width = max(int(options.get(\"tabSize\")), 1)\n\n    if options.get(\"insertSpaces\") is not None:\n        # TODO is it guaranteed to be a boolean, or can it be a string?\n        use_tabs = not options.get(\"insertSpaces\")\n\n        if use_tabs:\n            # Indent width doesn't make sense when using tabs\n            # the specifications state: \"Size of a tab in spaces\"\n            indent_width = 1\n\n    style_config[\"USE_TABS\"] = use_tabs\n    style_config[\"INDENT_WIDTH\"] = indent_width\n    style_config[\"CONTINUATION_INDENT_WIDTH\"] = indent_width\n\n    for style_option, value in options.items():\n        # Apply arbitrary options passed as formatter options\n        if style_option not in style_config:\n            # ignore if it's not a known yapf config\n            continue\n\n        style_config[style_option] = value\n\n    return style_config\n",
      "asOf": "2026-11-18"
    },
    "F219": {
      "label": "Project source file, yapf",
      "display": "pylsp/plugins/yapf_format.py",
      "asOf": "2026-11-18"
    },
    "F220": {
      "label": "Project full_name, yapf",
      "display": "python-lsp/python-lsp-server",
      "asOf": "2026-11-18"
    },
    "F221": {
      "label": "Project stargazers_count, yapf",
      "display": "2.6K",
      "asOf": "2026-11-18"
    }
  },
  "dataCheckedAt": "2026-11-18",
  "agent": {
    "exaCall": {
      "endpoint": "/search",
      "body": {
        "query": "Best Python code formatters Black autopep8 YAPF Ruff isort code examples",
        "numResults": 5
      },
      "docsUrl": "https://exa.ai/docs/reference/search"
    },
    "calls": []
  }
}
