{"id":13478473,"url":"https://github.com/google/pyink","last_synced_at":"2025-03-27T07:31:12.031Z","repository":{"id":65762296,"uuid":"553756432","full_name":"google/pyink","owner":"google","description":"Pyink, pronounced pī-ˈiŋk, is a Python formatter, forked from Black with a few different formatting behaviors.","archived":false,"fork":true,"pushed_at":"2025-02-26T11:14:25.000Z","size":6468,"stargazers_count":248,"open_issues_count":0,"forks_count":13,"subscribers_count":5,"default_branch":"pyink","last_synced_at":"2025-03-22T00:42:29.572Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"psf/black","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/google.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2022-10-18T18:07:38.000Z","updated_at":"2025-03-21T15:38:28.000Z","dependencies_parsed_at":"2023-10-17T03:14:37.969Z","dependency_job_id":null,"html_url":"https://github.com/google/pyink","commit_stats":{"total_commits":30,"total_committers":2,"mean_commits":15.0,"dds":"0.033333333333333326","last_synced_commit":"4b5d62b1aae96f68c00a256e66fdd485deecee08"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/google%2Fpyink","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/google%2Fpyink/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/google%2Fpyink/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/google%2Fpyink/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/google","download_url":"https://codeload.github.com/google/pyink/tar.gz/refs/heads/pyink","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245802438,"owners_count":20674666,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T16:01:57.551Z","updated_at":"2025-03-27T07:31:10.632Z","avatar_url":"https://github.com/google.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"*Pyink*, pronounced pī-ˈiŋk, is a Python formatter, forked from\n*[Black](https://github.com/psf/black)* with a few different formatting\nbehaviors. We intend to keep rebasing on top of *Black*'s latest changes.\n\n# Why *Pyink*?\n\nWe would love to adopt *Black*, but adopting it overnight is too disruptive to\nthe thousands of developers working in our monorepo. We also have other Python\ntooling that assumes certain formatting, it would be a too big task to update\nthem all at once. We decided to maintain a few local patches to *Black* as a\nmedium-term solution, and release them as a separate tool called *Pyink*.\n\n*Pyink* is intended to be an adoption helper, and we wish to remove as many\npatches as possible in the future.\n\n# What are the main differences?\n\n*   Support two-space indentation, using the `pyink-indentation` option.\n\n*   Support inferring preferred quote style by calculating the majority in a\n    file, using the `pyink-use-majority-quotes` option.\n\n*   Do not wrap trailing pragma comments if the line exceeds the length only\n    because of the pragma (see\n    [psf/black#2843](https://github.com/psf/black/issues/2843)). Example\n\n    ```python\n    # Pyink:\n    result = some_other_module._private_function(arg=\"value\")  # pylint: disable=protected-access\n\n    # Black:\n    result = some_other_module._private_function(\n        arg=\"value\"\n    )  # pylint: disable=protected-access\n    ```\n\n*   Do not wrap imports in parentheses and move them to separate lines (see\n    [psf/black#3324](https://github.com/psf/black/issues/3324)). Example:\n\n    ```python\n    # Pyink:\n    from very_long_top_level_package_name.sub_package.another_level import a_long_module\n\n    # Black:\n    from very_long_top_level_package_name.sub_package.another_level import (\n        a_long_module,\n    )\n    ```\n\n*   Add an empty line between class statements without docstrings, and the first\n    method. We expect we will simply remove this difference from *Pyink* at some\n    point. Example:\n\n    ```python\n    # Pyink:\n    class MyTest(unittest.TestCase):\n\n        def test_magic(self):\n            ...\n\n    # Black:\n    class MyTest(unittest.TestCase):\n        def test_magic(self):\n            ...\n    ```\n\n*   Module docstrings are formatted same as other docstrings (see\n    [psf/black#3493](https://github.com/psf/black/issues/3493)).\n\n*   Existing parentheses around strings are kept if the content does not fit on\n    a single line. This is related to https://github.com/psf/black/pull/3640\n    where we still want to keep the parentheses around the implicitly\n    concatenated strings if the code already uses them, making it more obvious\n    it's a single function argument. Example:\n\n    ```python\n    # Original code:\n    func1(\n        (\n            \" lorem ipsum dolor sit amet consectetur adipiscing elit sed do eiusmod tempor\"\n            \" incididunt ut labore et dolore magna aliqua Ut enim ad minim\"\n        ),\n        \" lorem ipsum dolor sit amet consectetur adipiscing elit sed do eiusmod tempor\",\n    )\n\n    func2(\n        \" lorem ipsum dolor sit amet consectetur adipiscing elit sed do eiusmod tempor\"\n        \" incididunt ut labore et dolore magna aliqua Ut enim ad minim\",\n        \" lorem ipsum dolor sit amet consectetur adipiscing elit sed do eiusmod tempor\",\n    )\n\n    # Pyink:\n    func1(\n        (\n            \" lorem ipsum dolor sit amet consectetur adipiscing elit sed do eiusmod tempor\"\n            \" incididunt ut labore et dolore magna aliqua Ut enim ad minim\"\n        ),\n        \" lorem ipsum dolor sit amet consectetur adipiscing elit sed do eiusmod tempor\",\n    )\n\n    func2(\n        \" lorem ipsum dolor sit amet consectetur adipiscing elit sed do eiusmod tempor\"\n        \" incididunt ut labore et dolore magna aliqua Ut enim ad minim\",\n        \" lorem ipsum dolor sit amet consectetur adipiscing elit sed do eiusmod tempor\",\n    )\n\n    # Black:\n    func1(\n        \" lorem ipsum dolor sit amet consectetur adipiscing elit sed do eiusmod tempor\"\n        \" incididunt ut labore et dolore magna aliqua Ut enim ad minim\",\n        \" lorem ipsum dolor sit amet consectetur adipiscing elit sed do eiusmod tempor\",\n    )\n\n    func2(\n        \" lorem ipsum dolor sit amet consectetur adipiscing elit sed do eiusmod tempor\"\n        \" incididunt ut labore et dolore magna aliqua Ut enim ad minim\",\n        \" lorem ipsum dolor sit amet consectetur adipiscing elit sed do eiusmod tempor\",\n    )\n    ```\n\n*   Temporarily disabled the following _Black_ future style changes:\n\n    *   https://github.com/psf/black/pull/2916\n    *   https://github.com/psf/black/pull/2278\n    *   https://github.com/psf/black/pull/4146\n\n## Historical differences\n\nThese are differences that existed in the past. We have upstreamed them to\n*Black* so they are now identical.\n\n*   Wrap concatenated strings in parens for function arguments (see\n    [psf/black#3292](https://github.com/psf/black/issues/3292)). Example:\n\n    ```python\n    # New:\n    function_call(\n        (\n            \" lorem ipsum dolor sit amet consectetur adipiscing elit sed do eiusmod tempor\"\n            \" incididunt ut labore et dolore magna aliqua Ut enim ad minim\"\n        ),\n        \" veniam quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo\",\n    )\n\n    # Old:\n    function_call(\n        \" lorem ipsum dolor sit amet consectetur adipiscing elit sed do eiusmod tempor\"\n        \" incididunt ut labore et dolore magna aliqua Ut enim ad minim\",\n        \" veniam quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo\",\n    )\n    ```\n\n*   Prefer splitting right hand side of assignment statements\n    (see [psf/black#1498](https://github.com/psf/black/issues/1498)). Example:\n\n    ```python\n    # New:\n    some_dictionary[\"some_key\"] = (\n        some_long_expression_causing_long_line\n    )\n\n    # Old:\n    some_dictionary[\n        \"some_key\"\n    ] = some_long_expression_causing_long_line\n    ```\n\n*   Prefer not breaking lines between immediately nested brackets (see\n    [psf/black#1811](https://github.com/psf/black/issues/1811)). Example:\n\n    ```python\n    # Pyink:\n    secrets = frozenset({\n        1001,\n        1002,\n        1003,\n        1004,\n        1005,\n        1006,\n        1007,\n        1008,\n        1009,\n    })\n\n    # Black:\n    secrets = frozenset(\n        {\n            1001,\n            1002,\n            1003,\n            1004,\n            1005,\n            1006,\n            1007,\n            1008,\n            1009,\n        }\n    )\n    ```\n\n*   Support only formatting selected line ranges, using the `--pyink-lines=`\n    argument (see [psf/black#830](https://github.com/psf/black/issues/830)).\n\n# How do I use *Pyink*?\n\nSame as `black`, except you'll use `pyink`. All `black` command line options are\nsupported by `pyink`. To configure the options in the `pyproject.toml` file, you\nneed to put them in the `[tool.pyink]` section instead of `[tool.black]`.\n\nThere are also a few *Pyink* only options:\n\n```\n  --pyink / --no-pyink            Enable the Pyink formatting mode. Disabling\n                                  it should behave the same as Black.\n                                  [default: pyink]\n  --pyink-indentation [2|4]       The number of spaces used for indentation.\n                                  [default: 4]\n  --pyink-use-majority-quotes     When normalizing string quotes, infer\n                                  preferred quote style by calculating the\n                                  majority in the file. Multi-line strings and\n                                  docstrings are excluded from this as they\n                                  always use double quotes.\n```\n\n## Is there a VS Code extension for *Pyink*?\n\nNo, but with a bit workaround, you can use the\n[Black Formatter](https://marketplace.visualstudio.com/items?itemName=ms-python.black-formatter)\nextension. After installing *Pyink* and the extension, you can set these in VS\nCode's `settings.json`:\n\n```json\n{\n    \"[python]\": {\n        \"editor.defaultFormatter\": \"ms-python.black-formatter\"\n    },\n    \"black-formatter.path\": [\n        \"path/to/pyink\"\n    ]\n}\n```\n\n## Can I use *Pyink* with the [pre-commit](https://pre-commit.com/) framework?\n\nYes! You can put the following in your `.pre-commit-config.yaml` file:\n\n```yaml\nrepos:\n  - repo: https://github.com/google/pyink\n    rev: 23.3.0\n    hooks:\n      - id: pyink\n        # It is recommended to specify the latest version of Python\n        # supported by your project here, or alternatively use\n        # pre-commit's default_language_version, see\n        # https://pre-commit.com/#top_level-default_language_version\n        language_version: python3.9\n```\n\n# Why the name?\n\nWe want a name with the same number of characters as *Black*, to make patching\neasier. And squid ink is black.\n\n# License\n\n[MIT](./LICENSE)\n\n# Contributing\n\nSee the [contribution guide](./CONTRIBUTING.md).\n\n# Changelog\n\nSee [CHANGES.md](./CHANGES.md).\n\n# Disclaimer\n\nThis is not an officially supported Google product.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgoogle%2Fpyink","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgoogle%2Fpyink","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgoogle%2Fpyink/lists"}