Skip to content

non-writeable property name in IO #2824

Closed
@jolaf

Description

@jolaf

I'm trying to create my own class that has IO capability.
The class instances would have names similar to file names, but specified at the moment of instance creation.
However when I try setting name field, mypy is protesting.

Here's the minimal repro:

from typing import AnyStr, IO
class MyIO(IO[AnyStr]):
    def __init__(self, name: str) -> None:
        self.name = name

mypy output:

Test.py: note: In member "__init__" of class "MyIO":
Test.py:5: error: Property "name" defined in "IO" is read-only

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