-
Notifications
You must be signed in to change notification settings - Fork 466
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
Read options from config #1668
Read options from config #1668
Conversation
Nice MR :-) But, I would prefer .codespellrc or .codespell/config or something similar. |
I am of the opposite mind, I prefer when all the tools can use one |
OK - I also added a magic |
Ok - I think this is finally ready to merge! On a separate note, it would be really helpful to have a requirements file and a contributing guide, to show how to run all of the various checks locally (unit tests, flake, etc.). Most of these are buried in the various CIs. This is a really fantastic simple tool... I have been looking for a good native python spell checker for quite some time. Good work! |
I would rather just support traversing a list -- it's more common with Python tools AFAIK. For example: https://flake8.pycqa.org/en/latest/user/configuration.html#configuration-locations To start, looking for If you don't feel like implementing this, I'd say just kill the |
@tomasbw does this do what you want? |
To further clarify the order of config parsing:
|
I think there is a problem with this hierarchy, I think command-line-passed arguments should have the highest priority. So in your list, it should be last, not first. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few comments
options = parser.parse_args(cfg_args) | ||
|
||
# Re-parse command line options to override config. | ||
options = parser.parse_args(list(args), namespace=options) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than re-calling this, would it be better to do:
if config.has_section(...):
...
options = parser.parse_args(cfg_args)
else:
options = argparse.NameSpace()
options = parser.parse_args(list(args), namespace=options)
If it's equivalent, it seems simpler/cleaner
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It only re-parses if config.has_section()
. The args have to be parsed first (line 372) before checking the config, to see if there is a --config
option passed. And they have to be re-parsed at the end in order to override the options from the config file (which was the requested behavior). Following your suggestion, you would be re-parsing it twice if there were no config files, which seems pointless.
It's your project though, feel free to re-implement it yourself if you have a better idea.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh right, forgot about the need to parse to see the --config
value. This should be fine then!
Thanks @vsalvino |
I guess we should dog food? This bit of Travis might be interesting, we'll have to override our skip config:
|
* .github/workflows/bump_chart_version.yaml: remove trailing whitespace Signed-off-by: Mateusz Gozdek <mateusz@kinvolk.io> * .codespellrc: initial commit Adds configuration for running codespell locally to check for possible typos. In the future this configuration file should be used by CI as well, but this is currently not possible until this PR gets merged: codespell-project/codespell#1668 Signed-off-by: Mateusz Gozdek <mateusz@kinvolk.io> * .github/workflows: run spell checking as part of CI process To avoid adding obvious typos. Signed-off-by: Mateusz Gozdek <mateusz@kinvolk.io> * Fix various typos found by codespell and manually Signed-off-by: Mateusz Gozdek <mateusz@kinvolk.io>
This adds the ability to read options from a config file, such as setup.cfg, similar to how most other python tools work.