Skip to content

Are the type stubs for decorator accurate? #14286

Open
@MarcoGorelli

Description

@MarcoGorelli

If I write:

from decorator import FunctionMaker

fm = FunctionMaker(lambda x: x)
print(f'{fm.defaults=}')

then I see

fm.defaults=None

However, the stubs show:

defaults: tuple[Any, ...]

and None can't be assigned to tuple[Any, ...]

@donBarbos sorry for the ping, I just saw that you worked on these stubs a few months ago. Can you tell if it's accurate that defaults should be tuple[Any, ...] | None?

The inspect docs also note:

defaults is an n-tuple of default argument values corresponding to the last n positional parameters, or None if there are no such defaults defined

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