Skip to content

fcntl.flock no longer typechecks with io.FileIO argument #1548

@EvanKrall

Description

@EvanKrall

Seems like an edge case broken by the change in #1505:

This code works in reality, but mypy does not like it:

import io
import fcntl


with io.FileIO('hello.txt', mode='a+', closefd=True) as f:
    fcntl.flock(f, fcntl.LOCK_EX)
    print("hey it works")
    fcntl.flock(f, fcntl.LOCK_UN)
$ python ./blurp.py
hey it works
$ mypy ./blurp.py
blurp.py:6: error: Argument 1 to "flock" has incompatible type "IOBase"; expected "Union[int, IO[Any]]"
blurp.py:8: error: Argument 1 to "flock" has incompatible type "IOBase"; expected "Union[int, IO[Any]]"

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