ty-extensions-unofficial 0.1.0.dev0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ty_extensions_unofficial-0.1.0.dev0/PKG-INFO +20 -0
- ty_extensions_unofficial-0.1.0.dev0/README.md +11 -0
- ty_extensions_unofficial-0.1.0.dev0/pyproject.toml +17 -0
- ty_extensions_unofficial-0.1.0.dev0/src/ty_extensions/__init__.py +1 -0
- ty_extensions_unofficial-0.1.0.dev0/src/ty_extensions/__init__.pyi +157 -0
- ty_extensions_unofficial-0.1.0.dev0/src/ty_extensions/py.typed +0 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
|
+
Name: ty-extensions-unofficial
|
|
3
|
+
Version: 0.1.0.dev0
|
|
4
|
+
Summary: A properly packaged fork of the official ty-extensions
|
|
5
|
+
Author: InSyncWithFoo
|
|
6
|
+
Author-email: InSyncWithFoo <insyncwithfoo@gmail.com>
|
|
7
|
+
Requires-Python: >=3.9
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
|
|
10
|
+
# `ty-extensions-unofficial`
|
|
11
|
+
|
|
12
|
+
This repository contains a properly packaged fork
|
|
13
|
+
of [the official `ty-extensions`][1], whose [PyPI project][2] is empty.
|
|
14
|
+
|
|
15
|
+
At runtime, the package simply raises a `RuntimeError`.
|
|
16
|
+
As such, do not import it normally.
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
[1]: https://github.com/astral-sh/ruff/blob/HEAD/crates/ty_vendored/ty_extensions/ty_extensions.pyi
|
|
20
|
+
[2]: https://pypi.org/project/ty-extensions/
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# `ty-extensions-unofficial`
|
|
2
|
+
|
|
3
|
+
This repository contains a properly packaged fork
|
|
4
|
+
of [the official `ty-extensions`][1], whose [PyPI project][2] is empty.
|
|
5
|
+
|
|
6
|
+
At runtime, the package simply raises a `RuntimeError`.
|
|
7
|
+
As such, do not import it normally.
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
[1]: https://github.com/astral-sh/ruff/blob/HEAD/crates/ty_vendored/ty_extensions/ty_extensions.pyi
|
|
11
|
+
[2]: https://pypi.org/project/ty-extensions/
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "ty-extensions-unofficial"
|
|
3
|
+
version = "0.1.0.dev0"
|
|
4
|
+
description = "A properly packaged fork of the official ty-extensions"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
authors = [
|
|
7
|
+
{ name = "InSyncWithFoo", email = "insyncwithfoo@gmail.com" }
|
|
8
|
+
]
|
|
9
|
+
requires-python = ">=3.9"
|
|
10
|
+
dependencies = []
|
|
11
|
+
|
|
12
|
+
[build-system]
|
|
13
|
+
requires = ["uv_build>=0.9.5,<0.10.0"]
|
|
14
|
+
build-backend = "uv_build"
|
|
15
|
+
|
|
16
|
+
[tool.uv.build-backend]
|
|
17
|
+
module-name = "ty_extensions"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
raise RuntimeError('ty_extensions is not a runtime package')
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
# ruff: noqa: PYI021
|
|
2
|
+
import sys
|
|
3
|
+
import types
|
|
4
|
+
from collections.abc import Iterable
|
|
5
|
+
from enum import Enum
|
|
6
|
+
from typing import (
|
|
7
|
+
Any,
|
|
8
|
+
ClassVar,
|
|
9
|
+
LiteralString,
|
|
10
|
+
Protocol,
|
|
11
|
+
_SpecialForm,
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
from typing_extensions import Self # noqa: UP035
|
|
15
|
+
|
|
16
|
+
# Special operations
|
|
17
|
+
def static_assert(condition: object, msg: LiteralString | None = None) -> None: ...
|
|
18
|
+
|
|
19
|
+
# Types
|
|
20
|
+
Unknown = object()
|
|
21
|
+
AlwaysTruthy = object()
|
|
22
|
+
AlwaysFalsy = object()
|
|
23
|
+
|
|
24
|
+
# Special forms
|
|
25
|
+
Not: _SpecialForm
|
|
26
|
+
Intersection: _SpecialForm
|
|
27
|
+
TypeOf: _SpecialForm
|
|
28
|
+
CallableTypeOf: _SpecialForm
|
|
29
|
+
# Top[T] evaluates to the top materialization of T, a type that is a supertype
|
|
30
|
+
# of every materialization of T.
|
|
31
|
+
Top: _SpecialForm
|
|
32
|
+
# Bottom[T] evaluates to the bottom materialization of T, a type that is a subtype
|
|
33
|
+
# of every materialization of T.
|
|
34
|
+
Bottom: _SpecialForm
|
|
35
|
+
|
|
36
|
+
# ty treats annotations of `float` to mean `float | int`, and annotations of `complex`
|
|
37
|
+
# to mean `complex | float | int`. This is to support a typing-system special case [1].
|
|
38
|
+
# We therefore provide `JustFloat` and `JustComplex` to represent the "bare" `float` and
|
|
39
|
+
# `complex` types, respectively.
|
|
40
|
+
#
|
|
41
|
+
# [1]: https://typing.readthedocs.io/en/latest/spec/special-types.html#special-cases-for-float-and-complex
|
|
42
|
+
type JustFloat = TypeOf[1.0]
|
|
43
|
+
type JustComplex = TypeOf[1.0j]
|
|
44
|
+
|
|
45
|
+
# Constraints
|
|
46
|
+
class ConstraintSet:
|
|
47
|
+
@staticmethod
|
|
48
|
+
def range(lower_bound: Any, typevar: Any, upper_bound: Any) -> Self:
|
|
49
|
+
"""
|
|
50
|
+
Returns a constraint set that requires `typevar` to specialize to a type
|
|
51
|
+
that is a supertype of `lower_bound` and a subtype of `upper_bound`.
|
|
52
|
+
"""
|
|
53
|
+
|
|
54
|
+
@staticmethod
|
|
55
|
+
def always() -> Self:
|
|
56
|
+
"""Returns a constraint set that is always satisfied"""
|
|
57
|
+
|
|
58
|
+
@staticmethod
|
|
59
|
+
def never() -> Self:
|
|
60
|
+
"""Returns a constraint set that is never satisfied"""
|
|
61
|
+
|
|
62
|
+
def implies_subtype_of(self, ty: Any, of: Any) -> Self:
|
|
63
|
+
"""
|
|
64
|
+
Returns a constraint set that is satisfied when `ty` is a `subtype`_ of
|
|
65
|
+
`of`, assuming that all of the constraints in `self` hold.
|
|
66
|
+
|
|
67
|
+
.. _subtype: https://typing.python.org/en/latest/spec/concepts.html#subtype-supertype-and-type-equivalence
|
|
68
|
+
"""
|
|
69
|
+
|
|
70
|
+
def __bool__(self) -> bool: ...
|
|
71
|
+
def __eq__(self, other: ConstraintSet) -> bool: ...
|
|
72
|
+
def __ne__(self, other: ConstraintSet) -> bool: ...
|
|
73
|
+
def __and__(self, other: ConstraintSet) -> ConstraintSet: ...
|
|
74
|
+
def __or__(self, other: ConstraintSet) -> ConstraintSet: ...
|
|
75
|
+
def __invert__(self) -> ConstraintSet: ...
|
|
76
|
+
|
|
77
|
+
# Predicates on types
|
|
78
|
+
#
|
|
79
|
+
# Ideally, these would be annotated using `TypeForm`, but that has not been
|
|
80
|
+
# standardized yet (https://peps.python.org/pep-0747).
|
|
81
|
+
def is_equivalent_to(type_a: Any, type_b: Any) -> ConstraintSet:
|
|
82
|
+
"""Returns a constraint set that is satisfied when `type_a` and `type_b` are
|
|
83
|
+
`equivalent`_ types.
|
|
84
|
+
|
|
85
|
+
.. _equivalent: https://typing.python.org/en/latest/spec/glossary.html#term-equivalent
|
|
86
|
+
"""
|
|
87
|
+
|
|
88
|
+
def is_subtype_of(ty: Any, of: Any) -> ConstraintSet:
|
|
89
|
+
"""Returns a constraint set that is satisfied when `ty` is a `subtype`_ of `of`.
|
|
90
|
+
|
|
91
|
+
.. _subtype: https://typing.python.org/en/latest/spec/concepts.html#subtype-supertype-and-type-equivalence
|
|
92
|
+
"""
|
|
93
|
+
|
|
94
|
+
def is_assignable_to(ty: Any, to: Any) -> ConstraintSet:
|
|
95
|
+
"""Returns a constraint set that is satisfied when `ty` is `assignable`_ to `to`.
|
|
96
|
+
|
|
97
|
+
.. _assignable: https://typing.python.org/en/latest/spec/concepts.html#the-assignable-to-or-consistent-subtyping-relation
|
|
98
|
+
"""
|
|
99
|
+
|
|
100
|
+
def is_disjoint_from(type_a: Any, type_b: Any) -> ConstraintSet:
|
|
101
|
+
"""Returns a constraint set that is satisfied when `type_a` and `type_b` are disjoint types.
|
|
102
|
+
|
|
103
|
+
Two types are disjoint if they have no inhabitants in common.
|
|
104
|
+
"""
|
|
105
|
+
|
|
106
|
+
def is_singleton(ty: Any) -> bool:
|
|
107
|
+
"""Returns `True` if `ty` is a singleton type with exactly one inhabitant."""
|
|
108
|
+
|
|
109
|
+
def is_single_valued(ty: Any) -> bool:
|
|
110
|
+
"""Returns `True` if `ty` is non-empty and all inhabitants compare equal to each other."""
|
|
111
|
+
|
|
112
|
+
# Returns the generic context of a type as a tuple of typevars, or `None` if the
|
|
113
|
+
# type is not generic.
|
|
114
|
+
def generic_context(ty: Any) -> Any: ...
|
|
115
|
+
|
|
116
|
+
# Returns the `__all__` names of a module as a tuple of sorted strings, or `None` if
|
|
117
|
+
# either the module does not have `__all__` or it has invalid elements.
|
|
118
|
+
def dunder_all_names(module: Any) -> Any: ...
|
|
119
|
+
|
|
120
|
+
# List all members of an enum.
|
|
121
|
+
def enum_members[E: type[Enum]](enum: E) -> tuple[str, ...]: ...
|
|
122
|
+
|
|
123
|
+
# Returns a tuple of all members of the given object, similar to `dir(obj)` and
|
|
124
|
+
# `inspect.getmembers(obj)`, with at least the following differences:
|
|
125
|
+
#
|
|
126
|
+
# * `dir` and `inspect.getmembers` may use runtime mutable state to construct
|
|
127
|
+
# the list of attributes returned. In contrast, this routine is limited to
|
|
128
|
+
# static information only.
|
|
129
|
+
# * `dir` will respect an object's `__dir__` implementation, if present, but
|
|
130
|
+
# this method (currently) does not.
|
|
131
|
+
def all_members(obj: Any) -> tuple[str, ...]: ...
|
|
132
|
+
|
|
133
|
+
# Returns `True` if the given object has a member with the given name.
|
|
134
|
+
def has_member(obj: Any, name: str) -> bool: ...
|
|
135
|
+
def reveal_protocol_interface(protocol: type) -> None:
|
|
136
|
+
"""
|
|
137
|
+
Passing a protocol type to this function will cause ty to emit an info-level
|
|
138
|
+
diagnostic describing the protocol's interface.
|
|
139
|
+
|
|
140
|
+
Passing a non-protocol type will cause ty to emit an error diagnostic.
|
|
141
|
+
"""
|
|
142
|
+
|
|
143
|
+
def reveal_mro(cls: type | types.GenericAlias) -> None:
|
|
144
|
+
"""Reveal the MRO that ty infers for the given class or generic alias."""
|
|
145
|
+
|
|
146
|
+
# A protocol describing an interface that should be satisfied by all named tuples
|
|
147
|
+
# created using `typing.NamedTuple` or `collections.namedtuple`.
|
|
148
|
+
class NamedTupleLike(Protocol):
|
|
149
|
+
# from typing.NamedTuple stub
|
|
150
|
+
_field_defaults: ClassVar[dict[str, Any]]
|
|
151
|
+
_fields: ClassVar[tuple[str, ...]]
|
|
152
|
+
@classmethod
|
|
153
|
+
def _make(cls: type[Self], iterable: Iterable[Any]) -> Self: ...
|
|
154
|
+
def _asdict(self, /) -> dict[str, Any]: ...
|
|
155
|
+
def _replace(self, /, **kwargs) -> Self: ...
|
|
156
|
+
if sys.version_info >= (3, 13):
|
|
157
|
+
def __replace__(self, **kwargs) -> Self: ...
|
|
File without changes
|