{"id":20269595,"url":"https://github.com/omnilib/ufmt","last_synced_at":"2025-04-08T08:11:11.508Z","repository":{"id":37287039,"uuid":"320470707","full_name":"omnilib/ufmt","owner":"omnilib","description":"Safe, atomic formatting with black and µsort","archived":false,"fork":false,"pushed_at":"2025-03-01T04:17:19.000Z","size":373,"stargazers_count":103,"open_issues_count":10,"forks_count":12,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-04-01T07:51:18.108Z","etag":null,"topics":["black","formatter","formatting","hacktoberfest","python","usort"],"latest_commit_sha":null,"homepage":"https://ufmt.omnilib.dev","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/omnilib.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.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,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-12-11T04:53:08.000Z","updated_at":"2025-03-15T04:56:22.000Z","dependencies_parsed_at":"2024-05-01T05:30:31.868Z","dependency_job_id":"a8c45cb5-357d-47fc-b0fe-09dc0e4f9670","html_url":"https://github.com/omnilib/ufmt","commit_stats":{"total_commits":196,"total_committers":5,"mean_commits":39.2,"dds":0.3214285714285714,"last_synced_commit":"515e38955b13499a01b0423bb34f98eca5aaffc5"},"previous_names":[],"tags_count":30,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/omnilib%2Fufmt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/omnilib%2Fufmt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/omnilib%2Fufmt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/omnilib%2Fufmt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/omnilib","download_url":"https://codeload.github.com/omnilib/ufmt/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247801155,"owners_count":20998338,"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","hacktoberfest","python","usort"],"created_at":"2024-11-14T12:26:00.409Z","updated_at":"2025-04-08T08:11:11.484Z","avatar_url":"https://github.com/omnilib.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# µfmt\n\nSafe, atomic formatting with [black][] and [µsort][]\n\n[![version](https://img.shields.io/pypi/v/ufmt.svg)](https://pypi.org/project/ufmt)\n[![documentation](https://readthedocs.org/projects/ufmt/badge/?version=latest)](https://ufmt.omnilib.dev)\n[![changelog](https://img.shields.io/badge/change-log-lightgrey)](https://ufmt.omnilib.dev/en/latest/changelog.html)\n[![license](https://img.shields.io/pypi/l/ufmt.svg)](https://github.com/omnilib/ufmt/blob/master/LICENSE)\n[![vscode extension](https://img.shields.io/badge/vscode-extension-007ACC?logo=visualstudiocode)](https://marketplace.visualstudio.com/items?itemName=omnilib.ufmt)\n\nµfmt is a safe, atomic code formatter for Python built on top of [black][] and [µsort][]:\n\n\u003e Black makes code review faster by producing the smallest diffs possible. Blackened code looks the same regardless of the project you’re reading.\n\n\u003e μsort is a safe, minimal import sorter. Its primary goal is to make no “dangerous” changes to code, and to make no changes on code style.\n\nµfmt formats files in-memory, first with µsort and then with black, before writing any\nchanges back to disk. This enables a combined, atomic step in CI/CD workflows for\nchecking or formatting files, without any chance of conflict or intermediate changes\nbetween the import sorter and the code formatter.\n\n\nInstall\n-------\n\nµfmt requires Python 3.8 or newer. You can install it from PyPI:\n\n```shell-session\n$ pip install ufmt\n```\n\nIf you want to prevent unexpected formatting changes that can break your CI workflow,\nmake sure to pin your transitive dependencies–including black, µsort, and µfmt–to your\npreferred versions.\n\nIf you use `requirements.txt`, this might look like:\n\n```text\nblack==22.6.0\nufmt==2.0.0\nusort==1.0.4\n```\n\n\nUsage\n-----\n\nTo format one or more files or directories in place:\n\n```shell-session\n$ ufmt format \u003cpath\u003e [\u003cpath\u003e ...]\n```\n\nTo validate files are formatted correctly, like for CI workflows:\n\n```shell-session\n$ ufmt check \u003cpath\u003e [\u003cpath\u003e ...]\n```\n\nTo validate formatting and generate a diff of necessary changes:\n\n```shell-session\n$ ufmt diff \u003cpath\u003e [\u003cpath\u003e ...]\n```\n\n\nIntegrations\n------------\n\nSee the [user guide](https://ufmt.omnilib.dev/en/latest/guide.html#integrations)\nfor details on each integration.\n\n### GitHub Actions\n\nµfmt provides a GitHub Action that can be added to an existing workflow,\nor as a separate workflow or job, to enforce proper formatting in pull requests:\n\n```yaml\njobs:\n  ufmt:\n    runs-on: ubuntu-latest\n    steps:\n      - uses: omnilib/ufmt@action-v1\n        with:\n          path: \u003cPATH TO CHECK\u003e\n          requirements: requirements-fmt.txt\n          python-version: \"3.x\"\n```\n\n### pre-commit hook\n\nµfmt provides a [pre-commit][] hook. To format your diff before\nevery commit, add the following to your `.pre-commit-config.yaml` file:\n\n```yaml\n  - repo: https://github.com/omnilib/ufmt\n    rev: v2.0.0\n    hooks:\n      - id: ufmt\n        additional_dependencies: \n          - black == 22.6.0\n          - usort == 1.0.4\n```\n\n### Visual Studio Code\n\nµfmt has an official VS Code extension to use µfmt as a formatter for Python files.\nOnce installed, µfmt can be set as the default formatter with the following settings:\n\n```json\n\"[python]\": {\n  \"editor.defaultFormatter\": \"omnilib.ufmt\"\n}\n```\n\nµfmt can automatically format when saving with the following settings:\n\n```json\n\"[python]\": {\n  \"editor.defaultFormatter\": \"omnilib.ufmt\",\n  \"editor.formatOnSave\": true\n}\n```\n\nFor more details, or to install the extension, see the Visual Studio Marketplace page:\n\n[![VS Code extension marketplace](https://img.shields.io/badge/VSCode-ufmt-007ACC?style=for-the-badge\u0026logo=visualstudiocode)](https://marketplace.visualstudio.com/items?itemName=omnilib.ufmt)\n[![Install VS Code extension now](https://img.shields.io/badge/-Install%20Now-107C10?style=for-the-badge\u0026logo=visualstudiocode)](vscode:extension/omnilib.ufmt)\n\n\nLicense\n-------\n\nufmt is copyright [Amethyst Reese](https://noswap.com), and licensed under\nthe MIT license.  I am providing code in this repository to you under an open\nsource license.  This is my personal repository; the license you receive to\nmy code is from me and not from my employer. See the `LICENSE` file for details.\n\n\n[black]: https://black.readthedocs.io\n[µsort]: https://usort.readthedocs.io\n[pre-commit]: https://pre-commit.com\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fomnilib%2Fufmt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fomnilib%2Fufmt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fomnilib%2Fufmt/lists"}