Skip to content

There is no way to annotate singletons like sys.monitoring.DISABLE #135807

Open
@gaogaotiantian

Description

@gaogaotiantian

Feature or enhancement

Proposal:

We have singletons like sys.monitoring.MISSING and sys.monitoring.DISABLE - and there's no way to annotate them in the function. In our own documentation we have something like

func(code: CodeType, instruction_offset: int) -> DISABLE | Any

but that's just wrong (well maybe pseudo?) - we can't do that. It's common to annotate a callback function with sys.monitoring.DISABLE, if you don't want to use Any. If you want to use it somewhere else, you might want to annotate as well.

I'm not the typing expert, but is there a way to support this? Literal[sys.monitoring.DISABLE] won't work either because it's a variable - I would accept that.

Has this already been discussed elsewhere?

No response given

Links to previous discussion of this feature:

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions