diff --git a/.github/ISSUE_TEMPLATE/0_bug.yml b/.github/ISSUE_TEMPLATE/0_bug.yml index cfccd360..a53f6fba 100644 --- a/.github/ISSUE_TEMPLATE/0_bug.yml +++ b/.github/ISSUE_TEMPLATE/0_bug.yml @@ -1,4 +1,3 @@ ---- name: Bug Report description: Create a bug report. labels: diff --git a/.github/ISSUE_TEMPLATE/1_feature.yml b/.github/ISSUE_TEMPLATE/1_feature.yml index a1e73982..bc022b41 100644 --- a/.github/ISSUE_TEMPLATE/1_feature.yml +++ b/.github/ISSUE_TEMPLATE/1_feature.yml @@ -1,4 +1,3 @@ ---- name: Feature Request description: Create a feature request. labels: diff --git a/.github/ISSUE_TEMPLATE/2_documentation.yml b/.github/ISSUE_TEMPLATE/2_documentation.yml index 68ae890d..f3ce0408 100644 --- a/.github/ISSUE_TEMPLATE/2_documentation.yml +++ b/.github/ISSUE_TEMPLATE/2_documentation.yml @@ -1,4 +1,3 @@ ---- name: Documentation description: Create a documentation related issue. labels: diff --git a/.github/ISSUE_TEMPLATE/epic.yml b/.github/ISSUE_TEMPLATE/epic.yml index eca723f4..9b3637f9 100644 --- a/.github/ISSUE_TEMPLATE/epic.yml +++ b/.github/ISSUE_TEMPLATE/epic.yml @@ -1,4 +1,3 @@ ---- name: Epic description: A collection of related tickets. labels: diff --git a/.github/dependabot.yml b/.github/dependabot.yml index fd367424..527ce8e0 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,4 +1,3 @@ ---- version: 2 updates: - package-ecosystem: github-actions diff --git a/.github/global.yml b/.github/global.yml index 4a336c90..43819da1 100644 --- a/.github/global.yml +++ b/.github/global.yml @@ -1,4 +1,3 @@ ---- # General - name: mitigated description: a workaround has been identified @@ -37,7 +36,7 @@ color: '#ededed' - name: locked description: '[bot] locked due to inactivity' - color: '#85BDB1' + color: '#85bdb1' - name: dependencies description: '[bot] PRs that update a dependency file' color: '#0366d6' @@ -61,7 +60,7 @@ # Sync - name: sync::anaconda description: sync internally with Anaconda, Inc. ticket tracker - color: '#5B2B76' + color: '#5b2b76' # Duplicates - name: duplicate @@ -251,14 +250,14 @@ # Stale - name: stale description: '[bot] marked as stale due to inactivity' - color: '#E79676' + color: '#e79676' aliases: [stale-marked] - name: stale::recovered description: '[bot] recovered after being marked as stale' - color: '#40A6B3' + color: '#40a6b3' - name: stale::closed description: '[bot] closed after being marked as stale' - color: '#86A8D8' + color: '#86a8d8' # Hackathons - name: hack::HackIllinois2019 @@ -276,20 +275,20 @@ # Tags - name: tag::performance description: related to degraded performance - color: '#86C579' + color: '#86c579' - name: tag::encoding-error description: related to an encoding error - color: '#86C579' + color: '#86c579' - name: tag::api description: related to the public API - color: '#86C579' + color: '#86c579' - name: tag::reproducibility description: related to producing reproducible results - color: '#86C579' + color: '#86c579' aliases: [reproducibility] - name: tag::ux description: related to user experience - color: '#86C579' + color: '#86c579' # Documentation - name: documentation::tutorials diff --git a/.github/labels.yml b/.github/labels.yml index 9fe397b6..81aa0cd2 100644 --- a/.github/labels.yml +++ b/.github/labels.yml @@ -1,4 +1,3 @@ ---- - name: type::development color: '#fff2cc' description: related to developer environment setups diff --git a/.github/messages.yml b/.github/messages.yml index 28ecf6b8..d214c85b 100644 --- a/.github/messages.yml +++ b/.github/messages.yml @@ -1,4 +1,3 @@ ---- stale-issue: | Hi there, thank you for your contribution! diff --git a/.github/sync/config.yml b/.github/sync/config.yml index 46be6553..12c49cc4 100644 --- a/.github/sync/config.yml +++ b/.github/sync/config.yml @@ -1,4 +1,3 @@ ---- group: # all projects - repos: | diff --git a/.github/workflows/cla.yml b/.github/workflows/cla.yml index 0f793ef0..07c7f75b 100644 --- a/.github/workflows/cla.yml +++ b/.github/workflows/cla.yml @@ -1,4 +1,3 @@ ---- name: CLA on: diff --git a/.github/workflows/issues.yml b/.github/workflows/issues.yml index 8391b0ee..7a114d6d 100644 --- a/.github/workflows/issues.yml +++ b/.github/workflows/issues.yml @@ -1,4 +1,3 @@ ---- name: Automate Issues on: diff --git a/.github/workflows/labels.yml b/.github/workflows/labels.yml index 45cb754d..f13985fb 100644 --- a/.github/workflows/labels.yml +++ b/.github/workflows/labels.yml @@ -1,4 +1,3 @@ ---- name: Sync Labels on: diff --git a/.github/workflows/lock.yml b/.github/workflows/lock.yml index c4294bea..2204b62d 100644 --- a/.github/workflows/lock.yml +++ b/.github/workflows/lock.yml @@ -1,4 +1,3 @@ ---- name: Lock on: diff --git a/.github/workflows/project.yml b/.github/workflows/project.yml index e1d5d4de..7d06584c 100644 --- a/.github/workflows/project.yml +++ b/.github/workflows/project.yml @@ -1,4 +1,3 @@ ---- name: Add to Project on: diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml index cfc95287..bcda1fea 100644 --- a/.github/workflows/stale.yml +++ b/.github/workflows/stale.yml @@ -1,4 +1,3 @@ ---- name: Stale on: diff --git a/.github/workflows/sync.yml b/.github/workflows/sync.yml index 7e45c3d0..757ab535 100644 --- a/.github/workflows/sync.yml +++ b/.github/workflows/sync.yml @@ -1,4 +1,3 @@ ---- name: Sync on: diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0c55ab68..c7d06b0f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,4 +1,3 @@ ---- repos: - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.6.0 @@ -8,6 +7,7 @@ repos: - id: end-of-file-fixer - id: trailing-whitespace # ensure syntaxes are valid + - id: check-toml - id: check-yaml # catch git merge/rebase problems - id: check-merge-conflict @@ -20,12 +20,25 @@ repos: files: ^.clabot$ require_serial: true args: [--sort-keys=contributors] + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.3.7 + hooks: + # lint & attempt to correct failures (e.g. pyupgrade) + - id: ruff + args: [--fix] + # compatible replacement for black + - id: ruff-format + - repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks + rev: v2.13.0 + hooks: + - id: pretty-format-toml + args: [--autofix, --trailing-commas] - repo: https://github.com/jumanjihouse/pre-commit-hook-yamlfmt rev: 0.2.3 hooks: - id: yamlfmt # ruamel.yaml doesn't line wrap correctly (?) so set width to 1M to avoid issues - args: [--mapping, '2', --offset, '2', --sequence, '4', --width, '1000000'] + args: [--mapping=2, --offset=2, --sequence=4, --width=1000000, --implicit_start] - repo: https://github.com/python-jsonschema/check-jsonschema rev: 0.28.2 hooks: @@ -33,7 +46,7 @@ repos: - id: check-github-workflows - id: check-dependabot - repo: https://github.com/codespell-project/codespell - # see setup.cfg + # see pyproject.toml rev: v2.2.6 hooks: - id: codespell diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..827949c7 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,22 @@ +[tool.codespell] +# see https://github.com/codespell-project/codespell#using-a-config-file +ignore-words-list = "rever," +skip = '.git' + +[tool.ruff] +target-version = "py38" + +[tool.ruff.lint] +# see https://docs.astral.sh/ruff/rules/ +select = [ + "D", # pydocstyle + "E", # pycodestyle errors + "F", # pyflakes + "FA", # flake8-future-annotations + "I", # isort + "ISC", # flake8-implicit-str-concat + "T10", # flake8-debugger + "TCH", # flake8-type-checking + "UP", # pyupgrade + "W", # pycodestyle warnings +] diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 9c50726c..00000000 --- a/setup.cfg +++ /dev/null @@ -1,4 +0,0 @@ -[codespell] -# see https://github.com/codespell-project/codespell#using-a-config-file -ignore-words-list = rever, -skip = .git diff --git a/sort_json.py b/sort_json.py index dedb5a6d..d972547d 100755 --- a/sort_json.py +++ b/sort_json.py @@ -1,14 +1,26 @@ #!/usr/bin/env python3 -from argparse import ArgumentParser +"""Sort specified keys in JSON files.""" + +from __future__ import annotations + import json +import sys +from argparse import ArgumentParser from pathlib import Path -from typing import Optional, Sequence +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from typing import Sequence -def main(argv: Optional[Sequence[str]] = None) -> int: +def main(argv: Sequence[str] | None = None) -> int: + """Sort specified keys in JSON files.""" parser = ArgumentParser() parser.add_argument( - "--sort-keys", type=lambda v: v.split(","), default=[], help="Keys to sort" + "--sort-keys", + type=lambda keys: keys.split(","), + default=[], + help="Keys to sort", ) parser.add_argument("filenames", nargs="*", type=Path, help="Filenames to fix") args = parser.parse_args(argv) @@ -29,11 +41,9 @@ def object_pairs_hook(pairs): else: pretty = f"{json.dumps(content, indent=2)}\n" # include trailing newline path.write_text(pretty) - status = ( - status or original != pretty - ) # record whether modifications were made + status = status or original != pretty # record whether modified return status if __name__ == "__main__": - raise SystemExit(main()) + sys.exit(main())