-
-
Notifications
You must be signed in to change notification settings - Fork 33.4k
bpo-31369: include RegexFlag in re.__all__ #30279
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
bpo-31369: include RegexFlag in re.__all__ #30279
Conversation
Misc/NEWS.d/next/Library/2021-12-27-18-28-44.bpo-31369.b9yM94.rst
Outdated
Show resolved
Hide resolved
Doc/library/re.rst
Outdated
|
|
||
| .. data:: NOFLAG | ||
|
|
||
| Indicates no flag being applied, the value is ``0``. |
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.
Similarly, explain when this is useful and add versionadded.
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 can be used for example as a default value for a function parameter, and also as a base value that will later conditionally be ORed with other flags. But this explanation would be confusing to many readers without code examples.
An example as follows may be enough:
def myfunc(text, flag=re.NOFLAG):
return re.match(text, flag)
What do you think?
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.
Thanks! I think that's a useful example.
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.
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.
Not ignored, missed. It took place 11 years prior. We can certainly add a NOFLAGS name now, and make NOFLAG be an alias.
Lib/re.py
Outdated
| "error", "Pattern", "Match", "A", "I", "L", "M", "S", "X", "U", | ||
| "ASCII", "IGNORECASE", "LOCALE", "MULTILINE", "DOTALL", "VERBOSE", | ||
| "UNICODE", | ||
| "UNICODE", "RegexFlag", |
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.
Should also add NOFLAG.
|
@ethanfurman would you like to look at this as it's enum-related? |
|
Thanks! I was just looking into this and was puzzled why a On a related note, I noticed that the type of |
Doc/library/re.rst
Outdated
|
|
||
| .. class:: RegexFlag | ||
|
|
||
| An :class:`~enum.Enum` class containing the regex options listed below. |
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.
What does the tilde in ~enum.Enum mean?
Also, it should be enum.IntFlag.
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.
The tilde creates a link with only the last element visible, i.e. Enum here, but since it should be IntFlag, I also removed the tilde as IntFlag is less known (though reader can still hover over shortened name to see where it links of course).
Doc/library/re.rst
Outdated
|
|
||
| An :class:`~enum.Enum` class containing the regex options listed below. | ||
|
|
||
| .. versionadded:: 3.6 (documented in 3.11) |
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.
Perhaps .. versionchanged:: added to all in 3.11
|
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
Doc/library/re.rst
Outdated
| An :class:`enum.IntFlag` class containing the regex options listed below. | ||
|
|
||
| .. versionadded:: 3.6 (documented in 3.11) | ||
| .. versionadded:: added to ``__all__`` in 3.11) |
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.
Missing a parenthesis, so lets change to:
.. versionadded:: 3.11 - added to ``__all__``
|
Stop
…On Sat, Feb 5, 2022, 12:03 AM Ethan Furman ***@***.***> wrote:
***@***.**** requested changes on this pull request.
------------------------------
In Doc/library/re.rst
<#30279 (comment)>:
>
- .. versionadded:: 3.6 (documented in 3.11)
+ .. versionadded:: added to ``__all__`` in 3.11)
Missing a parenthesis, so lets change to:
.. versionadded:: 3.11 - added to ``__all__``
—
Reply to this email directly, view it on GitHub
<#30279 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AV5LH7EJ7NIFS3KIFCKMXF3UZRSNDANCNFSM5K3D7JFQ>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
|
@ethanfurman thanks for reviewing! |
https://bugs.python.org/issue31369