Skip to content

class decorator could change type of the decorated class #7614

Closed
@ZeeD

Description

@ZeeD

Can a class decorator "change" the type of the decorated class?
My issue is with a "wrapper" class that I created, but I can replicate with even this example:

@str
class C: ...
reveal_type(C)

if I launch mypy I see

$ mypy <(echo '@str
> class C: ...
> reveal_type(C)')
/dev/fd/63:3: note: Revealed type is 'def () -> __main__.C'
$

while C, actually, has became a str!

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