{"id":13743338,"url":"https://github.com/asottile/add-trailing-comma","last_synced_at":"2025-10-05T12:55:37.357Z","repository":{"id":22574047,"uuid":"96721073","full_name":"asottile/add-trailing-comma","owner":"asottile","description":"A tool (and pre-commit hook) to automatically add trailing commas to calls and literals.","archived":false,"fork":false,"pushed_at":"2025-09-23T13:38:47.000Z","size":409,"stargazers_count":367,"open_issues_count":0,"forks_count":29,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-09-23T15:35:56.590Z","etag":null,"topics":["linter","pre-commit","python"],"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/asottile.png","metadata":{"files":{"readme":"README.md","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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":"asottile"}},"created_at":"2017-07-10T00:55:50.000Z","updated_at":"2025-09-23T13:38:49.000Z","dependencies_parsed_at":"2023-01-13T22:04:35.571Z","dependency_job_id":"f9cda38a-d973-4b67-ae17-55751c9e84a2","html_url":"https://github.com/asottile/add-trailing-comma","commit_stats":{"total_commits":297,"total_committers":11,"mean_commits":27.0,"dds":"0.44781144781144777","last_synced_commit":"19342db4147bf67fd017aaf5838c2d4cec5722d6"},"previous_names":[],"tags_count":42,"template":false,"template_full_name":null,"purl":"pkg:github/asottile/add-trailing-comma","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asottile%2Fadd-trailing-comma","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asottile%2Fadd-trailing-comma/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asottile%2Fadd-trailing-comma/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asottile%2Fadd-trailing-comma/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/asottile","download_url":"https://codeload.github.com/asottile/add-trailing-comma/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asottile%2Fadd-trailing-comma/sbom","scorecard":{"id":212715,"data":{"date":"2025-08-11","repo":{"name":"github.com/asottile/add-trailing-comma","commit":"35af5fa4a073df5c670f0934e27eb9d34784581a"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":4.4,"checks":[{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Code-Review","score":0,"reason":"Found 0/3 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Maintained","score":10,"reason":"13 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 10","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: third-party GitHubAction not pinned by hash: .github/workflows/main.yml:11: update your workflow using https://app.stepsecurity.io/secureworkflow/asottile/add-trailing-comma/main.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/main.yml:16: update your workflow using https://app.stepsecurity.io/secureworkflow/asottile/add-trailing-comma/main.yml/main?enable=pin","Info:   0 out of   2 third-party GitHubAction dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/main.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'main'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 29 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-17T01:03:02.197Z","repository_id":22574047,"created_at":"2025-08-17T01:03:02.198Z","updated_at":"2025-08-17T01:03:02.198Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278457468,"owners_count":25989956,"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","status":"online","status_checked_at":"2025-10-05T02:00:06.059Z","response_time":54,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["linter","pre-commit","python"],"created_at":"2024-08-03T05:00:44.857Z","updated_at":"2025-10-05T12:55:37.352Z","avatar_url":"https://github.com/asottile.png","language":"Python","readme":"[![build status](https://github.com/asottile/add-trailing-comma/actions/workflows/main.yml/badge.svg)](https://github.com/asottile/add-trailing-comma/actions/workflows/main.yml)\n[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/asottile/add-trailing-comma/main.svg)](https://results.pre-commit.ci/latest/github/asottile/add-trailing-comma/main)\n\nadd-trailing-comma\n==================\n\nA tool (and pre-commit hook) to automatically add trailing commas to calls and\nliterals.\n\n## Installation\n\n```bash\npip install add-trailing-comma\n```\n\n## As a pre-commit hook\n\nSee [pre-commit](https://github.com/pre-commit/pre-commit) for instructions\n\nSample `.pre-commit-config.yaml`:\n\n```yaml\n-   repo: https://github.com/asottile/add-trailing-comma\n    rev: v3.2.0\n    hooks:\n    -   id: add-trailing-comma\n```\n\n## multi-line method invocation style -- why?\n\n```python\n# Sample of *ideal* syntax\nfunction_call(\n    argument,\n    5 ** 5,\n    kwarg=foo,\n)\n```\n\n- the initial paren is at the end of the line\n- each argument is indented one level further than the function name\n- the last parameter (unless the call contains an unpacking\n  (`*args` / `**kwargs`)) has a trailing comma\n\nThis has the following benefits:\n\n- arbitrary indentation is avoided:\n\n    ```python\n    # I hear you like 15 space indents\n    # oh your function name changed? guess you get to reindent :)\n    very_long_call(arg,\n                   arg,\n                   arg)\n    ```\n- adding / removing a parameter preserves `git blame` and is a minimal diff:\n\n    ```diff\n     # with no trailing commas\n     x(\n    -    arg\n    +    arg,\n    +    arg2\n     )\n    ```\n\n    ```diff\n     # with trailing commas\n     x(\n         arg,\n    +    arg2,\n     )\n    ```\n\n\n## Implemented features\n\n### trailing commas for function calls\n\n```diff\n x(\n     arg,\n-    arg\n+    arg,\n )\n```\n\n### trailing commas for tuple / list / dict / set literals\n\n```diff\n x = [\n-    1, 2, 3\n+    1, 2, 3,\n ]\n```\n\n### trailing commas for function definitions\n\n```diff\n def func(\n         arg1,\n-        arg2\n+        arg2,\n ):\n```\n\n```diff\n async def func(\n         arg1,\n-        arg2\n+        arg2,\n ):\n```\n\n### trailing commas for `from` imports\n\n```diff\n from os import (\n     path,\n-    makedirs\n+    makedirs,\n )\n```\n\n### trailing comma for class definitions\n\n```diff\n class C(\n     Base1,\n-    Base2\n+    Base2,\n ):\n     pass\n```\n\n### trailing comma for with statement\n\n```diff\n with (\n         open('f1', 'r') as f1,\n-        open('f2', 'w') as f2\n+        open('f2', 'w') as f2,\n ):\n     pass\n```\n\n### trailing comma for match statement\n\n```diff\n match x:\n     case A(\n        1,\n-       2\n+       2,\n     ):\n        pass\n     case (\n        1,\n-       2\n+       2,\n     ):\n        pass\n     case [\n        1,\n-       2\n+       2,\n     ]:\n        pass\n     case {\n        'x': 1,\n-       'y': 2\n+       'y': 2,\n     }:\n        pass\n```\n\n\n### trailling comma for PEP-695 type aliases\n\n```diff\n def f[\n-    T\n+    T,\n ](x: T) -\u003e T:\n     return x\n```\n\n```diff\n class A[\n-    K\n+    K,\n ]:\n     def __init__(self, x: T) -\u003e None:\n         self.x = x\n```\n\n```diff\n type ListOrSet[\n-     T\n+     T,\n] = list[T] | set[T]\n```\n\n### unhug trailing paren\n\n```diff\n x(\n     arg1,\n-    arg2)\n+    arg2,\n+)\n```\n\n### unhug leading paren\n\n```diff\n-function_name(arg1,\n-              arg2)\n+function_name(\n+    arg1,\n+    arg2,\n+)\n```\n\n### match closing brace indentation\n\n```diff\n x = [\n     1,\n     2,\n     3,\n-    ]\n+]\n```\n\n### remove unnecessary commas\n\nyes yes, I realize the tool is called `add-trailing-comma` :laughing:\n\n```diff\n-[1, 2, 3,]\n-[1, 2, 3, ]\n+[1, 2, 3]\n+[1, 2, 3]\n```\n","funding_links":["https://github.com/sponsors/asottile"],"categories":["UNIX-way formatters","Python","Other","Code Refactoring"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fasottile%2Fadd-trailing-comma","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fasottile%2Fadd-trailing-comma","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fasottile%2Fadd-trailing-comma/lists"}