Skip to content

Commit

Permalink
FIX: intelligently exclude Python files from editorconfig
Browse files Browse the repository at this point in the history
  • Loading branch information
redeboer committed Aug 7, 2024
1 parent d722bf7 commit 5b9eafd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/compwa_policy/check_dev_files/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def main(argv: Sequence[str] | None = None) -> int:
do(cspell.main, precommit_config, args.no_cspell_update)
do(dependabot.main, args.dependabot)
do(direnv.main)
do(editorconfig.main, precommit_config, args.no_python)
do(editorconfig.main, precommit_config)
if not args.allow_labels:
do(github_labels.main)
if not args.no_github_actions:
Expand Down
9 changes: 5 additions & 4 deletions src/compwa_policy/check_dev_files/editorconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,25 @@
from ruamel.yaml.scalarstring import FoldedScalarString

from compwa_policy.utilities import CONFIG_PATH
from compwa_policy.utilities.match import filter_files
from compwa_policy.utilities.precommit.struct import Hook, Repo

if TYPE_CHECKING:
from compwa_policy.utilities.precommit import ModifiablePrecommit


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


def _update_precommit_config(precommit: ModifiablePrecommit, no_python: bool) -> None:
def _update_precommit_config(precommit: ModifiablePrecommit) -> None:
hook = Hook(
id="editorconfig-checker",
name="editorconfig",
alias="ec",
)
if not no_python:
if filter_files(["**/*.py"]):
msg = R"""
(?x)^(
.*\.py
Expand Down

0 comments on commit 5b9eafd

Please sign in to comment.