mercurial/thirdparty/attr/__init__.py
author Matt Harbison <matt_harbison@yahoo.com>
Mon, 21 Nov 2022 15:04:42 -0500
changeset 49643 e1c586b9a43c
parent 34397 765eb17a7eb8
permissions -rw-r--r--
attr: vendor 22.1.0 The previous version was 5 years old, and pytype 2022.06.30 started complaining about various uses (e.g. seeing `mercurial.thirdparty.attr._make._CountingAttr` instead of `bytearray`). Hopefully this helps. Additionally, this has official python 3.11 support. The `attrs` package is left out, because it is simply a bunch of *.pyi stubs and `from attr.X import *`, and that's not how they've been used up to this point. We'd probably need to customize those anyway to `from mercurial.thirdparty.attr import *`.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
49643
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents: 34397
diff changeset
     1
# SPDX-License-Identifier: MIT
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents: 34397
diff changeset
     2
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents: 34397
diff changeset
     3
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents: 34397
diff changeset
     4
import sys
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents: 34397
diff changeset
     5
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents: 34397
diff changeset
     6
from functools import partial
34397
765eb17a7eb8 thirdparty: vendor attrs
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
     7
49643
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents: 34397
diff changeset
     8
from . import converters, exceptions, filters, setters, validators
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents: 34397
diff changeset
     9
from ._cmp import cmp_using
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents: 34397
diff changeset
    10
from ._config import get_run_validators, set_run_validators
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents: 34397
diff changeset
    11
from ._funcs import asdict, assoc, astuple, evolve, has, resolve_types
34397
765eb17a7eb8 thirdparty: vendor attrs
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
    12
from ._make import (
49643
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents: 34397
diff changeset
    13
    NOTHING,
34397
765eb17a7eb8 thirdparty: vendor attrs
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
    14
    Attribute,
765eb17a7eb8 thirdparty: vendor attrs
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
    15
    Factory,
49643
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents: 34397
diff changeset
    16
    attrib,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents: 34397
diff changeset
    17
    attrs,
34397
765eb17a7eb8 thirdparty: vendor attrs
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
    18
    fields,
49643
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents: 34397
diff changeset
    19
    fields_dict,
34397
765eb17a7eb8 thirdparty: vendor attrs
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
    20
    make_class,
765eb17a7eb8 thirdparty: vendor attrs
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
    21
    validate,
765eb17a7eb8 thirdparty: vendor attrs
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
    22
)
49643
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents: 34397
diff changeset
    23
from ._version_info import VersionInfo
34397
765eb17a7eb8 thirdparty: vendor attrs
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
    24
765eb17a7eb8 thirdparty: vendor attrs
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
    25
49643
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents: 34397
diff changeset
    26
__version__ = "22.1.0"
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents: 34397
diff changeset
    27
__version_info__ = VersionInfo._from_version_string(__version__)
34397
765eb17a7eb8 thirdparty: vendor attrs
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
    28
765eb17a7eb8 thirdparty: vendor attrs
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
    29
__title__ = "attrs"
765eb17a7eb8 thirdparty: vendor attrs
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
    30
__description__ = "Classes Without Boilerplate"
49643
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents: 34397
diff changeset
    31
__url__ = "https://www.attrs.org/"
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents: 34397
diff changeset
    32
__uri__ = __url__
34397
765eb17a7eb8 thirdparty: vendor attrs
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
    33
__doc__ = __description__ + " <" + __uri__ + ">"
765eb17a7eb8 thirdparty: vendor attrs
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
    34
765eb17a7eb8 thirdparty: vendor attrs
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
    35
__author__ = "Hynek Schlawack"
765eb17a7eb8 thirdparty: vendor attrs
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
    36
__email__ = "hs@ox.cx"
765eb17a7eb8 thirdparty: vendor attrs
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
    37
765eb17a7eb8 thirdparty: vendor attrs
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
    38
__license__ = "MIT"
765eb17a7eb8 thirdparty: vendor attrs
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
    39
__copyright__ = "Copyright (c) 2015 Hynek Schlawack"
765eb17a7eb8 thirdparty: vendor attrs
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
    40
765eb17a7eb8 thirdparty: vendor attrs
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
    41
49643
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents: 34397
diff changeset
    42
s = attributes = attrs
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents: 34397
diff changeset
    43
ib = attr = attrib
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents: 34397
diff changeset
    44
dataclass = partial(attrs, auto_attribs=True)  # happy Easter ;)
34397
765eb17a7eb8 thirdparty: vendor attrs
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
    45
765eb17a7eb8 thirdparty: vendor attrs
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
    46
__all__ = [
765eb17a7eb8 thirdparty: vendor attrs
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
    47
    "Attribute",
765eb17a7eb8 thirdparty: vendor attrs
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
    48
    "Factory",
765eb17a7eb8 thirdparty: vendor attrs
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
    49
    "NOTHING",
765eb17a7eb8 thirdparty: vendor attrs
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
    50
    "asdict",
765eb17a7eb8 thirdparty: vendor attrs
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
    51
    "assoc",
765eb17a7eb8 thirdparty: vendor attrs
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
    52
    "astuple",
765eb17a7eb8 thirdparty: vendor attrs
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
    53
    "attr",
765eb17a7eb8 thirdparty: vendor attrs
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
    54
    "attrib",
765eb17a7eb8 thirdparty: vendor attrs
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
    55
    "attributes",
765eb17a7eb8 thirdparty: vendor attrs
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
    56
    "attrs",
49643
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents: 34397
diff changeset
    57
    "cmp_using",
34397
765eb17a7eb8 thirdparty: vendor attrs
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
    58
    "converters",
765eb17a7eb8 thirdparty: vendor attrs
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
    59
    "evolve",
765eb17a7eb8 thirdparty: vendor attrs
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
    60
    "exceptions",
765eb17a7eb8 thirdparty: vendor attrs
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
    61
    "fields",
49643
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents: 34397
diff changeset
    62
    "fields_dict",
34397
765eb17a7eb8 thirdparty: vendor attrs
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
    63
    "filters",
765eb17a7eb8 thirdparty: vendor attrs
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
    64
    "get_run_validators",
765eb17a7eb8 thirdparty: vendor attrs
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
    65
    "has",
765eb17a7eb8 thirdparty: vendor attrs
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
    66
    "ib",
765eb17a7eb8 thirdparty: vendor attrs
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
    67
    "make_class",
49643
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents: 34397
diff changeset
    68
    "resolve_types",
34397
765eb17a7eb8 thirdparty: vendor attrs
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
    69
    "s",
765eb17a7eb8 thirdparty: vendor attrs
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
    70
    "set_run_validators",
49643
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents: 34397
diff changeset
    71
    "setters",
34397
765eb17a7eb8 thirdparty: vendor attrs
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
    72
    "validate",
765eb17a7eb8 thirdparty: vendor attrs
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
    73
    "validators",
765eb17a7eb8 thirdparty: vendor attrs
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
    74
]
49643
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents: 34397
diff changeset
    75
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents: 34397
diff changeset
    76
if sys.version_info[:2] >= (3, 6):
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents: 34397
diff changeset
    77
    from ._next_gen import define, field, frozen, mutable  # noqa: F401
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents: 34397
diff changeset
    78
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents: 34397
diff changeset
    79
    __all__.extend(("define", "field", "frozen", "mutable"))