From 33d8cd26f977f082f406f787a81f148b9b4e735f Mon Sep 17 00:00:00 2001 From: Xuan Hu Date: Thu, 5 Jan 2023 13:16:40 +0800 Subject: [PATCH 1/3] Config toml-sort in pyproject.toml with trailing comma. --- Makefile | 2 +- Makefile.jinja | 2 +- pyproject.toml | 23 ++++++++++++++--------- pyproject.toml.jinja | 23 ++++++++++++++--------- 4 files changed, 30 insertions(+), 20 deletions(-) diff --git a/Makefile b/Makefile index b70c8182..cf84a777 100644 --- a/Makefile +++ b/Makefile @@ -57,7 +57,7 @@ ruff: ${PIPRUN} python -m ruff docs tests src toml-sort: - ${PIPRUN} toml-sort -a -i pyproject.toml + ${PIPRUN} toml-sort pyproject.toml tests: ${PIPRUN} python -m pytest . diff --git a/Makefile.jinja b/Makefile.jinja index 6295a002..a0b63a72 100644 --- a/Makefile.jinja +++ b/Makefile.jinja @@ -59,7 +59,7 @@ ruff: ${PIPRUN} python -m ruff docs tests src toml-sort: - ${PIPRUN} toml-sort -a -i pyproject.toml + ${PIPRUN} toml-sort pyproject.toml tests: ${PIPRUN} python -m pytest . diff --git a/pyproject.toml b/pyproject.toml index 350def3a..3fd4a359 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,12 +2,12 @@ build-backend = "setuptools.build_meta" requires = [ "setuptools", - "setuptools-scm" + "setuptools-scm", ] [project] authors = [ - {email = "i@huxuan.org", name = "huxuan"} + {email = "i@huxuan.org", name = "huxuan"}, ] classifiers = [ "Development Status :: 4 - Beta", @@ -16,19 +16,19 @@ classifiers = [ "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9" + "Programming Language :: Python :: 3.9", ] description = "A serious Python project template for out-of-box and production usage." dynamic = [ "dependencies", "optional-dependencies", - "version" + "version", ] keywords = [ "out-of-box", "production", "project template", - "template" + "template", ] name = "serious-scaffold" readme = "README.md" @@ -46,7 +46,7 @@ fail_under = 100 [tool.coverage.run] omit = [ - "src/{{ module_name }}/*" + "src/{{ module_name }}/*", ] [tool.mypy] @@ -54,10 +54,10 @@ check_untyped_defs = true disallow_any_unimported = true disallow_untyped_defs = true enable_error_code = [ - "ignore-without-code" + "ignore-without-code", ] exclude = [ - "src/{{ module_name }}" + "src/{{ module_name }}", ] no_implicit_optional = true show_error_codes = true @@ -84,7 +84,7 @@ extend-ignore = [ "D407", "D408", "D409", - "D413" + "D413", ] fix = true per-file-ignores = {"tests/*" = ["S101"]} @@ -102,3 +102,8 @@ package = {file = ["requirements/package.txt"]} tests = {file = ["requirements/tests.txt"]} [tool.setuptools_scm] + +[tool.tomlsort] +all = true +in_place = true +trailing_comma_inline_array = true diff --git a/pyproject.toml.jinja b/pyproject.toml.jinja index eb183866..22af927f 100644 --- a/pyproject.toml.jinja +++ b/pyproject.toml.jinja @@ -2,12 +2,12 @@ build-backend = "setuptools.build_meta" requires = [ "setuptools", - "setuptools-scm" + "setuptools-scm", ] [project] authors = [ - {email = "{{ author_email }}", name = "{{ author_name }}"} + {email = "{{ author_email }}", name = "{{ author_name }}"}, ] classifiers = [ "Development Status :: 4 - Beta", @@ -16,19 +16,19 @@ classifiers = [ "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9" + "Programming Language :: Python :: 3.9", ] description = "{{ project_description }}" dynamic = [ "dependencies", "optional-dependencies", - "version" + "version", ] keywords = [ "out-of-box", "production", "project template", - "template" + "template", ] name = "{{ package_name }}" readme = "README.md" @@ -47,7 +47,7 @@ fail_under = 100 [tool.coverage.run] omit = [ {%- if project_name == "Serious Scaffold Python" %} - "src/{{ '{{ module_name }}' }}/*" + "src/{{ '{{ module_name }}' }}/*", {%- endif %} ] @@ -56,11 +56,11 @@ check_untyped_defs = true disallow_any_unimported = true disallow_untyped_defs = true enable_error_code = [ - "ignore-without-code" + "ignore-without-code", ] exclude = [ {%- if project_name == "Serious Scaffold Python" %} - "src/{{ '{{ module_name }}' }}" + "src/{{ '{{ module_name }}' }}", {%- endif %} ] no_implicit_optional = true @@ -88,7 +88,7 @@ extend-ignore = [ "D407", "D408", "D409", - "D413" + "D413", ] fix = true per-file-ignores = {"tests/*" = ["S101"]} @@ -106,3 +106,8 @@ package = {file = ["requirements/package.txt"]} tests = {file = ["requirements/tests.txt"]} [tool.setuptools_scm] + +[tool.tomlsort] +all = true +in_place = true +trailing_comma_inline_array = true From eee9dd759af13b662acec80c4a710ab8443beb3e Mon Sep 17 00:00:00 2001 From: Xuan Hu Date: Thu, 5 Jan 2023 15:03:21 +0800 Subject: [PATCH 2/3] Add check for toml-sort in pre-commit. --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index aa44d560..407161a6 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -62,7 +62,7 @@ repos: name: ruff types: - python - - entry: pipenv run toml-sort -a -i + - entry: pipenv run toml-sort --check id: toml-sort language: system name: toml-sort From 943f4b40eb52b3aaf951ed142c5850a7dd5e156d Mon Sep 17 00:00:00 2001 From: Xuan Hu Date: Thu, 5 Jan 2023 15:03:46 +0800 Subject: [PATCH 3/3] Unify isort config. --- .pre-commit-config.yaml | 4 +--- pyproject.toml | 4 ++++ pyproject.toml.jinja | 4 ++++ 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 407161a6..6942430e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -37,9 +37,7 @@ repos: name: black types: - python - - args: - - '--filter-files' - entry: pipenv run python -m isort + - entry: pipenv run python -m isort id: isort language: system name: isort diff --git a/pyproject.toml b/pyproject.toml index 3fd4a359..57d66dd4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -49,6 +49,10 @@ omit = [ "src/{{ module_name }}/*", ] +[tool.isort] +filter_files = true +profile = "black" + [tool.mypy] check_untyped_defs = true disallow_any_unimported = true diff --git a/pyproject.toml.jinja b/pyproject.toml.jinja index 22af927f..fc34aee4 100644 --- a/pyproject.toml.jinja +++ b/pyproject.toml.jinja @@ -51,6 +51,10 @@ omit = [ {%- endif %} ] +[tool.isort] +filter_files = true +profile = "black" + [tool.mypy] check_untyped_defs = true disallow_any_unimported = true