Skip to content

Commit

Permalink
allow recursive exclude glob patterns (#20)
Browse files Browse the repository at this point in the history
* add pre-commit sentinels
* allow recursive ** file globbing
* use the new feature with the pre-commit sentinels
* update readme
* it's time for version 1.0.0
  • Loading branch information
haarcuba authored Sep 13, 2024
1 parent 07c5d8f commit da75b87
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 4 deletions.
5 changes: 3 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,17 @@ repos:
- id: flake8
args:
- --ignore=E203,E501,E266,F541,W503
- --exclude=tests/fixtures/*
- '--exclude=tests/fixtures/*,pre-commit-sentinels/*'
- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.28.3
hooks:
- id: check-github-workflows
args: ["--verbose"]
- repo: https://github.com/PracticeFoxyCode/practice
rev: releases/0.8.0
rev: 4ec1c03
hooks:
- id: foxylint-imports
args:
- "--exclude=tests/fixtures/*.py"
- "--exclude=pre-commit-sentinels/**/*.py"
- "--accept=/from mylogging/"
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1113,6 +1113,8 @@ You can exclude some files with `--exclude`, e.g.
- "--exclude=some/other/files/*.py" # you can repeat the --exlucde argument
```

You can use `**` globbing in exlude patterns.

You can make overall exceptions with `--accpet`, e.g.

```yaml
Expand Down
2 changes: 1 addition & 1 deletion foxylint/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def bold(text):
def main(files, exclude, accept):
excluded = []
for pattern in exclude:
excluded.extend(glob.glob(pattern))
excluded.extend(glob.glob(pattern, recursive=True))

excluded = [str(os.path.abspath(file)) for file in excluded]

Expand Down
6 changes: 6 additions & 0 deletions pre-commit-sentinels/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Pre-Commit Sentinels

This directory contains files with bad, unfoxy code.

The purpose is to make sure various specifications in this repository's
`.pre-commit-config.yaml` work, so that the linter knows to ignore this entire tree.
6 changes: 6 additions & 0 deletions pre-commit-sentinels/bad.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from pathlib import Path
from bad import behavior


def main():
pass
6 changes: 6 additions & 0 deletions pre-commit-sentinels/deeper/bad.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from pathlib import Path
from bad import behavior


def main():
pass
6 changes: 6 additions & 0 deletions pre-commit-sentinels/deeper/deeper/bad.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from pathlib import Path
from bad import behavior


def main():
pass
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "foxylint"
version = "0.9.0"
version = "1.0.0"
description = ""
authors = ["Yoav Kleinberger <[email protected]>"]
license = "MIT"
Expand Down

0 comments on commit da75b87

Please sign in to comment.