Currently, all the public functions in this module take arbitrary
**kwargs in order to support “Named lists” and won't raise an error if they receive keyword arguments they don’t need. A distasteful side effect of this is that if I forget, for example, whether I’m supposed to pass a
flags keyword argument to set flags (a mistake I’ve personally made multiple times), I get a silent failure; my argument is simply ignored and I get no clue what I did wrong:
>>> regex.findall('foo', 'FOOD', flag=regex.IGNORECASE) 
To fix this, I suggest tweaking
regex._compile to raise an exception if a kwarg is supplied that isn’t needed. I suppose this would be a slight backwards-compatibility break (since maybe some people were intentionally passing a dictionary of kwargs where only a subset of the keys were needed by any particular regex) but it seems worth it to me; my instinct is that many people have been caught out by the lack of typo resistance in the current API and will be again, while few if any are using kwargs in a way that this would break.
Thoughts? If you’d accept this in principle, I’ll put together a PR.