classification
Title: re.RegexFlag is not included in __all__
Type: Stage:
Components: Documentation, Regular Expressions Versions: Python 3.7, Python 3.6
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: docs@python Nosy List: PJB3005, docs@python, ezio.melotti, mrabarnett, r.david.murray
Priority: normal Keywords:

Created on 2017-09-06 20:40 by PJB3005, last changed 2017-09-06 22:53 by r.david.murray.

Messages (4)
msg301516 - (view) Author: Pieter-Jan Briers (PJB3005) Date: 2017-09-06 20:40
It exists and its flags are exported, but not the direct classes itself. This seems inconsistent to me and fixing it would make things like using static typing on it just a little bit easier.
msg301529 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2017-09-06 22:24
I think RegexFlag is an implementation detail, but it is true that it isn't prefixed with a _ so putting it in __all__ is not obviously wrong.  However, if we do that we should also document it (currently it is mentioned only in a versionchanged line, which isn't technically documenting it).

I find it curious that static typing is affected by __all___, but I don't really know anything about typing.
msg301532 - (view) Author: Pieter-Jan Briers (PJB3005) Date: 2017-09-06 22:43
I suppose it may be an implementation detail, though I wouldn't be amazed that had enum existed when re was written it'd have been used instead of constant integers at the time. Though I do suppose exposing it fully would add two ways to get the flags which I can see how it would be considered bad.

It's still useful for type checking though, and while I did make a PR to add it to typeshed, that still leaves it in an iffy state and I probably would not be the last person to be confused by it initially.
msg301536 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2017-09-06 22:53
Well, I consider that they really should be named constants and not an enum, which is why I consider it an implementation detail :)
History
Date User Action Args
2017-09-06 22:53:45r.david.murraysetmessages: + msg301536
2017-09-06 22:43:21PJB3005setmessages: + msg301532
2017-09-06 22:24:23r.david.murraysetversions: + Python 3.7
nosy: + r.david.murray, docs@python

messages: + msg301529

assignee: docs@python
components: + Documentation
2017-09-06 20:40:02PJB3005create