Skip to content

Arbitrary attributes are available on T: Callable #3303

@sharkdp

Description

@sharkdp

Those attribute accesses should be errors:

from typing import Callable

def my_decorator[T: Callable](f: T):
    print(f.whatever)
    f.whatever = 1

https://play.ty.dev/613cab3e-17be-463e-b5bd-023bf2a72114

(happens for a more specific Callable type too)

Metadata

Metadata

Assignees

No one assigned

    Labels

    attribute accessInstance attributes, class attributes, etc.bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions