{"id":13501475,"url":"https://github.com/dizballanze/gray","last_synced_at":"2025-03-17T16:13:17.121Z","repository":{"id":43221788,"uuid":"253291864","full_name":"dizballanze/gray","owner":"dizballanze","description":"Less uncompromising Python code formatter","archived":false,"fork":false,"pushed_at":"2024-04-28T09:15:00.000Z","size":101,"stargazers_count":75,"open_issues_count":5,"forks_count":8,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-10-13T09:17:45.882Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/dizballanze.png","metadata":{"files":{"readme":"README.md","changelog":"HISTORY.md","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":"AUTHORS.md","dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-04-05T17:26:27.000Z","updated_at":"2024-09-09T03:07:49.000Z","dependencies_parsed_at":"2024-06-21T05:45:41.613Z","dependency_job_id":"5aa5576d-2cf0-4c7e-ad3d-b8e02f13fa22","html_url":"https://github.com/dizballanze/gray","commit_stats":{"total_commits":73,"total_committers":8,"mean_commits":9.125,"dds":0.4657534246575342,"last_synced_commit":"ac4a9ef6b32ce92bccf912aa40811efc87ed42f8"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dizballanze%2Fgray","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dizballanze%2Fgray/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dizballanze%2Fgray/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dizballanze%2Fgray/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dizballanze","download_url":"https://codeload.github.com/dizballanze/gray/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244066189,"owners_count":20392406,"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-31T22:01:38.787Z","updated_at":"2025-03-17T16:13:17.101Z","avatar_url":"https://github.com/dizballanze.png","language":"Python","funding_links":[],"categories":["Python","Improvements and wrappers"],"sub_categories":[],"readme":"# gray\n\n[![Package Version](https://badge.fury.io/py/gray.svg)](http://badge.fury.io/py/gray)\n[![Build Status](https://travis-ci.org/dizballanze/gray.svg?branch=master)](https://travis-ci.org/dizballanze/gray)\n\nLess uncompromising Python code formatter.\n\nGray stands on the shoulders of giants:\n\n- [isort](https://timothycrosley.github.io/isort/) - imports sorting and more\n- [pyupgrade](https://github.com/asottile/pyupgrade) - automatically upgrades syntax for newer versions of Python\n- [autoflake](https://github.com/myint/autoflake) - remove unused imports and variables\n- [add-trailing-comma](https://github.com/asottile/add-trailing-comma)\n- [trim](https://github.com/myint/trim) - remove trailing whitespaces\n- [unify](https://github.com/myint/unify) - unify quotes style\n- [fixit](https://github.com/Instagram/Fixit) - various code formatters on LibCST\n- [black](https://github.com/psf/black) - optional - the uncompromising Python code formatter\n\n## Usage\n\n```\nusage:\n            gray myapp.py\n            gray myproj/ tests/\n            gray --log-level debug --formatters isort,unify ~/app\n\n\nLess uncompromising Python code formatter.\n\npositional arguments:\n  paths                 Paths to format (default: (PosixPath('.'),))\n\noptional arguments:\n  -h, --help            show this help message and exit\n  --exclude EXCLUDE     A regular expression matching files and directories that should be\n                        excluded from formatting. Passing an explicit empty value means not paths\n                        get excluded. Use '/' as directory separator, including on Windows.\n                        [default: (.*/)?(\\.direnv|\\.eggs|\\.git|\\.hg|\\.mypy_cache|\\.nox|\\.tox|\\.ven\n                        v|venv|\\.svn|_build|buck-out|build|dist|__pypackages__)$] (default: (.*/)?\n                        (\\.direnv|\\.eggs|\\.git|\\.hg|\\.mypy_cache|\\.nox|\\.tox|\\.venv|venv|\\.svn|_bu\n                        ild|buck-out|build|dist|__pypackages__)$)\n  --extend-exclude EXTEND_EXCLUDE\n                        An additional regular expression to use besides --exclude. This allows to\n                        keep the default regex from --exclude. (default: None)\n  --pool-size POOL_SIZE\n                        process pool size (default: 8)\n  --do-not-detect-venv  Don't try to detect virtualenv (default: False)\n\nLogging options:\n  --log-level {debug,info,warning,error,fatal}\n\nFormatters options:\n  -f FORMATTERS, --formatters FORMATTERS\n                        Enabled formatters separated by comma (optional: black) (default: add-\n                        trailing-comma,autoflake,fixit,isort,pyupgrade,trim,unify)\n  --min-python-version MIN_PYTHON_VERSION\n                        Minimum python version to support (default: (3, 9))\n\npyupgrade options:\n  --pyupgrade-keep-percent-format PYUPGRADE_KEEP_PERCENT_FORMAT\n                        Do not upgrade percent formatted strings to f-strings (default: False)\n  --pyupgrade-keep-mock PYUPGRADE_KEEP_MOCK\n                        Disable rewrite of mock imports (default: False)\n  --pyupgrade-keep-runtime-typing PYUPGRADE_KEEP_RUNTIME_TYPING\n                        Disable pep 585 typing rewrites (default: False)\n\nunify options:\n  --unify-quote UNIFY_QUOTE\n                        preferred quote (default: \")\n\nisort options:\n  --isort-profile ISORT_PROFILE\n                        Base profile type to use for configuration. (default: None)\n  --isort-line-length ISORT_LINE_LENGTH\n                        The max length of an import line (used for wrapping long imports)\n                        (default: 80)\n  --isort-wrap-length ISORT_WRAP_LENGTH\n                        Specifies how long lines that are wrapped should be, if not set\n                        line_length is used. NOTE: wrap_length must be LOWER than or equal to\n                        line_length (default: None)\n  --isort-multi-line-output ISORT_MULTI_LINE_OUTPUT\n                        Multi line output (0-grid, 1-vertical, 2-hanging, 3-vert-hanging, 4-vert-\n                        grid, 5-vert-grid-grouped, 6-deprecated-alias-for-5, 7-noqa, 8-vertical-\n                        hanging-indent-bracket, 9-vertical-prefix-from-module-import, 10-hanging-\n                        indent-with-parentheses). (default: 5)\n  --isort-known-third-party ISORT_KNOWN_THIRD_PARTY\n                        Force isort to recognize a module as being part of a third party library.\n                        (default: None)\n  --isort-known-first-party ISORT_KNOWN_FIRST_PARTY\n                        Force isort to recognize a module as being part of the current python\n                        project. (default: None)\n  --isort-known-local-folder ISORT_KNOWN_LOCAL_FOLDER\n                        Force isort to recognize a module as being a local folder. Generally, this\n                        is reserved for relative imports (from . import module). (default: None)\n  --isort-virtual-env ISORT_VIRTUAL_ENV\n                        virtual env path (default: env)\n  --isort-include-trailing-comma ISORT_INCLUDE_TRAILING_COMMA\n                        Includes a trailing comma on multi line imports that include parentheses.\n                        (default: True)\n  --isort-lines-after-imports ISORT_LINES_AFTER_IMPORTS\n                        empty lines after imports (default: 2)\n  --isort-skip-gitignore ISORT_SKIP_GITIGNORE\n                        Treat project as a git repository and ignore files listed in .gitignore.\n                        (default: True)\n  --isort-use-parentheses ISORT_USE_PARENTHESES\n                        Use parentheses for line continuation on length limit instead of slashes.\n                        **NOTE**: This is separate from wrap modes, and only affects how\n                        individual lines that are too long get continued, not sections of multiple\n                        imports.. (default: True)\n  --isort-length-sort ISORT_LENGTH_SORT\n                        Sort imports by their string length. (default: False)\n\nautoflake options:\n  --autoflake-ignore-init-module-imports AUTOFLAKE_IGNORE_INIT_MODULE_IMPORTS\n  --autoflake-expand-star-imports AUTOFLAKE_EXPAND_STAR_IMPORTS\n  --autoflake-remove-all-unused-imports AUTOFLAKE_REMOVE_ALL_UNUSED_IMPORTS\n  --autoflake-remove-duplicate-keys AUTOFLAKE_REMOVE_DUPLICATE_KEYS\n  --autoflake-remove-unused-variables AUTOFLAKE_REMOVE_UNUSED_VARIABLES\n\ntrim options:\n  --trim-leading-newlines TRIM_LEADING_NEWLINES\n\nfixit options:\n  --fixit-redundant-fstrings FIXIT_REDUNDANT_FSTRINGS\n  --fixit-redundant-lambdas FIXIT_REDUNDANT_LAMBDAS\n  --fixit-redundant-list-comprehensions FIXIT_REDUNDANT_LIST_COMPREHENSIONS\n  --fixit-to-comprehensions FIXIT_TO_COMPREHENSIONS\n  --fixit-to-literals FIXIT_TO_LITERALS\n  --fixit-to-fstrings FIXIT_TO_FSTRINGS\n\nblack options:\n  --black-line-length BLACK_LINE_LENGTH\n                        How many characters per line to allow. (default: 88)\n  --black-skip-magic-trailing-comma BLACK_SKIP_MAGIC_TRAILING_COMMA\n                        Don't use trailing commas as a reason to split lines. (default: False)\n  --black-skip-string-normalization BLACK_SKIP_STRING_NORMALIZATION\n                        Don't normalize string quotes or prefixes. (default: False)\n\nArgs that start with '--' (eg. --exclude) can also be set in a config file (/Users/stephane/.gray\nor /etc/gray.conf or ./gray.conf). Config file syntax allows: key=value, flag=true, stuff=[a,b,c]\n(for details, see syntax at https://goo.gl/R74nmi). If an arg is specified in more than one place,\nthen commandline values override config file values which override defaults.\n```\n\n\n## Git Hook\n\nYou can setup gray formatting before each commit with pre-commit git hook.\nAdd following file to `.git/hooks/pre-commit` and make it executable with\n`chmod +x .git/hooks/pre-commit`.\n\n```python\n#!/usr/bin/env python\nfrom gray.hooks import git_pre_commit\n\nexit(git_pre_commit(stop_on_modify=True))\n```\n\nIf `stop_on_modify` argument is `True`, hook will prevent commit if there are\nany unstaged changes in files you about to commit.\n\nOtherwise, any unstaged changes in this files will be added to the index\nby the hook.\n\n\n## Config file\n\nGray is looking for config file in `./gray.conf`, `/etc/gray.conf` or `~/.gray`.\n\nExample of grayconf:\n\n```\nformatters = add-trailing-comma,isort,unify\nmin-python-version = 3.5\n```\n\n## Features\n\n* TODO\n\n## Git pre-commit hook\n\nUse [pre-commit](https://pre-commit.com/). Once you\n[have it installed](https://pre-commit.com/#install), add this to the\n`.pre-commit-config.yaml` in your repository:\n\n```yaml\nrepos:\n  - repo: https://github.com/dizballanze/gray\n    rev: master # Replace by any tag/branch: https://github.com/dizballanze/gray/tags\n    hooks:\n      - id: gray\n```\n\nand run `pre-commit install`.\n\n## Using with Sourcetree\nSourcetree may run without `gray` being available via `PATH`.\n\n### MacOS\nMake sure `gray` is available via `PATH` and run `open /Applications/Sourcetree.app`.\nOr better [create](https://stackoverflow.com/a/281455/1555653) an `Automator` workflow \nwith `source ~/.bash_profile \u0026\u0026 open /Applications/Sourcetree.app` script.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdizballanze%2Fgray","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdizballanze%2Fgray","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdizballanze%2Fgray/lists"}