question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

pre-commit exclude is ignored

See original GitHub issue

Question

Is it possible to ignore directories and files when using the mypy pre-commit by specifying exclude?

My .pre-commit-config.yaml file:

default_language_version:
    python: python3.6
repos:
-   repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v2.1.0
    hooks:
    -   id: flake8
        args: [ignore_me, not_me]
        exclude: 'ignore_me' # This works, and skips the directory ignore_me, and only runs flake8 on the not_me directory
-   repo: https://github.com/pre-commit/mirrors-mypy
    rev: v0.670
    hooks:
    -   id: mypy
        args: [--ignore-missing-imports, .]
        exclude: 'ignore_me' # I still see mypy errors from the ignore_me directory

When I commit in my repository, I still see mypy errors from ignore_me and I don’t get the flake8 errors.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:5
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

10reactions
asottilecommented, Jul 7, 2021

you’ll note I didn’t use exclude anywhere, I instead configured mypy settings for individual modules

5reactions
konstantinmillercommented, Jul 7, 2021

Sorry but it’s still unclear to me how to make mypy ignore errors in specific files. The link in your post doesn’t provide an example of that.

I’ve tried adding

exclude: path/to/my/folder

to .pre-commit-config.yaml

and I’ve tried adding

[mypy]
exclude = path/to/my/folder

to mypy.ini

I’ve also tried adding

args: [--exclude path/to/my/folder]

to .pre-commit-config.yaml

None of it worked.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Pre-commit-hook ignores exclude patterns · Issue #395 - GitHub
While configuring this, I discovered that black seems to ignore inclusion/exclusion rules completely if it's given a path to a file not a...
Read more >
Exclude some files on running black using pre-commit
This issue on the black issue tracker outlines your particular problem. pre-commit finds all the python files, then applies pre-commit 's ...
Read more >
pre-commit
Git hook scripts are useful for identifying simple issues before submission to code review. We run our hooks on every commit to automatically...
Read more >
Can I Exclude Files From Every Precommit Hook Except For One
Here is an example let's say we want to ignore a file called readme.txt then we just.gitignore file ignoring files in Git |...
Read more >
Available Hooks • precommit - Lorenz Walthert's
Arguments for the hooks are specified as described in the pre-commit.com ... Argument ignore-start and ignore-stop is passed to options() to set ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found