Skip to content

re's Match does not support indexing: "Value of type "Optional[Match[str]]" is not indexable" #3010

Closed
@blueyed

Description

@blueyed

The following is valid, but mypy complains about it:

import re

m = re.search(".", "foo")
print(m[0])

t-mypy.py:4: error: Value of type "Optional[Match[str]]" is not indexable

Seems to be similar to #2751 (#2753).

mypy 0.710+dev.5f08ccf029aa3046b15e1afc60743ba692e4758d.dirty (dirty due to using latest typshed master (53500c8)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions