{"id":16994576,"url":"https://github.com/thep0y/python-black","last_synced_at":"2025-03-22T15:31:05.164Z","repository":{"id":42955660,"uuid":"373035182","full_name":"thep0y/python-black","owner":"thep0y","description":"Black formatter for  Sublime Text","archived":false,"fork":false,"pushed_at":"2023-12-02T06:46:24.000Z","size":3958,"stargazers_count":39,"open_issues_count":9,"forks_count":5,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-18T13:18:57.816Z","etag":null,"topics":["black","formatter","formatting","python","sublime-text"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thep0y.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-06-02T04:06:30.000Z","updated_at":"2025-01-19T17:05:06.000Z","dependencies_parsed_at":"2024-10-28T13:24:03.453Z","dependency_job_id":"0c765172-6eaa-4b9c-b132-7cac5728ef7f","html_url":"https://github.com/thep0y/python-black","commit_stats":null,"previous_names":[],"tags_count":42,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thep0y%2Fpython-black","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thep0y%2Fpython-black/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thep0y%2Fpython-black/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thep0y%2Fpython-black/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thep0y","download_url":"https://codeload.github.com/thep0y/python-black/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244978548,"owners_count":20541869,"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":["black","formatter","formatting","python","sublime-text"],"created_at":"2024-10-14T03:45:57.617Z","updated_at":"2025-03-22T15:31:04.638Z","avatar_url":"https://github.com/thep0y.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch2 align=\"center\"\u003epython-black\u003c/h2\u003e\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://github.com/psf/black\"\u003e\u003cimg alt=\"black\" src=\"https://img.shields.io/badge/code%20style-black-000000.svg\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n[Black](https://github.com/psf/black) formatter for Sublime Text.\n\nIt is recommended to use it with [LSP-pyright](https://github.com/sublimelsp/LSP-pyright).\n\n### Installation\n\n\u003e There is **no need** to install `black`. However, if you choose to install it, it will not affect this package..\n\nYou can install `python-black` with Package Control:\n\n1. Open your command pallete and type `Package Control: Install Package`.\n2. Find this project `python-black` and press `Enter`.\n\n#### ~~Local installation~~\n\n~~This package has been uploaded to packagecontrol.io, so you do not need to choose local installation:~~\n\n```shell\ngit clone https://github.com/thep0y/python-black.git\n```\n\n~~Copy or move the `python-black` folder to the `Packages` directory of **Sublime Text 4**.~~\n\n### Usage\n\n#### 1 Key Binding\n\nYou can create custom key binding based on sample`Preferences - Package Settings - Python Black - Key Bindings`, such as:\n\n```json\n{\n  \"keys\": [\"ctrl+super+l\"],\n  \"command\": \"black\",\n  \"args\": {\n    \"use_selection\": true\n  }\n}\n```\n\nThe optional `use_selection` boolean (defaults to `true`) controls whether to format the selected region or the entire file.\n\n\u003e :warning:Note: Do not **duplicate** the key binding of other packages.\n\n#### 2 Settings\n\nThere are some modifiable properties in settings:\n\n```js\n{\n   // Whether to automatically format the entire document when saving.\n   // There are three modes:\n   //    - \"on\"\n   //    - \"off\"\n   //    - \"smart\": Automatic formatting is only enabled if there is a `black` section in the project's `pyproject.toml`\n   \"format_on_save\": \"on\",\n   // Black [OPTIONS]\n   // The priority of loading options for Black is:\n   // Sublime project settings \u003e Configuration file \u003e Sublime package user settings \u003e Sublime package default settings\n   \"options\": {\n      // Python versions that should be supported by Black's output.\n      \"target_version\": [],\n      // How many characters per line to allow.\n      \"line_length\": 88,\n      // Format all input files like typing stubs regardless of file extension (useful when piping source on standard input).\n      \"is_pyi\": false,\n      // Skip the first line of the source code.\n      \"skip_source_first_line\": false,\n      // Don't normalize string quotes or prefixes.\n      \"skip_string_normalization\": false,\n      // Don't use trailing commas as a reason to split lines.\n      \"skip_magic_trailing_comma\": false\n   }\n}\n\n```\n\nThe `format_on_save` can also be toggled via `Preferences \u003e Package Settings \u003e Python Black \u003e Format On Save`.\n\nThe Black options can also be configured in sublime-project:\n\n```js\n{\n  \"settings\": {\n    // ...\n    \"python-black\": {\n      \"options\": {\n        \"line_length\": 127,\n        \"skip_string_normalization\": true\n      }\n    }\n  }\n}\n```\n\n#### 3 Create Black Configuration File\n\nYou can quickly generate a black configuration file for the current project.\n\n| Command                                         | Description                                                                                                                       |\n| ----------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- |\n| `python-black: Create Black Configuration File` | Creates a `pyproject.toml` file in the root of the project with basic options. Opens the configuration file if it already exists. |\n\n\u003e :warning: If you don't want to generate a `pyproject.toml` for _\u003cu\u003e**each project**\u003c/u\u003e_, you need to create a **global configuration file** for Black.\n\u003e\n\u003e Refer to [Black Documentation](https://black.readthedocs.io/en/stable/usage_and_configuration/the_basics.html#where-black-looks-for-the-file).\n\n\u003e If you want to disable `format_on_save` in a project that does not use `black` code style [#14](https://github.com/thep0y/python-black/issues/14), you need to add the configuration to `*.sublime-project`:\n\u003e\n\u003e ```js\n\u003e {\n\u003e \t...\n\u003e \t\"settings\": {\n\u003e \t\t...\n\u003e \t\t\"python-black\": {\n\u003e \t\t\t\"format_on_save\": \"off\"\n\u003e \t\t}\n\u003e \t}\n\u003e }\n\u003e ```\n\n### Development\n\nIf you want to fix bugs or add features, you can read the logs:\n\n- Colorful: in `python-black.log` in the `[SublimeText]/Log` directory.\n\n- Colorless: in the Sublime Text console.\n\nYou can also add logs where you think they should be logged as follows:\n\n```python\nfrom .log import child_logger\n\nlogger = child_logger(__name__)\n\n\n# ...\nlogger.debug(\"...\")\nlogger.info(\"...\")\nlogger.warning(\"...\")\nlogger.error(\"...\")\n# ...\n```\n\nDiscussion and creation of PRs are welcome.\n\n### TODO\n\n- [ ] format all python files in the current project\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthep0y%2Fpython-black","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthep0y%2Fpython-black","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthep0y%2Fpython-black/lists"}