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

--exclude is not working #461

Closed
sadikkuzu opened this issue Apr 16, 2022 · 7 comments
Closed

--exclude is not working #461

sadikkuzu opened this issue Apr 16, 2022 · 7 comments

Comments

@sadikkuzu
Copy link

Hi,

--exclude is not working after v1.3.3

To reproduce:

docker run -it --rm python:latest bash -c '\
cd /tmp ; mkdir compare-133-160; cd $_; \
echo ; \
echo "+ pip install pre-commit" ; \
pip install -q pre-commit ; \
mkdir -p tests/fixtures ; \
mkdir -p tests/folder/fixtures ; \
mkdir -p src/constants ; \
echo "Comman" > ./src/constants/config.py
echo "assingment" > ./tests/folder/fixtures/file.txt ; \
echo "dummy_id = \"b8e718aa646b8a235ba11\"" > ./tests/fixtures/mock_objects.py ; \
typos-hook-1-3-3() { \
cat <<\EOF
repos:
-   repo: https://github.com/crate-ci/typos
    rev: v1.3.3
    hooks:
    -   id: typos
        verbose: true
        args: [
            "--exclude",
            "tests/*/fixtures",
            "tests/fixtures",
            "src/constants/config.py",
        ]
EOF
} ; \
echo ; \
echo "+ cat ./tests/fixtures/mock_objects.py" ; \
cat ./tests/fixtures/mock_objects.py ; \
echo ; \
echo "+ cat ./tests/folder/fixtures/file.txt" ; \
cat ./tests/folder/fixtures/file.txt ; \
echo ; \
echo "+ cat ./src/constants/config.py" ; \
cat ./src/constants/config.py ; \
echo ; \
typos-hook-1-3-3 > .pre-commit-config.yaml ; \
echo "+ cat ./.pre-commit-config.yaml" ; \
cat ./.pre-commit-config.yaml ; \
echo ; \
echo "*** 1.3.3 ***" ; \
git config --global init.defaultBranch main ; \
git init; git add . ; \
pre-commit run --all-files; \
echo ; \
echo "*** 1.6.0 ***" ; \
pre-commit autoupdate; \
git add -u ; \
pre-commit run --all-files;'

Result output is:
image

@epage
Copy link
Collaborator

epage commented Apr 16, 2022

So a basic thing that was fixed in 1.3.4 was a bug in our CLI parser that allowed --exclude v1 v2 v3. It now has to be --exclude v1 --exclude v2 --exclude v3.

However, even with that its not working in the container with pre-commit but is working when I run it directly. Still looking into that.

@epage
Copy link
Collaborator

epage commented Apr 16, 2022

Also, in general using exclude is broken with pre-commit, see #347, I'm just confused as to why it worked before.

@sadikkuzu
Copy link
Author

Hi @epage
Thanks for fast reply.

Unfortunately --exclude v1 --exclude v2 --exclude v3 option didn't work well too.

docker run -it --rm python:latest bash -c '\
cd /tmp ; mkdir compare-133-160; cd $_; \
echo ; \
echo "+ pip install pre-commit" ; \
pip install -q pre-commit ; \
mkdir -p tests/fixtures ; \
mkdir -p tests/folder/fixtures ; \
mkdir -p src/constants ; \
echo "Comman" > ./src/constants/config.py
echo "assingment" > ./tests/folder/fixtures/file.txt ; \
echo "dummy_id = \"b8e718aa646b8a235ba11\"" > ./tests/fixtures/mock_objects.py ; \
typos-hook-1-3-3() { \
cat <<\EOF
repos:
-   repo: https://github.com/crate-ci/typos
    rev: v1.3.3
    hooks:
    -   id: typos
        verbose: true
        args: [
            "--exclude",
            "tests/*/fixtures",
            "--exclude",
            "tests/fixtures",
            "--exclude",
            "src/constants/config.py",
        ]
EOF
} ; \
echo ; \
echo "+ cat ./tests/fixtures/mock_objects.py" ; \
cat ./tests/fixtures/mock_objects.py ; \
echo ; \
echo "+ cat ./tests/folder/fixtures/file.txt" ; \
cat ./tests/folder/fixtures/file.txt ; \
echo ; \
echo "+ cat ./src/constants/config.py" ; \
cat ./src/constants/config.py ; \
echo ; \
typos-hook-1-3-3 > .pre-commit-config.yaml ; \
echo "+ cat ./.pre-commit-config.yaml" ; \
cat ./.pre-commit-config.yaml ; \
echo ; \
echo "*** 1.3.3 ***" ; \
git config --global init.defaultBranch main ; \
git init; git add . ; \
pre-commit run --all-files; \
echo ; \
echo "*** 1.6.0 ***" ; \
pre-commit autoupdate; \
git add -u ; \
pre-commit run --all-files;'

image

@sadikkuzu
Copy link
Author

Also, in general using exclude is broken with pre-commit, see #347, I'm just confused as to why it worked before.

Looking forward to resolution of #347
Thanks

@sadikkuzu
Copy link
Author

sadikkuzu commented Apr 16, 2022

Maybe exclusion should be delegated to pre-commit
as mentioned in #347 (comment)

before

repos:
-   repo: https://github.com/crate-ci/typos
    rev: v1.6.0
    hooks:
    -   id: typos
        verbose: true
        args: [
            "--exclude",
            "tests/*/fixtures",
            "--exclude",
            "tests/fixtures",
            "--exclude",
            "src/constants/config.py",
        ]

after

repos:
-   repo: https://github.com/crate-ci/typos
    rev: v1.6.0
    hooks:
    -   id: typos
        verbose: true
        exclude: "fixtures|src/constants/config"
docker run -it --rm python:latest bash -c '\
cd /tmp ; mkdir compare-133-160; cd $_; \
echo ; \
echo "+ pip install pre-commit" ; \
pip install -q pre-commit ; \
mkdir -p tests/fixtures ; \
mkdir -p tests/folder/fixtures ; \
mkdir -p src/constants ; \
echo "Comman" > ./src/constants/config.py
echo "assingment" > ./tests/folder/fixtures/file.txt ; \
echo "dummy_id = \"b8e718aa646b8a235ba11\"" > ./tests/fixtures/mock_objects.py ; \
typos-hook-1-3-3() { \
cat <<\EOF
repos:
-   repo: https://github.com/crate-ci/typos
    rev: v1.3.3
    hooks:
    -   id: typos
        verbose: true
        exclude: "fixtures|src/constants/config"
EOF
} ; \
echo ; \
echo "+ cat ./tests/fixtures/mock_objects.py" ; \
cat ./tests/fixtures/mock_objects.py ; \
echo ; \
echo "+ cat ./tests/folder/fixtures/file.txt" ; \
cat ./tests/folder/fixtures/file.txt ; \
echo ; \
echo "+ cat ./src/constants/config.py" ; \
cat ./src/constants/config.py ; \
echo ; \
typos-hook-1-3-3 > .pre-commit-config.yaml ; \
echo "+ cat ./.pre-commit-config.yaml" ; \
cat ./.pre-commit-config.yaml ; \
echo ; \
echo "*** 1.3.3 ***" ; \
git config --global init.defaultBranch main ; \
git init; git add . ; \
pre-commit run --all-files; \
echo ; \
echo "*** 1.6.0 ***" ; \
pre-commit autoupdate; \
git add -u ; \
pre-commit run --all-files;'

image

@epage
Copy link
Collaborator

epage commented Apr 18, 2022

Yes, using precommit's exclusions is a workaround for this. The downside is it doesn't work with other uses of typos so you have to duplicate your config in both spots.

@epage epage changed the title --exclude is not working (after v1.3.3) --exclude is not working May 8, 2022
@epage
Copy link
Collaborator

epage commented May 8, 2022

Going ahead and closing this in favor of #347

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants