Skip to content

gh-102211: Document re.{Pattern,Match}’s existence #102212

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

Merged
merged 14 commits into from
Aug 25, 2023

Conversation

flying-sheep
Copy link
Contributor

@flying-sheep flying-sheep commented Feb 24, 2023

typing documents re.Pattern’s and re.Match’s existence so re should too.

I’m not sure what to add to the body of the classes, so for now I just added them as markers that indeed, re exports two classes by that name.

Rendered:

`typing` documents `re.Pattern`’s and `re.Match`’s existence so `re` should too
@bedevere-bot bedevere-bot added awaiting review docs Documentation in the Doc dir skip news labels Feb 24, 2023
@flying-sheep flying-sheep changed the title Document re.{Pattern,Match}’s existence gh-102211: Document re.{Pattern,Match}’s existence Feb 24, 2023
@gvanrossum gvanrossum removed their request for review February 24, 2023 15:22
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
@hugovk
Copy link
Member

hugovk commented Feb 27, 2023

Preview:

image

https://deploy-preview-102212--python-cpython-preview.netlify.app/library/re.html#regular-expression-objects

image

https://deploy-preview-102212--python-cpython-preview.netlify.app/library/re.html#match-objects


Should "the following methods and attributes" be changed to "the following classes, methods and attributes"?

I’m not sure what to add to the body of the classes, so for now I just added them as markers that indeed, re exports two classes by that name.

Would be nice to add something rather than leaving blank. Why do these classes exist? What use do they have for end users? "Useful for type hints"?

@flying-sheep
Copy link
Contributor Author

flying-sheep commented Feb 27, 2023

I mean, they’re classes. They can be used for instance checks like all other classes. Weirdly they can’t be instantiated (why not, shouldn’t re.Pattern(...) behave the same way as re.compile(...)?)

We could also move things up:

Match objects

class re.Pattern

Compiled regular expression object. See :class:typing.Pattern for use in type hints.

Supports the following methods and attributes:

Pattern.search(...)

...

@flying-sheep
Copy link
Contributor Author

what would you prefer?

@hugovk
Copy link
Member

hugovk commented Jun 26, 2023

If we're going to add the headers, let's add at least some sort of description, however short.

@flying-sheep
Copy link
Contributor Author

this should be ready now

Copy link
Member

@hugovk hugovk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@hugovk hugovk added needs backport to 3.11 only security fixes needs backport to 3.12 only security fixes labels Aug 1, 2023
Copy link
Member

@AA-Turner AA-Turner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, two comments:

A

flying-sheep and others added 2 commits August 6, 2023 19:02
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Copy link
Member

@AA-Turner AA-Turner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I should have made the same suggestion on GenericAlias for both Pattern and Match: (also switched to versionchanged)

Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
@flying-sheep
Copy link
Contributor Author

happy with those changes!

@flying-sheep
Copy link
Contributor Author

Is this waiting for anything?

@hugovk
Copy link
Member

hugovk commented Aug 25, 2023

I think we're good here, thank you for your patience and the contribution!

@hugovk hugovk merged commit 6895ddf into python:main Aug 25, 2023
@miss-islington
Copy link
Contributor

Thanks @flying-sheep for the PR, and @hugovk for merging it 🌮🎉.. I'm working now to backport this PR to: 3.11, 3.12.
🐍🍒⛏🤖

@bedevere-bot
Copy link

GH-108490 is a backport of this pull request to the 3.12 branch.

@bedevere-bot bedevere-bot removed the needs backport to 3.12 only security fixes label Aug 25, 2023
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Aug 25, 2023
…102212)

(cherry picked from commit 6895ddf)

Co-authored-by: Philipp A <flying-sheep@web.de>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
@bedevere-bot
Copy link

GH-108491 is a backport of this pull request to the 3.11 branch.

@bedevere-bot bedevere-bot removed the needs backport to 3.11 only security fixes label Aug 25, 2023
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Aug 25, 2023
…102212)

(cherry picked from commit 6895ddf)

Co-authored-by: Philipp A <flying-sheep@web.de>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
@flying-sheep flying-sheep deleted the re-classes branch August 25, 2023 16:58
hugovk pushed a commit that referenced this pull request Aug 25, 2023
… (#108491)

Co-authored-by: Philipp A <flying-sheep@web.de>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Yhg1s pushed a commit that referenced this pull request Aug 26, 2023
… (#108490)

gh-102211: Document `re.{Pattern,Match}`’s existence (GH-102212)
(cherry picked from commit 6895ddf)

Co-authored-by: Philipp A <flying-sheep@web.de>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir skip news topic-regex
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants