Skip to content

Mypy does not accept mmap object in re.match #1467

Closed
@libre-man

Description

@libre-man

It seems that the re.compile types are to restrictive, the following code errors in mypy but running it is no problem:

# _txt_fmt is a object gotten from `re.compile`
with open(file, 'r+') as f:
    with mmap.mmap(f.fileno(), 0) as data:
        match = _txt_fmt.match(data)

Mypy gives the error Argument 1 to "match" of "Pattern" has incompatible type "mmap"; expected "bytes".

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions