Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FEAT: add --no-cspell-update flag #204

Merged
merged 4 commits into from
Oct 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 0 additions & 20 deletions .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,37 +16,17 @@
],
"ignorePaths": [
"**/.cspell.json",
"*.bib",
"*.ico",
"*.root",
"*.rst_t",
"*.svg",
"*particle*.*ml",
".constraints/*.txt",
".editorconfig",
".gitignore",
".gitpod.*",
".mypy.ini",
".pre-commit-config.yaml",
".prettierignore",
".readthedocs.yml",
".vscode/*",
".vscode/.gitignore",
"CITATION.cff",
"codecov.yml",
"Dockerfile",
"docs/_templates/*",
"docs/adr/*/*",
"docs/conf.py",
"labels.toml",
"labels/*.toml",
"Makefile",
"Manifest.toml",
"Project.toml",
"pyproject.toml",
"pyrightconfig.json",
"pytest.ini",
"requirements*.txt",
"setup.cfg",
"setup.py",
"tox.ini",
Expand Down
1 change: 0 additions & 1 deletion src/repoma/.template/.cspell.json

This file was deleted.

119 changes: 119 additions & 0 deletions src/repoma/.template/.cspell.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
{
"version": "0.2",
"enableFiletypes": ["git-commit", "julia", "jupyter"],
"flagWords": [
"analyse",
"colour",
"comparision",
"favour",
"flavour",
"hte",
"optimise",
"paramater",
"parmater",
"transision",
"transisions"
],
"ignorePaths": [
"**/.cspell.json",
"*.bib",
"*.ico",
"*.root",
"*.rst_t",
"*.svg",
"*particle*.*ml",
".constraints/*.txt",
".editorconfig",
".gitignore",
".gitpod.*",
".mypy.ini",
".pre-commit-config.yaml",
".prettierignore",
".readthedocs.yml",
".vscode/*",
".vscode/.gitignore",
"CITATION.cff",
"codecov.yml",
"Dockerfile",
"docs/_templates/*",
"docs/adr/*/*",
"docs/conf.py",
"labels.toml",
"labels/*.toml",
"Makefile",
"Manifest.toml",
"Project.toml",
"pyproject.toml",
"pyrightconfig.json",
"pytest.ini",
"requirements*.txt",
"setup.cfg",
"setup.py",
"tox.ini",
"typings"
],
"language": "en-US",
"words": [
"Colaboratory",
"compwa",
"Deepnote",
"docstrings",
"graphviz",
"ipython",
"mkdir",
"mypy",
"pytest",
"PYTHONHASHSEED",
"repoma",
"toctree",
"Zenodo"
],
"ignoreWords": [
"MAINT",
"PyPI",
"argparse",
"autonumbering",
"autoupdate",
"bdist",
"celltoolbar",
"codecov",
"colab",
"commitlint",
"conda",
"fromdict",
"indentless",
"jsonschema",
"linkcheck",
"maxdepth",
"maxsplit",
"nargs",
"nbcell",
"nbformat",
"nbqa",
"nbstripout",
"noqa",
"noreply",
"orcid",
"pandoc",
"prebuilds",
"precommit",
"prereleased",
"prettierignore",
"prettierrc",
"pyright",
"pyupgrade",
"redeboer",
"repos",
"reqs",
"ruamel",
"scalarstring",
"sdist",
"setuptools",
"showcode",
"showtags",
"taplo",
"tomlkit",
"unittests",
"venv"
]
}
19 changes: 17 additions & 2 deletions src/repoma/check_dev_files/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def main(argv: Optional[Sequence[str]] = None) -> int:
executor = Executor()
executor(citation.main)
executor(commitlint.main)
executor(cspell.main)
executor(cspell.main, args.no_cspell_update)
executor(editorconfig.main, args.no_python)
if not args.allow_labels:
executor(github_labels.main)
Expand Down Expand Up @@ -128,11 +128,26 @@ def _create_argparse() -> ArgumentParser:
default=False,
help="Do not update author info in setup.cfg.",
)
parser.add_argument(
"--no-cspell-update",
action="store_true",
default=False,
help=(
"Do not enforce same cSpell configuration as other ComPWA repositories."
" This can be useful if you have a more advanced configuration, like using"
" different dictionaries for different file types."
),
)
parser.add_argument(
"--no-github-actions",
action="store_true",
default=False,
help="Skip check that concern config files for Python projects.",
help=(
"Do not add standard GitHub Actions workflows that are used across ComPWA"
" repositories. This can be useful if you already have your own CI"
" workflows that do the same as the workflows enforced by the"
" check-dev-files hook."
),
)
parser.add_argument(
"--no-python",
Expand Down
12 changes: 9 additions & 3 deletions src/repoma/check_dev_files/cspell.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import json
import os
from glob import glob
from pathlib import Path
from typing import Any, Iterable, List, Sequence, Union

Expand Down Expand Up @@ -38,7 +39,7 @@
__EXPECTED_CONFIG = json.load(__STREAM)


def main() -> None:
def main(no_cspell_update: bool) -> None:
rename_file("cspell.json", str(CONFIG_PATH.cspell))
executor = Executor()
executor(_update_cspell_repo_url)
Expand All @@ -48,7 +49,8 @@ def main() -> None:
executor(_remove_configuration)
else:
executor(_update_precommit_repo)
executor(_fix_config_content)
if not no_cspell_update:
executor(_update_config_content)
executor(_sort_config_entries)
executor(add_badge, __BADGE)
executor(vscode.add_extension_recommendation, __VSCODE_EXTENSION_NAME)
Expand Down Expand Up @@ -103,7 +105,7 @@ def _update_precommit_repo() -> None:
update_single_hook_precommit_repo(expected_hook)


def _fix_config_content() -> None:
def _update_config_content() -> None:
if not CONFIG_PATH.cspell.exists():
with open(CONFIG_PATH.cspell, "w") as stream:
stream.write("{}")
Expand Down Expand Up @@ -157,6 +159,10 @@ def __get_expected_content(config: dict, section: str, *, extend: bool = False)
if isinstance(expected_section_content, str):
return expected_section_content
if isinstance(expected_section_content, list):
if section == "ignorePaths":
expected_section_content = [
p for p in expected_section_content if glob(p, recursive=True)
]
if not extend:
return __sort_section(expected_section_content, section)
expected_section_content_set = set(expected_section_content)
Expand Down