From 5722baee71c0cd020b94197209798cbd5e675f12 Mon Sep 17 00:00:00 2001 From: Althea Denlinger Date: Wed, 24 May 2023 12:15:32 -0600 Subject: [PATCH] Add Flynt to linter for updating format strings This will convert format strings to f strings when possible --- .pre-commit-config.yaml | 8 ++++++++ deploy/conda-dev-spec.template | 1 + docs/developers_guide/quick_start.md | 5 +++-- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 10f9429a6..7a8413fe5 100755 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -15,6 +15,14 @@ repos: hooks: - id: isort + # Can run individually with `flynt [file]` or `flynt [source]` + - repo: https://github.com/ikamensh/flynt + rev: '0.78' + hooks: + - id: flynt + args: ["--fail-on-change", "--verbose"] + require_serial: true + # Can run individually with `pre-commit run flake8 --all-files` # Need to use flake8 GitHub mirror due to CentOS git issue with GitLab # https://github.com/pre-commit/pre-commit/issues/1206 diff --git a/deploy/conda-dev-spec.template b/deploy/conda-dev-spec.template index a77327318..ff8dfa301 100644 --- a/deploy/conda-dev-spec.template +++ b/deploy/conda-dev-spec.template @@ -45,6 +45,7 @@ types-requests pip pytest isort +flynt flake8 mypy pre-commit diff --git a/docs/developers_guide/quick_start.md b/docs/developers_guide/quick_start.md index 939477e83..41fe9e613 100644 --- a/docs/developers_guide/quick_start.md +++ b/docs/developers_guide/quick_start.md @@ -527,8 +527,9 @@ a tools that helps to enforce this standard by checking your code each time you make a commit. It will tell you about various types of problems it finds. Internally, it uses [flake8](https://flake8.pycqa.org/en/latest/) to check PEP8 compliance, [isort](https://pycqa.github.io/isort/) to sort, check and format -imports, and [mypy](https://mypy-lang.org/) to check for consistent variable -types. An example error might be: +imports, [flynt](https://github.com/ikamensh/flynt) to change any format +strings to f-strings, and [mypy](https://mypy-lang.org/) to check for +consistent variable types. An example error might be: ```bash example.py:77:1: E302 expected 2 blank lines, found 1