Comments (9)
@danygielow do you have an quick answer to this? Otherwise I'll try to make time this weekend.
from auto-optional.
@Luttik , @danygielow , updated the request with section "How do I resolve it".
Unfortunately, it takes a longer time because it should verify the whole src/
folder and not only modified files.
from auto-optional.
It does look like expected behavior then rather than a bug (don't you agree?).
It is expected that it takes longer if you verify the entire project rather than just the changed files.
What I would advise is applying auto-optional once manually to all files and then using the pre-commit only for changed files, that seems like the most optimal solution.
from auto-optional.
@Luttik , I also simulated that behavior and changed 2 files locally with next config:
- id: auto-optional
name: auto-optional
description: Adds the Optional type-hint to arguments where the default value is None
entry: auto-optional
language: python
types: [python]
from auto-optional.
Edit: I have now re-created the problem. I actually didn't yet use auto-optional via pre-commit my projects. Shame on me. It seems pre-commit sends multiple files simultaneously to the command in the pre-commit, which auto-optional doesn't support.
Maybe using https://pre-commit.com/#hooks-require_serial is the solution.
pre-commit
runs by default only over staged files or files you want to commit. If you want to let it run over all files, you can run pre-commit run [-a|--all-files]
.
(see https://pre-commit.com/#top_level-files and https://pre-commit.com/#top_level-exclude for include or exclude config options)
You seem to have added the config from .pre-commit-hooks.yaml
to your .pre-commit-config.yaml
.
You should use the following configuration.
see https://github.com/Luttik/auto-optional#pre-commit
- repo: https://github.com/luttik/auto-optional
rev: v0.2.3 # the current version as of this writing, use 'pre-commit autoupdate' to update to latest version
hooks:
- id: auto-optional
from auto-optional.
You seem to have added the config from .pre-commit-hooks.yaml to your .pre-commit-config.yaml.
@danygielow , it is because I am running it from local install package. I use repo: local for that case.
Simple configuration as Dany proposed:
default_language_version:
python: python3.8
repos:
- repo: https://github.com/luttik/auto-optional
rev: v0.2.3 # the current version as of this writing, use 'pre-commit autoupdate' to update to latest version
hooks:
- id: auto-optional
Modified 2 files:
- src/core/utils/send_emails.py
- src/email_handling/mail.py
Error at the console:
auto-optional............................................................Failed
- hook id: auto-optional
- exit code: 2
Usage: auto-optional [OPTIONS] [PATH]
Try 'auto-optional --help' for help.
Error: Got unexpected extra argument (src/email_handling/mail.py)
Did you test/run it on your projects?
Because you will receive the same error if you modify 2+ files.
The problem still remains.
from auto-optional.
I see you modified your response so you can confirm the problem.
from auto-optional.
Yes, see my Edits in my comment above. I have now re-created the problem. And maybe https://pre-commit.com/#hooks-require_serial in the hook config is the solution.
from auto-optional.
@Luttik @DmytroLitvinov
I opened a PR with a bugfix. The PR has a breaking change though, because giving no arguments are not allowed anymore.
from auto-optional.
Related Issues (6)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from auto-optional.