Skip to content

Commit

Permalink
FIX: selectively exclude Python files from EditorConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
redeboer committed Sep 27, 2023
1 parent 409e121 commit 21cc670
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/repoma/check_dev_files/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def main(argv: Optional[Sequence[str]] = None) -> int:
executor(citation.main)
executor(commitlint.main)
executor(cspell.main)
executor(editorconfig.main)
executor(editorconfig.main, args.no_python)
if not args.allow_labels:
executor(github_labels.main)
executor(github_templates.main)
Expand Down
33 changes: 17 additions & 16 deletions src/repoma/check_dev_files/editorconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,27 @@
from repoma.utilities.precommit import update_single_hook_precommit_repo


def main() -> None:
def main(no_python: bool) -> None:
if CONFIG_PATH.editorconfig.exists():
_update_precommit_config()
_update_precommit_config(no_python)


def _update_precommit_config() -> None:
excludes = dedent(R"""
(?x)^(
.*\.py
)$
""").strip()
def _update_precommit_config(no_python: bool) -> None:
hook = CommentedMap(
id="editorconfig-checker",
name="editorconfig",
alias="ec",
)
if not no_python:
excludes = dedent(R"""
(?x)^(
.*\.py
)$
""").strip()
hook["exclude"] = FoldedScalarString(excludes)

expected_hook = CommentedMap(
repo="https://github.com/editorconfig-checker/editorconfig-checker.python",
hooks=[
CommentedMap(
id="editorconfig-checker",
name="editorconfig",
alias="ec",
exclude=FoldedScalarString(excludes),
)
],
hooks=[hook],
)
update_single_hook_precommit_repo(expected_hook)

0 comments on commit 21cc670

Please sign in to comment.