Skip to content

Properly Type MISSING #2008

Open
@VincentRPS

Description

@VincentRPS

Summary

Properly type the MISSING type for things set to it.

What is the feature request for?

The core library

The Problem

Currently any type working as MISSING is not declared as it so type checkers hate is not operations on said type.

The Ideal Solution

Firstly make a type like:

import enum
from typing import Union, TypeVar, Literal

T = TypeVar('T')

class MissingType(enum.Enum):
    MISSING = enum.auto()

MISSING: Literal[MissingType.MISSING] = MissingType.MISSING

Maybe = Union[T, MissingType]

Then simply on values which can be MISSING:

self.guild: Maybe[Guild] = MISSING

The Current Solution

No response

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Projects

    Status

    No status

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions