Skip to content

Add regex stubs - #6713

Merged
Akuli merged 18 commits into
python:masterfrom
jpy-git:regex_stubs
Dec 30, 2021
Merged

Add regex stubs#6713
Akuli merged 18 commits into
python:masterfrom
jpy-git:regex_stubs

Conversation

@jpy-git

Copy link
Copy Markdown
Contributor

This PR closes#6710.

Aim is to provide typing stubs for the regex package.
This regex implementation is backwards-compatible with the standard 're' module, but offers additional functionality.
Github: https://github.com/mrabarnett/mrab-regex
PyPI: https://pypi.org/project/regex/

I'm opening this as a draft as I have a couple questions about how to reference types for classes defined in C code (will annotate the PR with the questions). Any help/suggestions are greatly appreciated 😄

@jpy-gitjpy-git left a comment

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Some direction on these points (plus any general improvements) would be really appreciated, thanks! 😄

Comment threadstubs/regex/regex/_regex.pyi Outdated
Comment threadstubs/regex/regex/regex.pyi Outdated
Comment threadstubs/regex/regex/regex.pyi Outdated
Comment threadstubs/regex/regex/regex.pyi Outdated

@AlexWaygoodAlexWaygood left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

With the latest mypy release, we no longer need uppercase Tuple (and attempting to import it will cause CI to fail after the changes to check_new_syntax that I introduced in #6717 🙂)

Comment threadstubs/regex/regex/regex.pyi Outdated
Comment threadstubs/regex/regex/regex.pyi Outdated
Comment threadstubs/regex/regex/regex.pyi Outdated
@jpy-gitjpy-git changed the title Add initial regex stubsAdd regex stubsDec 29, 2021

@jpy-gitjpy-git left a comment

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

This should be ready for review now 😄

Comment threadstubs/regex/@tests/stubtest_allowlist.txt
Comment threadstubs/regex/regex/_regex_core.pyi Outdated
Comment threadstubs/regex/regex/regex.pyi Outdated
Comment threadstubs/regex/regex/_regex.pyi Outdated
@jpy-git
jpy-git marked this pull request as ready for review December 29, 2021 01:40
Comment threadstubs/regex/regex/regex.pyi Outdated
Comment threadstubs/regex/regex/regex.pyi Outdated
@LeeeeT

Copy link
Copy Markdown
Contributor

Thank you so much! Your PR is just in time 🚀🚀🚀

jpy-gitand others added 2 commits December 30, 2021 13:21
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Comment threadstubs/regex/regex/_regex.pyi Outdated
Comment threadstubs/regex/regex/_regex.pyi Outdated
Comment threadstubs/regex/regex/regex.pyi
Comment threadstubs/regex/@tests/stubtest_allowlist.txt Outdated
Comment threadstubs/regex/regex/_regex.pyi
Comment threadstubs/regex/regex/_regex.pyi
Comment threadstubs/regex/regex/_regex.pyi
Comment threadstubs/regex/regex/regex.pyi Outdated

@AkuliAkuli left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks!

@Akuli
Akuli merged commit fbf5982 into python:masterDec 30, 2021
@jpy-git

Copy link
Copy Markdown
ContributorAuthor

Awesome, thanks @Akuli and @AlexWaygood for the great reviews 😄

) -> Scanner[AnyStr]: ...

@final
class Match(Generic[AnyStr]):

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Is this missing __getitem__? After updating some modules I now get hundreds of "__getitem__" method not defined on type "Match[str]" errors.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I'm not using regex and have not investigated, but this seems likely. re.Match (or rather typing.Match) also has a __getitem__() field. Cc @jpy-git

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Makes sense, will make a PR 👍

Sign up for freeto 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.

Add typing stubs for regex package

6 participants

@jpy-git@LeeeeT@srittau@richardjharris@Akuli@AlexWaygood