Skip to content

Check if the UNSPECIFIED module-level sentinel is needed #23680

Description

@Matt711

Follow-up from PR #23558 review: Unspecified() already always returns a singleton, so it's
unclear whether the module-level UNSPECIFIED instance is still needed, or if Unspecified()
should just be used directly wherever a sentinel is required:

class Unspecified:
"""
Sentinel value meaning "no value was explicitly provided".
The singleton instance :data:`UNSPECIFIED` is used as the default for every
:class:`StreamingOptions` field, as well as for
``ParquetOptions.prefetch_file_metadata``. When a field is still
``UNSPECIFIED`` after construction (i.e. neither an explicit value nor a
matching environment variable was provided), the consuming component decides
on the semantics.
"""
_instance: Unspecified | None = None
def __new__(cls) -> Unspecified:
"""Return the singleton instance."""
if cls._instance is None:
cls._instance = super().__new__(cls)
return cls._instance
def __repr__(self) -> str:
"""Return ``"UNSPECIFIED"``."""
return "UNSPECIFIED"
UNSPECIFIED = Unspecified()

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions