-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
re.match().group() fails despite if check #7503
Comments
|
In Python 3.8 you'll be able to use assignment expressions which should work with mypy and be more efficient, but until then try a cast or a type ignore. |
mypy with Python 3.8 still has the same issue with the example code:
results in: error: Item "None" of "Optional[Match[str]]" has no attribute "group" |
This is #7316. |
The following code fails the mypy check:
With error:
Despite the explicit check for r.match(x) that means .group() will never be called for None.
How can I work around this?
The text was updated successfully, but these errors were encountered: