id stringlengths 14 16 | text stringlengths 13 2.7k | source stringlengths 57 178 |
|---|---|---|
356e2cfe11ce-40 | # `Unpack` only takes one argument, so __args__ should contain only
# a single item.
return '*' + repr(self.__args__[0])
def __getitem__(self, args):
if self.__typing_is_unpacked_typevartuple__:
return args
return super().__getitem__(args)
@property
def __typing_u... | lang/api.python.langchain.com/en/latest/_modules/typing.html |
356e2cfe11ce-41 | """Parameterizes a generic class.
At least, parameterizing a generic class is the *main* thing this method
does. For example, for some generic class `Foo`, this is called when we
do `Foo[int]` - there, with `cls=Foo` and `params=int`.
However, note that this method is also called when de... | lang/api.python.langchain.com/en/latest/_modules/typing.html |
356e2cfe11ce-42 | new_args.extend(new_arg)
else:
new_args.append(new_arg)
params = tuple(new_args)
return _GenericAlias(cls, params,
_paramspec_tvars=True)
def __init_subclass__(cls, *args, **kwargs):
super().__init_subclass__(*args, **kwarg... | lang/api.python.langchain.com/en/latest/_modules/typing.html |
356e2cfe11ce-43 | s_args = ', '.join(str(g) for g in gvars)
raise TypeError(f"Some type variables ({s_vars}) are"
f" not listed in Generic[{s_args}]")
tvars = gvars
cls.__parameters__ = tuple(tvars)
class _TypingEllipsis:
"""Internal placeholder for ... ... | lang/api.python.langchain.com/en/latest/_modules/typing.html |
356e2cfe11ce-44 | # PEP 544 prohibits using issubclass() with protocols that have non-method members.
return all(callable(getattr(cls, attr, None)) for attr in _get_protocol_attrs(cls))
def _no_init_or_replace_init(self, *args, **kwargs):
cls = type(self)
if cls._is_protocol:
raise TypeError('Protocols cannot be inst... | lang/api.python.langchain.com/en/latest/_modules/typing.html |
356e2cfe11ce-45 | return sys._getframe(depth + 1).f_globals.get('__name__', default)
except (AttributeError, ValueError): # For platforms without _getframe()
return None
def _allow_reckless_class_checks(depth=3):
"""Allow instance and class checks for special stdlib modules.
The abc and functools modules indiscrimin... | lang/api.python.langchain.com/en/latest/_modules/typing.html |
356e2cfe11ce-46 | if cls._is_protocol:
if all(hasattr(instance, attr) and
# All *methods* can be blocked by setting them to None.
(not callable(getattr(cls, attr, None)) or
getattr(instance, attr) is not None)
for attr in _get_protocol_attrs(cls... | lang/api.python.langchain.com/en/latest/_modules/typing.html |
356e2cfe11ce-47 | cls._is_protocol = any(b is Protocol for b in cls.__bases__)
# Set (or override) the protocol subclass hook.
def _proto_hook(other):
if not cls.__dict__.get('_is_protocol', False):
return NotImplemented
# First, perform various sanity checks.
if not ge... | lang/api.python.langchain.com/en/latest/_modules/typing.html |
356e2cfe11ce-48 | # We have nothing more to do for non-protocols...
if not cls._is_protocol:
return
# ... otherwise check consistency of bases, and prohibit instantiation.
for base in cls.__bases__:
if not (base in (object, Generic) or
base.__module__ in _PROTO_ALLOWLIS... | lang/api.python.langchain.com/en/latest/_modules/typing.html |
356e2cfe11ce-49 | return "typing.Annotated[{}, {}]".format(
_type_repr(self.__origin__),
", ".join(repr(a) for a in self.__metadata__)
)
def __reduce__(self):
return operator.getitem, (
Annotated, (self.__origin__,) + self.__metadata__
)
def __eq__(self, other):
... | lang/api.python.langchain.com/en/latest/_modules/typing.html |
356e2cfe11ce-50 | - Instantiating an annotated type is equivalent to instantiating the
underlying type::
assert Annotated[C, Ann1](5) == C(5)
- Annotated can be used as a generic type alias::
Optimized: TypeAlias = Annotated[T, runtime.Optimize()]
assert Optimized[int] == Annotated[int, runtime.Optimize()... | lang/api.python.langchain.com/en/latest/_modules/typing.html |
356e2cfe11ce-51 | origin = _type_check(params[0], msg, allow_special_forms=True)
metadata = tuple(params[1:])
return _AnnotatedAlias(origin, metadata)
def __init_subclass__(cls, *args, **kwargs):
raise TypeError(
"Cannot subclass {}.Annotated".format(cls.__module__)
)
def runtime_checkable... | lang/api.python.langchain.com/en/latest/_modules/typing.html |
356e2cfe11ce-52 | At runtime this does nothing: it returns the first argument unchanged with no
checks or side effects, no matter the actual type of the argument.
When a static type checker encounters a call to assert_type(), it
emits an error if the value is not of the specified type::
def greet(name: str) -> None:
... | lang/api.python.langchain.com/en/latest/_modules/typing.html |
356e2cfe11ce-53 | and these are also used as the locals. If the object does not appear
to have globals, an empty dictionary is used. For classes, the search
order is globals first then locals.
- If one dict argument is passed, it is used for both globals and
locals.
- If two dict arguments are passed, they sp... | lang/api.python.langchain.com/en/latest/_modules/typing.html |
356e2cfe11ce-54 | value = _eval_type(value, base_globals, base_locals)
hints[name] = value
return hints if include_extras else {k: _strip_annotations(t) for k, t in hints.items()}
if globalns is None:
if isinstance(obj, types.ModuleType):
globalns = obj.__dict__
else:
n... | lang/api.python.langchain.com/en/latest/_modules/typing.html |
356e2cfe11ce-55 | def _strip_annotations(t):
"""Strip the annotations from a given type."""
if isinstance(t, _AnnotatedAlias):
return _strip_annotations(t.__origin__)
if hasattr(t, "__origin__") and t.__origin__ in (Required, NotRequired):
return _strip_annotations(t.__args__[0])
if isinstance(t, _Generic... | lang/api.python.langchain.com/en/latest/_modules/typing.html |
356e2cfe11ce-56 | assert get_origin(P.args) is P
"""
if isinstance(tp, _AnnotatedAlias):
return Annotated
if isinstance(tp, (_BaseGenericAlias, GenericAlias,
ParamSpecArgs, ParamSpecKwargs)):
return tp.__origin__
if tp is Generic:
return Generic
if isinstance(tp, types.U... | lang/api.python.langchain.com/en/latest/_modules/typing.html |
356e2cfe11ce-57 | is_typeddict(Union[list, str]) # => False
"""
return isinstance(tp, _TypedDictMeta)
_ASSERT_NEVER_REPR_MAX_LENGTH = 100
def assert_never(arg: Never, /) -> Never:
"""Statically assert that a line of code is unreachable.
Example::
def int_or_str(arg: int | str) -> None:
match arg:
... | lang/api.python.langchain.com/en/latest/_modules/typing.html |
356e2cfe11ce-58 | or getattr(obj, '__module__', None) != arg.__module__
):
# We only modify objects that are defined in this type directly.
# If classes / methods are nested in multiple layers,
# we will modify them when processing their direct holders.
continue... | lang/api.python.langchain.com/en/latest/_modules/typing.html |
356e2cfe11ce-59 | def overload(func):
"""Decorator for overloaded functions/methods.
In a stub file, place two or more stub definitions for the same
function in a row, each decorated with @overload.
For example::
@overload
def utf8(value: None) -> None: ...
@overload
def utf8(value: bytes)... | lang/api.python.langchain.com/en/latest/_modules/typing.html |
356e2cfe11ce-60 | return []
mod_dict = _overload_registry[f.__module__]
if f.__qualname__ not in mod_dict:
return []
return list(mod_dict[f.__qualname__].values())
def clear_overloads():
"""Clear all overloads in the registry."""
_overload_registry.clear()
def final(f):
"""Decorator to indicate final meth... | lang/api.python.langchain.com/en/latest/_modules/typing.html |
356e2cfe11ce-61 | VT = TypeVar('VT') # Value type.
T_co = TypeVar('T_co', covariant=True) # Any type covariant containers.
V_co = TypeVar('V_co', covariant=True) # Any type covariant containers.
VT_co = TypeVar('VT_co', covariant=True) # Value type covariant containers.
T_contra = TypeVar('T_contra', contravariant=True) # Ditto con... | lang/api.python.langchain.com/en/latest/_modules/typing.html |
356e2cfe11ce-62 | Callable.__doc__ = \
"""Deprecated alias to collections.abc.Callable.
Callable[[int], str] signifies a function that takes a single
parameter of type int and returns a str.
The subscription syntax must always be used with exactly two
values: the argument list and the return type.
The argument li... | lang/api.python.langchain.com/en/latest/_modules/typing.html |
356e2cfe11ce-63 | """
List = _alias(list, 1, inst=False, name='List')
Deque = _alias(collections.deque, 1, name='Deque')
Set = _alias(set, 1, inst=False, name='Set')
FrozenSet = _alias(frozenset, 1, inst=False, name='FrozenSet')
MappingView = _alias(collections.abc.MappingView, 1)
KeysView = _alias(collections.abc.KeysView, 1)
ItemsView... | lang/api.python.langchain.com/en/latest/_modules/typing.html |
356e2cfe11ce-64 | class ProUser(User): ...
class TeamUser(User): ...
And a function that takes a class argument that's a subclass of
User and returns an instance of the corresponding class::
U = TypeVar('U', bound=User)
def new_user(user_class: Type[U]) -> U:
user = user_class()
# ... | lang/api.python.langchain.com/en/latest/_modules/typing.html |
356e2cfe11ce-65 | pass
@runtime_checkable
class SupportsAbs(Protocol[T_co]):
"""An ABC with one abstract method __abs__ that is covariant in its return type."""
__slots__ = ()
@abstractmethod
def __abs__(self) -> T_co:
pass
@runtime_checkable
class SupportsRound(Protocol[T_co]):
"""An ABC with one abstract me... | lang/api.python.langchain.com/en/latest/_modules/typing.html |
356e2cfe11ce-66 | raise TypeError(
'can only inherit from a NamedTuple type and Generic')
bases = tuple(tuple if base is _NamedTuple else base for base in bases)
types = ns.get('__annotations__', {})
default_names = []
for field_name in types:
if field_name in ns:
... | lang/api.python.langchain.com/en/latest/_modules/typing.html |
356e2cfe11ce-67 | The resulting class has an extra __annotations__ attribute, giving a
dict that maps field names to types. (The field names are also in
the _fields attribute, which is part of the namedtuple API.)
An alternative equivalent functional syntax is also accepted::
Employee = NamedTuple('Employee', [('nam... | lang/api.python.langchain.com/en/latest/_modules/typing.html |
356e2cfe11ce-68 | generic_base = (Generic,)
else:
generic_base = ()
tp_dict = type.__new__(_TypedDictMeta, name, (*generic_base, dict), ns)
annotations = {}
own_annotations = ns.get('__annotations__', {})
msg = "TypedDict('Name', {f0: t0, f1: t1, ...}); each t must be a type"
o... | lang/api.python.langchain.com/en/latest/_modules/typing.html |
356e2cfe11ce-69 | tp_dict.__total__ = total
return tp_dict
__call__ = dict # static method
def __subclasscheck__(cls, other):
# Typed dicts are only for static structural subtyping.
raise TypeError('TypedDict does not support instance and class checks')
__instancecheck__ = __subclasscheck__
def Typed... | lang/api.python.langchain.com/en/latest/_modules/typing.html |
356e2cfe11ce-70 | class Point2D(TypedDict, total=False):
x: int
y: int
This means that a Point2D TypedDict can have any of the keys omitted. A type
checker is only expected to support a literal False or True as the value of
the total argument. True is the default, and makes all items defined in the
... | lang/api.python.langchain.com/en/latest/_modules/typing.html |
356e2cfe11ce-71 | _TypedDict = type.__new__(_TypedDictMeta, 'TypedDict', (), {})
TypedDict.__mro_entries__ = lambda bases: (_TypedDict,)
@_SpecialForm
def Required(self, parameters):
"""Special typing construct to mark a TypedDict key as required.
This is mainly useful for total=False TypedDicts.
For example::
class ... | lang/api.python.langchain.com/en/latest/_modules/typing.html |
356e2cfe11ce-72 | Usage::
UserId = NewType('UserId', int)
def name_by_id(user_id: UserId) -> str:
...
UserId('user') # Fails type check
name_by_id(42) # Fails type check
name_by_id(UserId(42)) # OK
num = UserId(5) + 1 # type: int
"""
__call__ = _i... | lang/api.python.langchain.com/en/latest/_modules/typing.html |
356e2cfe11ce-73 | def __ror__(self, other):
return Union[other, self]
# Python-version-specific alias (Python 2: unicode; Python 3: str)
Text = str
# Constant that's True when type checking, but False here.
TYPE_CHECKING = False
class IO(Generic[AnyStr]):
"""Generic base class for TextIO and BinaryIO.
This is an abstract... | lang/api.python.langchain.com/en/latest/_modules/typing.html |
356e2cfe11ce-74 | pass
@abstractmethod
def readlines(self, hint: int = -1) -> List[AnyStr]:
pass
@abstractmethod
def seek(self, offset: int, whence: int = 0) -> int:
pass
@abstractmethod
def seekable(self) -> bool:
pass
@abstractmethod
def tell(self) -> int:
pass
@abstr... | lang/api.python.langchain.com/en/latest/_modules/typing.html |
356e2cfe11ce-75 | pass
@property
@abstractmethod
def line_buffering(self) -> bool:
pass
@property
@abstractmethod
def newlines(self) -> Any:
pass
@abstractmethod
def __enter__(self) -> 'TextIO':
pass
class _DeprecatedType(type):
def __getattribute__(cls, name):
if name ... | lang/api.python.langchain.com/en/latest/_modules/typing.html |
356e2cfe11ce-76 | When a static type checker encounters a call to ``reveal_type()``,
it will emit the inferred type of the argument::
x: int = 1
reveal_type(x)
Running a static type checker (e.g., mypy) on this example
will produce output similar to 'Revealed type is "builtins.int"'.
At runtime, the funct... | lang/api.python.langchain.com/en/latest/_modules/typing.html |
356e2cfe11ce-77 | class CustomerModel(ModelBase):
id: int
name: str
The ``CustomerModel`` classes defined above will
be treated by type checkers similarly to classes created with
``@dataclasses.dataclass``.
For example, type checkers will assume these classes have
``__init__`` methods that acc... | lang/api.python.langchain.com/en/latest/_modules/typing.html |
a3b43ace734b-0 | Source code for _markupbase
"""Shared support for scanning document type declarations in HTML and XHTML.
This module is used as a foundation for the html.parser module. It has no
documented public API and should not be used directly.
"""
import re
_declname_match = re.compile(r'[a-zA-Z][-_.a-zA-Z0-9]*\s*').match
_decl... | lang/api.python.langchain.com/en/latest/_modules/_markupbase.html |
a3b43ace734b-1 | if i >= j:
return j
rawdata = self.rawdata
nlines = rawdata.count("\n", i, j)
if nlines:
self.lineno = self.lineno + nlines
pos = rawdata.rindex("\n", i, j) # Should not fail
self.offset = j-(pos+1)
else:
self.offset = self.offs... | lang/api.python.langchain.com/en/latest/_modules/_markupbase.html |
a3b43ace734b-2 | n = len(rawdata)
if rawdata[j:j+2] == '--': #comment
# Locate --.*-- as the body of the comment
return self.parse_comment(i)
elif rawdata[j] == '[': #marked section
# Locate [statusWord [...arbitrary SGML...]] as the body of the marked section
# Where stat... | lang/api.python.langchain.com/en/latest/_modules/_markupbase.html |
a3b43ace734b-3 | elif c in self._decl_otherchars:
j = j + 1
elif c == "[":
# this could be handled in a separate doctype parser
if decltype == "doctype":
j = self._parse_doctype_subset(j + 1, i)
elif decltype in {"attlist", "linktype", "link... | lang/api.python.langchain.com/en/latest/_modules/_markupbase.html |
a3b43ace734b-4 | # look for MS Office ]> ending
match= _msmarkedsectionclose.search(rawdata, i+3)
else:
raise AssertionError(
'unknown status keyword %r in marked section' % rawdata[i+3:j]
)
if not match:
return -1
if report:
j = match.s... | lang/api.python.langchain.com/en/latest/_modules/_markupbase.html |
a3b43ace734b-5 | "unexpected char in internal subset (in %r)" % s
)
if (j + 2) == n:
# end of buffer; incomplete
return -1
if (j + 4) > n:
# end of buffer; incomplete
return -1
if rawdata[j... | lang/api.python.langchain.com/en/latest/_modules/_markupbase.html |
a3b43ace734b-6 | return j
self.updatepos(declstartpos, j)
raise AssertionError("unexpected char after internal subset")
else:
return -1
elif c.isspace():
j = j + 1
else:
self.updatepos(declstartpos, j)
... | lang/api.python.langchain.com/en/latest/_modules/_markupbase.html |
a3b43ace734b-7 | # an enumerated type; look for ')'
if ")" in rawdata[j:]:
j = rawdata.find(")", j) + 1
else:
return -1
while rawdata[j:j+1].isspace():
j = j + 1
if not rawdata[j:]:
# end of bu... | lang/api.python.langchain.com/en/latest/_modules/_markupbase.html |
a3b43ace734b-8 | # end of buffer; incomplete
return -1
if c == '>':
return j + 1
if c in "'\"":
m = _declstringlit_match(rawdata, j)
if not m:
return -1
j = m.end()
else:
name, j = self... | lang/api.python.langchain.com/en/latest/_modules/_markupbase.html |
a3b43ace734b-9 | # return -1 if we've reached the end of the buffer.
def _scan_name(self, i, declstartpos):
rawdata = self.rawdata
n = len(rawdata)
if i == n:
return None, -1
m = _declname_match(rawdata, i)
if m:
s = m.group()
name = s.strip()
i... | lang/api.python.langchain.com/en/latest/_modules/_markupbase.html |
93f5fd6782c0-0 | Source code for ast
"""
ast
~~~
The `ast` module helps Python applications to process trees of the Python
abstract syntax grammar. The abstract syntax itself might change with
each Python release; this module helps to find out programmatically what
the current grammar looks like and allows modi... | lang/api.python.langchain.com/en/latest/_modules/ast.html |
93f5fd6782c0-1 | major, minor = feature_version # Should be a 2-tuple.
assert major == 3
feature_version = minor
elif feature_version is None:
feature_version = -1
# Else it should be an int giving the minor version for 3.x.
return compile(source, filename, mode, flags,
_feature_v... | lang/api.python.langchain.com/en/latest/_modules/ast.html |
93f5fd6782c0-2 | return + operand
else:
return - operand
return _convert_num(node)
def _convert(node):
if isinstance(node, Constant):
return node.value
elif isinstance(node, Tuple):
return tuple(map(_convert, node.elts))
elif isinstance(node, List):... | lang/api.python.langchain.com/en/latest/_modules/ast.html |
93f5fd6782c0-3 | omitting unambiguous field names. Attributes such as line
numbers and column offsets are not dumped by default. If this is wanted,
include_attributes can be set to true. If indent is a non-negative
integer or string, then the tree will be pretty-printed with that indent
level. None (the default) sele... | lang/api.python.langchain.com/en/latest/_modules/ast.html |
93f5fd6782c0-4 | if allsimple and len(args) <= 3:
return '%s(%s)' % (node.__class__.__name__, ', '.join(args)), not args
return '%s(%s%s)' % (node.__class__.__name__, prefix, sep.join(args)), False
elif isinstance(node, list):
if not node:
return '[]', True
ret... | lang/api.python.langchain.com/en/latest/_modules/ast.html |
93f5fd6782c0-5 | col_offset attributes for every node that supports them. This is rather
tedious to fill in for generated nodes, so this helper adds these attributes
recursively where not already set, by setting them to the values of the
parent node. It works recursively starting at *node*.
"""
def _fix(node, line... | lang/api.python.langchain.com/en/latest/_modules/ast.html |
93f5fd6782c0-6 | # TypeIgnore is a special case where lineno is not an attribute
# but rather a field of the node itself.
if isinstance(child, TypeIgnore):
child.lineno = getattr(child, 'lineno', 0) + n
continue
if 'lineno' in child._attributes:
child.lineno = getattr(child, '... | lang/api.python.langchain.com/en/latest/_modules/ast.html |
93f5fd6782c0-7 | that can be uniformly removed from the second line onwards is removed.
"""
if not isinstance(node, (AsyncFunctionDef, FunctionDef, ClassDef, Module)):
raise TypeError("%r can't have docstrings" % node.__class__.__name__)
if not(node.body and isinstance(node.body[0], Expr)):
return None
n... | lang/api.python.langchain.com/en/latest/_modules/ast.html |
93f5fd6782c0-8 | return result
def get_source_segment(source, node, *, padded=False):
"""Get source code segment of the *source* that generated *node*.
If some location information (`lineno`, `end_lineno`, `col_offset`,
or `end_col_offset`) is missing, return None.
If *padded* is `True`, the first line of a multi-line s... | lang/api.python.langchain.com/en/latest/_modules/ast.html |
93f5fd6782c0-9 | while todo:
node = todo.popleft()
todo.extend(iter_child_nodes(node))
yield node
class NodeVisitor(object):
"""
A node visitor base class that walks the abstract syntax tree and calls a
visitor function for every node found. This function may return a value
which is forwarded by... | lang/api.python.langchain.com/en/latest/_modules/ast.html |
93f5fd6782c0-10 | if type_name is None:
for cls, name in _const_node_type_names.items():
if isinstance(value, cls):
type_name = name
break
if type_name is not None:
method = 'visit_' + type_name
try:
visitor = getattr(self... | lang/api.python.langchain.com/en/latest/_modules/ast.html |
93f5fd6782c0-11 | For nodes that were part of a collection of statements (that applies to all
statement nodes), the visitor may also return a list of nodes rather than
just a single node.
Usually you use the transformer like this::
node = YourTransformer().visit(node)
"""
def generic_visit(self, node):
... | lang/api.python.langchain.com/en/latest/_modules/ast.html |
93f5fd6782c0-12 | return False
if cls in _const_types:
try:
value = inst.value
except AttributeError:
return False
else:
return (
isinstance(value, _const_types[cls]) and
not isinstance(value, _const_types_... | lang/api.python.langchain.com/en/latest/_modules/ast.html |
93f5fd6782c0-13 | Str: (str,),
Bytes: (bytes,),
NameConstant: (type(None), bool),
Ellipsis: (type(...),),
}
_const_types_not = {
Num: (bool,),
}
_const_node_type_names = {
bool: 'NameConstant', # should be before int
type(None): 'NameConstant',
int: 'Num',
float: 'Num',
complex: 'Num',
str: 'Str'... | lang/api.python.langchain.com/en/latest/_modules/ast.html |
93f5fd6782c0-14 | """Deprecated AST node class. Unused in Python 3."""
class Param(expr_context):
"""Deprecated AST node class. Unused in Python 3."""
# Large float and imaginary literals get turned into infinities in the AST.
# We unparse those infinities to INFSTR.
_INFSTR = "1e" + repr(sys.float_info.max_10_exp + 1)
@_simple_en... | lang/api.python.langchain.com/en/latest/_modules/ast.html |
93f5fd6782c0-15 | ATOM = auto()
def next(self):
try:
return self.__class__(self + 1)
except ValueError:
return self
_SINGLE_QUOTES = ("'", '"')
_MULTI_QUOTES = ('"""', "'''")
_ALL_QUOTES = (*_SINGLE_QUOTES, *_MULTI_QUOTES)
class _Unparser(NodeVisitor):
"""Methods in this class recursively ... | lang/api.python.langchain.com/en/latest/_modules/ast.html |
93f5fd6782c0-16 | self.write("\n")
def fill(self, text=""):
"""Indent a piece of text and append it, according to the current
indentation level"""
self.maybe_newline()
self.write(" " * self._indent + text)
def write(self, *text):
"""Add new source parts"""
self._source.extend(te... | lang/api.python.langchain.com/en/latest/_modules/ast.html |
93f5fd6782c0-17 | def get_precedence(self, node):
return self._precedences.get(node, _Precedence.TEST)
def set_precedence(self, precedence, *nodes):
for node in nodes:
self._precedences[node] = precedence
def get_raw_docstring(self, node):
"""If a docstring node is found in the body of the *no... | lang/api.python.langchain.com/en/latest/_modules/ast.html |
93f5fd6782c0-18 | self._source = []
self.traverse(node)
return "".join(self._source)
def _write_docstring_and_traverse_body(self, node):
if (docstring := self.get_raw_docstring(node)):
self._write_docstring(docstring)
self.traverse(node.body[1:])
else:
self.traverse... | lang/api.python.langchain.com/en/latest/_modules/ast.html |
93f5fd6782c0-19 | self.write("." * (node.level or 0))
if node.module:
self.write(node.module)
self.write(" import ")
self.interleave(lambda: self.write(", "), self.traverse, node.names)
def visit_Assign(self, node):
self.fill()
for target in node.targets:
self.set_prece... | lang/api.python.langchain.com/en/latest/_modules/ast.html |
93f5fd6782c0-20 | def visit_Assert(self, node):
self.fill("assert ")
self.traverse(node.test)
if node.msg:
self.write(", ")
self.traverse(node.msg)
def visit_Global(self, node):
self.fill("global ")
self.interleave(lambda: self.write(", "), self.write, node.names)
d... | lang/api.python.langchain.com/en/latest/_modules/ast.html |
93f5fd6782c0-21 | return
self.write(" ")
self.traverse(node.exc)
if node.cause:
self.write(" from ")
self.traverse(node.cause)
def do_visit_try(self, node):
self.fill("try")
with self.block():
self.traverse(node.body)
for ex in node.handlers:
... | lang/api.python.langchain.com/en/latest/_modules/ast.html |
93f5fd6782c0-22 | self.traverse(deco)
self.fill("class " + node.name)
with self.delimit_if("(", ")", condition = node.bases or node.keywords):
comma = False
for e in node.bases:
if comma:
self.write(", ")
else:
comma = True
... | lang/api.python.langchain.com/en/latest/_modules/ast.html |
93f5fd6782c0-23 | self.traverse(node.target)
self.write(" in ")
self.traverse(node.iter)
with self.block(extra=self.get_type_comment(node)):
self.traverse(node.body)
if node.orelse:
self.fill("else")
with self.block():
self.traverse(node.orelse)
def ... | lang/api.python.langchain.com/en/latest/_modules/ast.html |
93f5fd6782c0-24 | self.interleave(lambda: self.write(", "), self.traverse, node.items)
with self.block(extra=self.get_type_comment(node)):
self.traverse(node.body)
def _str_literal_helper(
self, string, *, quote_types=_ALL_QUOTES, escape_special_whitespace=False
):
"""Helper for writing string... | lang/api.python.langchain.com/en/latest/_modules/ast.html |
93f5fd6782c0-25 | possible_quotes.sort(key=lambda q: q[0] == escaped_string[-1])
# If we're using triple quotes and we'd need to escape a final
# quote, escape it
if possible_quotes[0][0] == escaped_string[-1]:
assert len(possible_quotes[0]) == 3
escaped_string = escape... | lang/api.python.langchain.com/en/latest/_modules/ast.html |
93f5fd6782c0-26 | self._write_fstring_inner(value)
fstring_parts.append(
("".join(buffer), isinstance(value, Constant))
)
new_fstring_parts = []
quote_types = list(_ALL_QUOTES)
fallback_to_repr = False
for value, is_constant in fstring_parts:
value, new_... | lang/api.python.langchain.com/en/latest/_modules/ast.html |
93f5fd6782c0-27 | self.write(value)
elif isinstance(node, FormattedValue):
self.visit_FormattedValue(node)
else:
raise ValueError(f"Unexpected node inside JoinedStr, {node!r}")
def visit_FormattedValue(self, node):
def unparse_inner(inner):
unparser = type(self)(_avoid_back... | lang/api.python.langchain.com/en/latest/_modules/ast.html |
93f5fd6782c0-28 | )
elif self._avoid_backslashes and isinstance(value, str):
self._write_str_avoiding_backslashes(value)
else:
self.write(repr(value))
def visit_Constant(self, node):
value = node.value
if isinstance(value, tuple):
with self.delimit("(", ")"):
... | lang/api.python.langchain.com/en/latest/_modules/ast.html |
93f5fd6782c0-29 | if node.is_async:
self.write(" async for ")
else:
self.write(" for ")
self.set_precedence(_Precedence.TUPLE, node.target)
self.traverse(node.target)
self.write(" in ")
self.set_precedence(_Precedence.TEST.next(), node.iter, *node.ifs)
self.traverse... | lang/api.python.langchain.com/en/latest/_modules/ast.html |
93f5fd6782c0-30 | # see PEP 448 for details
self.write("**")
self.set_precedence(_Precedence.EXPR, v)
self.traverse(v)
else:
write_key_value_pair(k, v)
with self.delimit("{", "}"):
self.interleave(
lambda: self.write(", "), wr... | lang/api.python.langchain.com/en/latest/_modules/ast.html |
93f5fd6782c0-31 | self.traverse(node.operand)
binop = {
"Add": "+",
"Sub": "-",
"Mult": "*",
"MatMult": "@",
"Div": "/",
"Mod": "%",
"LShift": "<<",
"RShift": ">>",
"BitOr": "|",
"BitXor": "^",
"BitAnd": "&",
"FloorDiv": "//",
"Po... | lang/api.python.langchain.com/en/latest/_modules/ast.html |
93f5fd6782c0-32 | else:
left_precedence = operator_precedence
right_precedence = operator_precedence.next()
self.set_precedence(left_precedence, node.left)
self.traverse(node.left)
self.write(f" {operator} ")
self.set_precedence(right_precedence, node.right)... | lang/api.python.langchain.com/en/latest/_modules/ast.html |
93f5fd6782c0-33 | operator_precedence = operator_precedence.next()
self.set_precedence(operator_precedence, node)
self.traverse(node)
with self.require_parens(operator_precedence, node):
s = f" {operator} "
self.interleave(lambda: self.write(s), increasing_level_traverse, node.valu... | lang/api.python.langchain.com/en/latest/_modules/ast.html |
93f5fd6782c0-34 | self.traverse(node.value)
with self.delimit("[", "]"):
if is_non_empty_tuple(node.slice):
# parentheses can be omitted if the tuple isn't empty
self.items_view(self.traverse, node.slice.elts)
else:
self.traverse(node.slice)
def visit_St... | lang/api.python.langchain.com/en/latest/_modules/ast.html |
93f5fd6782c0-35 | if d:
self.write("=")
self.traverse(d)
if index == len(node.posonlyargs):
self.write(", /")
# varargs, or bare '*' if no varargs but keyword-only arguments present
if node.vararg or node.kwonlyargs:
if first:
first =... | lang/api.python.langchain.com/en/latest/_modules/ast.html |
93f5fd6782c0-36 | if buffer:
self.write(" ", *buffer)
self.write(": ")
self.set_precedence(_Precedence.TEST, node.body)
self.traverse(node.body)
def visit_alias(self, node):
self.write(node.name)
if node.asname:
self.write(" as " + node.asname)
def v... | lang/api.python.langchain.com/en/latest/_modules/ast.html |
93f5fd6782c0-37 | write_key_pattern_pair,
zip(keys, node.patterns, strict=True),
)
rest = node.rest
if rest is not None:
if keys:
self.write(", ")
self.write(f"**{rest}")
def visit_MatchClass(self, node):
self.set_preceden... | lang/api.python.langchain.com/en/latest/_modules/ast.html |
93f5fd6782c0-38 | self.interleave(lambda: self.write(" | "), self.traverse, node.patterns)
def unparse(ast_obj):
unparser = _Unparser()
return unparser.visit(ast_obj)
def main():
import argparse
parser = argparse.ArgumentParser(prog='python -m ast')
parser.add_argument('infile', type=argparse.FileType(mode='rb'), nar... | lang/api.python.langchain.com/en/latest/_modules/ast.html |
fda4fdfd093c-0 | Source code for string
"""A collection of string constants.
Public module variables:
whitespace -- a string containing all ASCII whitespace
ascii_lowercase -- a string containing all ASCII lowercase letters
ascii_uppercase -- a string containing all ASCII uppercase letters
ascii_letters -- a string containing all ASCII... | lang/api.python.langchain.com/en/latest/_modules/string.html |
fda4fdfd093c-1 | join. If the optional second argument sep is absent or None,
runs of whitespace characters are replaced by a single space
and leading and trailing whitespace are removed, otherwise
sep is used to split and join the words.
"""
return (sep or ' ').join(map(str.capitalize, s.split(sep)))
#############... | lang/api.python.langchain.com/en/latest/_modules/string.html |
fda4fdfd093c-2 | )
"""
cls.pattern = _re.compile(pattern, cls.flags | _re.VERBOSE)
def __init__(self, template):
self.template = template
# Search for $$, $identifier, ${identifier}, and any bare $'s
def _invalid(self, mo):
i = mo.start('invalid')
lines = self.template[:i].splitli... | lang/api.python.langchain.com/en/latest/_modules/string.html |
fda4fdfd093c-3 | elif kws:
mapping = _ChainMap(kws, mapping)
# Helper function for .sub()
def convert(mo):
named = mo.group('named') or mo.group('braced')
if named is not None:
try:
return str(mapping[named])
except KeyError:
... | lang/api.python.langchain.com/en/latest/_modules/string.html |
fda4fdfd093c-4 | self.pattern)
return ids
# Initialize Template.pattern. __init_subclass__() is automatically called
# only for subclasses, not for the Template class itself.
Template.__init_subclass__()
########################################################################
# the Formatter class
# see PEP 3101 for details an... | lang/api.python.langchain.com/en/latest/_modules/string.html |
fda4fdfd093c-5 | if auto_arg_index is False:
raise ValueError('cannot switch from manual field '
'specification to automatic field '
'numbering')
field_name = str(auto_arg_index)
auto_arg_ind... | lang/api.python.langchain.com/en/latest/_modules/string.html |
fda4fdfd093c-6 | if conversion is None:
return value
elif conversion == 's':
return str(value)
elif conversion == 'r':
return repr(value)
elif conversion == 'a':
return ascii(value)
raise ValueError("Unknown conversion specifier {0!s}".format(conversion))
... | lang/api.python.langchain.com/en/latest/_modules/string.html |
95552857791c-0 | All modules for which code is available
_markupbase
ast
html.parser
langchain.adapters.openai
langchain.agents.agent
langchain.agents.agent_iterator
langchain.agents.agent_toolkits.ainetwork.toolkit
langchain.agents.agent_toolkits.amadeus.toolkit
langchain.agents.agent_toolkits.azure_cognitive_services
langchain.agents... | lang/api.python.langchain.com/en/latest/_modules/index.html |
95552857791c-1 | langchain.agents.agent_toolkits.vectorstore.toolkit
langchain.agents.agent_toolkits.zapier.toolkit
langchain.agents.agent_types
langchain.agents.chat.base
langchain.agents.chat.output_parser
langchain.agents.conversational.base
langchain.agents.conversational.output_parser
langchain.agents.conversational_chat.base
lang... | lang/api.python.langchain.com/en/latest/_modules/index.html |
95552857791c-2 | langchain.callbacks.arize_callback
langchain.callbacks.arthur_callback
langchain.callbacks.clearml_callback
langchain.callbacks.comet_ml_callback
langchain.callbacks.confident_callback
langchain.callbacks.context_callback
langchain.callbacks.file
langchain.callbacks.flyte_callback
langchain.callbacks.human
langchain.ca... | lang/api.python.langchain.com/en/latest/_modules/index.html |
95552857791c-3 | langchain.chains.graph_qa.base
langchain.chains.graph_qa.cypher
langchain.chains.graph_qa.cypher_utils
langchain.chains.graph_qa.falkordb
langchain.chains.graph_qa.hugegraph
langchain.chains.graph_qa.kuzu
langchain.chains.graph_qa.nebulagraph
langchain.chains.graph_qa.neptune_cypher
langchain.chains.graph_qa.sparql
lan... | lang/api.python.langchain.com/en/latest/_modules/index.html |
95552857791c-4 | langchain.chains.router.embedding_router
langchain.chains.router.llm_router
langchain.chains.router.multi_prompt
langchain.chains.router.multi_retrieval_qa
langchain.chains.sequential
langchain.chains.sql_database.query
langchain.chains.transform
langchain.chat_loaders.base
langchain.chat_loaders.facebook_messenger
lan... | lang/api.python.langchain.com/en/latest/_modules/index.html |
95552857791c-5 | langchain.docstore.base
langchain.docstore.in_memory
langchain.docstore.wikipedia
langchain.document_loaders.acreom
langchain.document_loaders.airbyte
langchain.document_loaders.airbyte_json
langchain.document_loaders.airtable
langchain.document_loaders.apify_dataset
langchain.document_loaders.arcgis_loader
langchain.d... | lang/api.python.langchain.com/en/latest/_modules/index.html |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.