asottile/add-trailing-comma

Enable the `directory` args option in addition to `filenames`

amirhessam88 opened this issue · 3 comments

Hey @asottile ; I am trying to use add-trailing-comma as part of formatting and use flake8-comma as check against it. I can see this as help:

usage: add-trailing-comma [-h] [--exit-zero-even-if-changed] [--py35-plus] [--py36-plus] [filenames ...]

My understanding is the directory option is not currently available. I have seen black or isort have this ability:

  --src SRC_PATHS, --src-path SRC_PATHS
                        Add an explicitly defined source path (modules within src paths have their imports automatically categorized as first_party). Glob expansion (`*` and `**`) is supported for
                        this option.

I was wondering maybe this can be a very helpful feature. I also appreciate it if you direct me how can I apply this on a directory. For example, lets say I have src/ and tests/ and I wanna apply add-trailing-comma to all .py files.
Currently, I am running the snippet below (I use poetry) in my formatting scripts:

poetry run add-trailing-comma src/**/*.py tests/**/*.py 

search the issue tracker

Thanks @asottile Just found this --> #37 which is using pre-commit; Can you point me to the CLI option? thanks again

there is none, you did not find the relevant issue -- that one is unrelated. #59