Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Python2: fix groupindex and lastgroup for re#6778

Closed
jpy-git wants to merge 1 commit into
python:masterpython/typeshed:masterfrom
jpy-git:py2_re_groupindex_lastgroupjpy-git/typeshed:py2_re_groupindex_lastgroupCopy head branch name to clipboard
Closed

Python2: fix groupindex and lastgroup for re#6778
jpy-git wants to merge 1 commit into
python:masterpython/typeshed:masterfrom
jpy-git:py2_re_groupindex_lastgroupjpy-git/typeshed:py2_re_groupindex_lastgroupCopy head branch name to clipboard

Conversation

@jpy-git

@jpy-git jpy-git commented Jan 1, 2022

Copy link
Copy Markdown
Contributor

Follow up PR to #6776.

I checked these types for Python 2.7 as well and observed the same behaviour:

>>> import re
>>> re.compile(r"(?P<test>\w)").groupindex
{'test': 1}
>>> re.compile(b"(?P<test>\w)").groupindex
{'test': 1}
>>> re.compile(r"(?P<test>\w)").search("a1").lastgroup
'test'
>>> re.compile(b"(?P<test>\w)").search(b"a1").lastgroup
'test'

N.B. I also checked if #6763 also applies to Python 2 and observed that Nones are not produced so the current Python 2 typing for re.Pattern.split() is correct.

@github-actions

github-actions Bot commented Jan 1, 2022

Copy link
Copy Markdown
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

@Akuli

Akuli commented Jan 1, 2022

Copy link
Copy Markdown
Collaborator

All of your tests use the same kind of string. In Python 2, type("") is type(b"").

What's your motivation for fixing anything in the Python 2 stubs? We will accept pull requests, but at least I personally don't really care about whether anyone fixes them.

@jpy-git jpy-git closed this Jan 1, 2022
@jpy-git jpy-git deleted the py2_re_groupindex_lastgroup branch January 1, 2022 21:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.