Skip to content
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

Add regex stubs #6713

Merged
merged 18 commits into from
Dec 30, 2021
Merged

Add regex stubs #6713

merged 18 commits into from
Dec 30, 2021

Conversation

jpy-git
Copy link
Contributor

@jpy-git jpy-git commented Dec 27, 2021

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 😄

Copy link
Contributor Author

@jpy-git jpy-git left a comment

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! 😄

stubs/regex/regex/_regex.pyi Outdated Show resolved Hide resolved
stubs/regex/regex/regex.pyi Outdated Show resolved Hide resolved
stubs/regex/regex/regex.pyi Outdated Show resolved Hide resolved
Copy link
Member

@AlexWaygood AlexWaygood left a comment

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 🙂)

stubs/regex/regex/regex.pyi Outdated Show resolved Hide resolved
stubs/regex/regex/regex.pyi Outdated Show resolved Hide resolved
stubs/regex/regex/regex.pyi Outdated Show resolved Hide resolved
@jpy-git jpy-git changed the title Add initial regex stubs Add regex stubs Dec 29, 2021
Copy link
Contributor Author

@jpy-git jpy-git left a comment

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 😄

stubs/regex/@tests/stubtest_allowlist.txt Show resolved Hide resolved
stubs/regex/regex/_regex_core.pyi Outdated Show resolved Hide resolved
stubs/regex/regex/regex.pyi Outdated Show resolved Hide resolved
stubs/regex/regex/_regex.pyi Outdated Show resolved Hide resolved
@jpy-git jpy-git marked this pull request as ready for review December 29, 2021 01:40
stubs/regex/regex/regex.pyi Outdated Show resolved Hide resolved
stubs/regex/regex/regex.pyi Outdated Show resolved Hide resolved
@LeeeeT
Copy link
Contributor

LeeeeT commented Dec 30, 2021

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

stubs/regex/regex/_regex.pyi Outdated Show resolved Hide resolved
stubs/regex/regex/_regex.pyi Outdated Show resolved Hide resolved
stubs/regex/regex/regex.pyi Show resolved Hide resolved
stubs/regex/@tests/stubtest_allowlist.txt Outdated Show resolved Hide resolved
stubs/regex/regex/_regex.pyi Show resolved Hide resolved
stubs/regex/regex/_regex.pyi Show resolved Hide resolved
stubs/regex/regex/_regex.pyi Show resolved Hide resolved
stubs/regex/regex/regex.pyi Outdated Show resolved Hide resolved
Copy link
Collaborator

@Akuli Akuli left a comment

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:master Dec 30, 2021
@jpy-git
Copy link
Contributor Author

jpy-git commented Dec 30, 2021

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

) -> Scanner[AnyStr]: ...

@final
class Match(Generic[AnyStr]):

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
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
Contributor Author

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 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.

Add typing stubs for regex package
6 participants