Use flake8 config file
In #6, it was mentioned the CLI options would be exposed through flake8 config system. This would be great, as currently if the darglint config is not picked up (i.e. if running in a higher directory) then you are forced to use default settings, and flake8 --config=path/to/setup.cfg would fix this.
From what I could tell, this should be easy to implement - it seems we only need --docstring-style and --strictness exposed. If no one wants to do this, I might have time this weekend to have a go at it.
Ah, good catch. Feel free to attempt it, if you'd like. Let me know if you have any questions.
Has there been any progress on this? I was thinking about giving it a try, but don't want to duplicate work.
Sorry, not yet. I've been mostly trying to focus on stability and reducing regressions lately. Sure, if you'd like to try it go ahead. I'll post here before starting to work on it myself, if I can get around to it.
I'm working on this right now, but I had a question about how you'd like it to work.
As things are now, there would be some duplication between config.py and the the flake8 entrypoint. It's not much, but the code that translates strings to Enum values would need to be duplicated. My suggestion is that I refactor that out to something accessible from both the main configuration loader and the flake8 entrypoint. I think it would look something like this:
class Strictness(Enum):
SHORT_DESCRIPTION = 1
LONG_DESCRIPTION = 2
FULL_DESCRIPTION = 3
@classmethod
def string_to_member(cls, string):
# Code that is currently at https://github.com/terrencepreilly/darglint/blob/master/darglint/config.py#L217
And the same thing for the DocstringStyle Enum.
This would be similar to what I've seen other flake8 extensions do, plus make things easier if you ever support a new style or make any changes like that.
So, do you want me to go ahead and do that, or just copy and paste the code into the flake8 entrypoint?
Assuming that the code is always using the Enum (i.e. using is Strictness.SHORT_DESCRIPTION, rather than using the int values), then you could just use the enum values like:
class Strictness(Enum):
SHORT_DESCRIPTION = 'short'
LONG_DESCRIPTION = 'long'
FULL_DESCRIPTION = 'full'
Strictness('short') # <Strictness.SHORT_DESCRIPTION: 'short'>
The problem with that approach is that it would only provide one option. Currently, the configuration accepts either "short" or "short_description" and so on, so to remain backwards-compatible, whatever we end up doing has to accept both ways, as well (I assume).
@Harrison88, your suggestion sounds fine. (Sorry I took a while to respond -- I had to fly back home for a funeral, so I've been out of touch for a week.) Since this is constructing values from a string, I'd probably name the class method something like from_string, though.
No problem, I hope all is well. from_string does sound better. I should be able to put in a pull request sometime this coming week.