File: member_modifiers.py

package info (click to toggle)
python-atom 0.11.0-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 1,676 kB
  • sloc: cpp: 9,254; python: 6,181; makefile: 123
file content (37 lines) | stat: -rw-r--r-- 1,156 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# --------------------------------------------------------------------------------------
# Copyright (c) 2023-2024, Nucleic Development Team.
#
# Distributed under the terms of the Modified BSD License.
#
# The full license is in the file LICENSE, distributed with this software.
# --------------------------------------------------------------------------------------
"""Custom marker objects used to modify the default settings of a member."""

from typing import Any, Optional


class set_default(object):
    """An object used to set the default value of a base class member."""

    __slots__ = ("value", "name")

    #: Name of the member for which a new default value should be set. Used by
    #: the metaclass.
    name: Optional[str]

    #: New default value to be set.
    value: Any

    def __init__(self, value: Any) -> None:
        self.value = value
        self.name = None  # storage for the metaclass

    def clone(self) -> "set_default":
        """Create a clone of the sentinel."""
        return type(self)(self.value)


# XXX add more sentinels here to allow customizing members without using the
# members themselves:
# - tag
#