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 support for typing.Pattern and re.Pattern #105

Open
Fatal1ty opened this issue Apr 25, 2023 · 0 comments
Open

Add support for typing.Pattern and re.Pattern #105

Fatal1ty opened this issue Apr 25, 2023 · 0 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@Fatal1ty
Copy link
Owner

Is your feature request related to a problem? Please describe.
There is a standard type Pattern https://docs.python.org/3/library/typing.html#typing.Pattern. Support for annotations re.Pattern and typing.Pattern could be useful.

Describe the solution you'd like
A Pattern object can be deserialized from string using re.compile:

print(type(re.compile("[a-z]+")))  # <class 're.Pattern'>

For serialization we can use pattern property:

print(repr(re.compile("[a-z]+").pattern))  # '[a-z]+'

I'm not sure if we should distinguish different variations of a generic Pattern type. We can treat them all like Pattern[str] unless there is a reasonable use of Pattern[bytes].

@Fatal1ty Fatal1ty added enhancement New feature or request good first issue Good for newcomers labels Apr 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant