{"id":17961217,"url":"https://github.com/erictleung/pyblack","last_synced_at":"2025-03-25T03:31:37.087Z","repository":{"id":167819256,"uuid":"643449522","full_name":"erictleung/pyblack","owner":"erictleung","description":"RStudio addin to style Python code blocks with black","archived":false,"fork":false,"pushed_at":"2024-06-17T14:15:53.000Z","size":253,"stargazers_count":8,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-19T08:39:52.887Z","etag":null,"topics":["black","formatting","python","rstudio","rstudio-addin"],"latest_commit_sha":null,"homepage":"","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/erictleung.png","metadata":{"files":{"readme":"README.Rmd","changelog":null,"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":"2023-05-21T07:38:53.000Z","updated_at":"2024-07-15T09:27:54.000Z","dependencies_parsed_at":null,"dependency_job_id":"3af6df61-fd10-4926-924d-8fcd3f02e159","html_url":"https://github.com/erictleung/pyblack","commit_stats":null,"previous_names":["erictleung/pyblack"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erictleung%2Fpyblack","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erictleung%2Fpyblack/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erictleung%2Fpyblack/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erictleung%2Fpyblack/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/erictleung","download_url":"https://codeload.github.com/erictleung/pyblack/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245394751,"owners_count":20608122,"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","formatting","python","rstudio","rstudio-addin"],"created_at":"2024-10-29T11:08:40.435Z","updated_at":"2025-03-25T03:31:37.081Z","avatar_url":"https://github.com/erictleung.png","language":"R","funding_links":[],"categories":[],"sub_categories":[],"readme":"---\noutput: github_document\n---\n\n\u003c!-- README.md is generated from README.Rmd. Please edit that file --\u003e\n\n```{r, include = FALSE}\nknitr::opts_chunk$set(\n  collapse = TRUE,\n  comment = \"#\u003e\",\n  fig.path = \"man/figures/README-\",\n  out.width = \"100%\"\n)\n```\n\n# pyblack\n\n\u003c!-- badges: start --\u003e\n[![R-CMD-check](https://github.com/erictleung/pyblack/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/erictleung/pyblack/actions/workflows/R-CMD-check.yaml)\n[![Project Type Toy Badge](https://img.shields.io/badge/project%20type-toy-blue)](https://project-types.github.io/#toy)\n\u003c!-- badges: end --\u003e\n\nRStudio addin to style Python code blocks with\n[black](https://github.com/psf/black).\n\n![Demo of the pyblack RStudio addin to help format Python code in RMarkdown](man/figures/pyblack.gif)\n\n## Installation\n\n```r\nremotes::install_github(\"erictleung/pyblack\")\n```\n\nYou must have black installed and accessible in your path for this addin to\nwork.\n\n```bash\npip install black\n```\n\n## Usage\n\nThis addin supports styling with black by:\n\n- highlighted selected code\n- entire active file in RStudio\n\n**For select code**, in your text editor, first highlight the relevant Python\ncode you wish to format. Then navigate in RStudio to Addins \u003e PYBLACK \u003e Style\nselection with black.\n\n**For formatting an entire active document**, in your text editor, have your\ncursor in an open document you want to format. Then navigate in RStudio to\nAddins \u003e PYBLACK \u003e Style active file with black.\n\nThere is a third option available to change indentation from 4 spaces to 2\nspaces. This does not require or use black to work.\n\n## Configuration\n\nIn your working directory, you can have a `pyproject.toml` file that `black`\nwill read.\n\nBelow is an example `pyproject.toml` file that changes the line-length from the\ndefault of 88 to 80.\n\n```\n[tool.black]\nline-length = 80\n```\n\nOther settings available to change can be found by running `black --help`.\n\nYou can read more about this\n[here](https://black.readthedocs.io/en/stable/usage_and_configuration/the_basics.html#configuration-format).\n\n\n## Conditionally apply formatting\n\nThere are two ways to tell black to apply formatting to a code block:\n\n1. Use `# fmt: off` before a block of code\n2. Use `black = FALSE` in chunk options\n\nFor example, black won't format the `custom_formatting` object, but will format\nthe `black_formatting` object.\n\n```python\n# fmt: off\ncustom_formatting = [\n    0,  1,  2,\n    3,  4,  5,\n    6,  7,  8,\n]\n# fmt: on\nblack_formatting = [\n    0,  1,  2,\n    3,  4,  5,\n    6,  7,  8,\n]\n```\n\nAnother way to avoid formatting an entire code block is to set `black = FALSE`\nin the code chunk.\n\n````{verbatim}\n```{python, black = FALSE}\n\n```\n````\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ferictleung%2Fpyblack","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ferictleung%2Fpyblack","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ferictleung%2Fpyblack/lists"}