repo stringclasses 454
values | file_path stringlengths 5 201 | extension stringclasses 1
value | content stringlengths 8 509k | num_lines int64 3 16.9k | size_bytes int64 8 511k |
|---|---|---|---|---|---|
pydantic | pydantic/_migration.py | .py | import sys
from collections.abc import Callable
from typing import Any
from pydantic.warnings import PydanticDeprecatedSince20
from .version import version_short
MOVED_IN_V2 = {
'pydantic.utils:version_info': 'pydantic.version:version_info',
'pydantic.error_wrappers:ValidationError': 'pydantic:ValidationErro... | 318 | 12,188 |
pydantic | pydantic/v1/types.py | .py | import abc
import math
import re
import warnings
from datetime import date
from decimal import Decimal, InvalidOperation
from enum import Enum
from pathlib import Path
from types import new_class
from typing import (
TYPE_CHECKING,
Any,
Callable,
ClassVar,
Dict,
FrozenSet,
List,
Optional... | 1,206 | 35,455 |
pydantic | pydantic/v1/annotated_types.py | .py | import sys
from typing import TYPE_CHECKING, Any, Dict, FrozenSet, NamedTuple, Type
from pydantic.v1.fields import Required
from pydantic.v1.main import BaseModel, create_model
from pydantic.v1.typing import is_typeddict, is_typeddict_special
if TYPE_CHECKING:
from typing_extensions import TypedDict
if sys.versi... | 73 | 3,157 |
pydantic | pydantic/v1/_hypothesis_plugin.py | .py | """
Register Hypothesis strategies for Pydantic custom types.
This enables fully-automatic generation of test data for most Pydantic classes.
Note that this module has *no* runtime impact on Pydantic itself; instead it
is registered as a setuptools entry point and Hypothesis will import it if
Pydantic is installed. ... | 392 | 14,847 |
pydantic | pydantic/v1/parse.py | .py | import json
import pickle
from enum import Enum
from pathlib import Path
from typing import Any, Callable, Union
from pydantic.v1.types import StrBytes
class Protocol(str, Enum):
json = 'json'
pickle = 'pickle'
def load_str_bytes(
b: StrBytes,
*,
content_type: str = None,
encoding: str = 'u... | 67 | 1,821 |
pydantic | pydantic/v1/errors.py | .py | from decimal import Decimal
from pathlib import Path
from typing import TYPE_CHECKING, Any, Callable, Sequence, Set, Tuple, Type, Union
from pydantic.v1.typing import display_as_type
if TYPE_CHECKING:
from pydantic.v1.typing import DictStrAny
# explicitly state exports to avoid "from pydantic.v1.errors import *"... | 647 | 17,726 |
pydantic | pydantic/v1/json.py | .py | import datetime
from collections import deque
from decimal import Decimal
from enum import Enum
from ipaddress import IPv4Address, IPv4Interface, IPv4Network, IPv6Address, IPv6Interface, IPv6Network
from pathlib import Path
from re import Pattern
from types import GeneratorType
from typing import Any, Callable, Dict, T... | 113 | 3,390 |
pydantic | pydantic/v1/main.py | .py | import sys
import warnings
from abc import ABCMeta
from copy import deepcopy
from enum import Enum
from functools import partial
from pathlib import Path
from types import FunctionType, prepare_class, resolve_bases
from typing import (
TYPE_CHECKING,
AbstractSet,
Any,
Callable,
ClassVar,
Dict,
... | 1,131 | 45,697 |
pydantic | pydantic/v1/utils.py | .py | import keyword
import warnings
import weakref
from collections import OrderedDict, defaultdict, deque
from copy import deepcopy
from itertools import islice, zip_longest
from types import BuiltinFunctionType, CodeType, FunctionType, GeneratorType, LambdaType, ModuleType
from typing import (
TYPE_CHECKING,
Abstr... | 808 | 26,014 |
pydantic | pydantic/v1/fields.py | .py | import copy
import re
from collections import Counter as CollectionCounter, defaultdict, deque
from collections.abc import Callable, Hashable as CollectionsHashable, Iterable as CollectionsIterable
from typing import (
TYPE_CHECKING,
Any,
Counter,
DefaultDict,
Deque,
Dict,
ForwardRef,
Fr... | 1,254 | 50,649 |
pydantic | pydantic/v1/decorator.py | .py | from functools import wraps
from typing import TYPE_CHECKING, Any, Callable, Dict, List, Mapping, Optional, Tuple, Type, TypeVar, Union, overload
from pydantic.v1 import validator
from pydantic.v1.config import Extra
from pydantic.v1.errors import ConfigError
from pydantic.v1.main import BaseModel, create_model
from p... | 265 | 10,339 |
pydantic | pydantic/v1/color.py | .py | """
Color definitions are used as per CSS3 specification:
http://www.w3.org/TR/css3-color/#svg-color
A few colors have multiple names referring to the sames colors, eg. `grey` and `gray` or `aqua` and `cyan`.
In these cases the LAST color when sorted alphabetically takes preferences,
eg. Color((0, 255, 255)).as_name... | 495 | 16,844 |
pydantic | pydantic/v1/__init__.py | .py | # flake8: noqa
from pydantic.v1 import dataclasses
from pydantic.v1.annotated_types import create_model_from_namedtuple, create_model_from_typeddict
from pydantic.v1.class_validators import root_validator, validator
from pydantic.v1.config import BaseConfig, ConfigDict, Extra
from pydantic.v1.decorator import validate_... | 132 | 2,946 |
pydantic | pydantic/v1/generics.py | .py | import functools
import operator
import sys
import types
import typing
from typing import (
TYPE_CHECKING,
Any,
ClassVar,
Dict,
ForwardRef,
Generic,
Iterator,
List,
Mapping,
Optional,
Tuple,
Type,
TypeVar,
Union,
cast,
)
from weakref import WeakKeyDictionary, ... | 401 | 17,829 |
pydantic | pydantic/v1/dataclasses.py | .py | """
The main purpose is to enhance stdlib dataclasses by adding validation
A pydantic dataclass can be generated from scratch or from a stdlib one.
Behind the scene, a pydantic dataclass is just like a regular one on which we attach
a `BaseModel` and magic methods to trigger the validation of the data.
`__init__` and ... | 501 | 18,172 |
pydantic | pydantic/v1/version.py | .py | __all__ = 'compiled', 'VERSION', 'version_info'
VERSION = '1.10.26'
try:
import cython # type: ignore
except ImportError:
compiled: bool = False
else: # pragma: no cover
try:
compiled = cython.compiled
except AttributeError:
compiled = False
def version_info() -> str:
import pl... | 39 | 1,039 |
pydantic | pydantic/v1/class_validators.py | .py | import warnings
from collections import ChainMap
from functools import partial, partialmethod, wraps
from itertools import chain
from types import FunctionType
from typing import TYPE_CHECKING, Any, Callable, Dict, Iterable, List, Optional, Set, Tuple, Type, Union, overload
from pydantic.v1.errors import ConfigError
f... | 362 | 14,672 |
pydantic | pydantic/v1/schema.py | .py | import re
import warnings
from collections import defaultdict
from dataclasses import is_dataclass
from datetime import date, datetime, time, timedelta
from decimal import Decimal
from enum import Enum
from ipaddress import IPv4Address, IPv4Interface, IPv4Network, IPv6Address, IPv6Interface, IPv6Network
from pathlib im... | 1,164 | 47,801 |
pydantic | pydantic/v1/networks.py | .py | import re
from ipaddress import (
IPv4Address,
IPv4Interface,
IPv4Network,
IPv6Address,
IPv6Interface,
IPv6Network,
_BaseAddress,
_BaseNetwork,
)
from typing import (
TYPE_CHECKING,
Any,
Collection,
Dict,
Generator,
List,
Match,
Optional,
Pattern,
... | 748 | 22,124 |
pydantic | pydantic/v1/env_settings.py | .py | import os
import warnings
from pathlib import Path
from typing import AbstractSet, Any, Callable, ClassVar, Dict, List, Mapping, Optional, Tuple, Type, Union
from pydantic.v1.config import BaseConfig, Extra
from pydantic.v1.fields import ModelField
from pydantic.v1.main import BaseModel
from pydantic.v1.types import J... | 351 | 14,105 |
pydantic | pydantic/v1/typing.py | .py | import functools
import operator
import sys
import typing
from collections.abc import Callable
from os import PathLike
from typing import ( # type: ignore
TYPE_CHECKING,
AbstractSet,
Any,
Callable as TypingCallable,
ClassVar,
Dict,
ForwardRef,
Generator,
Iterable,
List,
Mapp... | 628 | 20,102 |
pydantic | pydantic/v1/config.py | .py | import json
from enum import Enum
from typing import TYPE_CHECKING, Any, Callable, Dict, ForwardRef, Optional, Tuple, Type, Union
from typing_extensions import Literal, Protocol
from pydantic.v1.typing import AnyArgTCallable, AnyCallable
from pydantic.v1.utils import GetterDict
from pydantic.v1.version import compile... | 192 | 6,532 |
pydantic | pydantic/v1/tools.py | .py | import json
from functools import lru_cache
from pathlib import Path
from typing import TYPE_CHECKING, Any, Callable, Optional, Type, TypeVar, Union
from pydantic.v1.parse import Protocol, load_file, load_str_bytes
from pydantic.v1.types import StrBytes
from pydantic.v1.typing import display_as_type
__all__ = ('parse... | 93 | 2,881 |
pydantic | pydantic/v1/datetime_parse.py | .py | """
Functions to parse datetime objects.
We're using regular expressions rather than time.strptime because:
- They provide both validation and parsing.
- They're more flexible for datetimes.
- The date/datetime/time constructors produce friendlier error messages.
Stolen from https://raw.githubusercontent.com/django/d... | 249 | 7,724 |
pydantic | pydantic/v1/mypy.py | .py | import sys
from configparser import ConfigParser
from typing import Any, Callable, Dict, List, Optional, Set, Tuple, Type as TypingType, Union
from mypy.errorcodes import ErrorCode
from mypy.nodes import (
ARG_NAMED,
ARG_NAMED_OPT,
ARG_OPT,
ARG_POS,
ARG_STAR2,
MDEF,
Argument,
Assignment... | 950 | 38,860 |
pydantic | pydantic/v1/error_wrappers.py | .py | import json
from typing import TYPE_CHECKING, Any, Dict, Generator, List, Optional, Sequence, Tuple, Type, Union
from pydantic.v1.json import pydantic_encoder
from pydantic.v1.utils import Representation
if TYPE_CHECKING:
from typing_extensions import TypedDict
from pydantic.v1.config import BaseConfig
f... | 162 | 5,196 |
pydantic | pydantic/v1/validators.py | .py | import math
import re
from collections import OrderedDict, deque
from collections.abc import Hashable as CollectionsHashable
from datetime import date, datetime, time, timedelta
from decimal import Decimal, DecimalException
from enum import Enum, IntEnum
from ipaddress import IPv4Address, IPv4Interface, IPv4Network, IP... | 769 | 22,187 |
pydantic | pydantic/experimental/pipeline.py | .py | """Experimental pipeline API functionality. Be careful with this API, it's subject to change."""
from __future__ import annotations
import datetime
import operator
import re
from collections import deque
from collections.abc import Callable, Container
from dataclasses import dataclass
from functools import cached_pro... | 684 | 24,805 |
pydantic | pydantic/experimental/missing_sentinel.py | .py | """Experimental module exposing a function a `MISSING` sentinel."""
from pydantic_core import MISSING
__all__ = ('MISSING',)
| 6 | 127 |
pydantic | pydantic/experimental/arguments_schema.py | .py | """Experimental module exposing a function to generate a core schema that validates callable arguments."""
from __future__ import annotations
from collections.abc import Callable
from typing import Any, Literal
from pydantic_core import CoreSchema
from pydantic import ConfigDict
from pydantic._internal import _conf... | 45 | 1,866 |
pydantic | pydantic/plugin/__init__.py | .py | """!!! abstract "Usage Documentation"
[Build a Plugin](../concepts/plugins.md#build-a-plugin)
Plugin interface for Pydantic plugins, and related types.
"""
from __future__ import annotations
from collections.abc import Callable
from typing import Any, Literal, NamedTuple, TypeAlias
from pydantic_core import Cor... | 195 | 7,360 |
pydantic | pydantic/plugin/_schema_validator.py | .py | """Pluggable schema validator for pydantic."""
from __future__ import annotations
import functools
from collections.abc import Callable, Iterable
from typing import TYPE_CHECKING, Any, Literal, TypeVar
from pydantic_core import CoreConfig, CoreSchema, SchemaValidator, ValidationError
from typing_extensions import Pa... | 153 | 5,815 |
pydantic | pydantic/plugin/_loader.py | .py | from __future__ import annotations
import importlib.metadata as importlib_metadata
import os
import warnings
from collections.abc import Iterable
from typing import TYPE_CHECKING, Final
if TYPE_CHECKING:
from . import PydanticPluginProtocol
PYDANTIC_ENTRY_POINT_GROUP: Final[str] = 'pydantic'
# cache of plugins... | 59 | 2,213 |
pydantic | pydantic/deprecated/parse.py | .py | from __future__ import annotations
import json
import pickle
import warnings
from collections.abc import Callable
from enum import Enum
from pathlib import Path
from typing import TYPE_CHECKING, Any
from typing_extensions import deprecated
from ..warnings import PydanticDeprecatedSince20
if not TYPE_CHECKING:
#... | 82 | 2,538 |
pydantic | pydantic/deprecated/json.py | .py | import datetime
import warnings
from collections import deque
from collections.abc import Callable
from decimal import Decimal
from enum import Enum
from ipaddress import IPv4Address, IPv4Interface, IPv4Network, IPv6Address, IPv6Interface, IPv6Network
from pathlib import Path
from re import Pattern
from types import Ge... | 143 | 4,665 |
pydantic | pydantic/deprecated/decorator.py | .py | import warnings
from collections.abc import Callable, Mapping
from functools import wraps
from typing import TYPE_CHECKING, Any, Optional, TypeVar, Union, get_type_hints, overload
from typing_extensions import deprecated
from .._internal import _config
from ..alias_generators import to_pascal
from ..errors import Pyd... | 285 | 10,814 |
pydantic | pydantic/deprecated/copy_internals.py | .py | from __future__ import annotations as _annotations
import typing
from copy import deepcopy
from enum import Enum
from typing import Any
import typing_extensions
from .._internal import (
_model_construction,
_typing_extra,
_utils,
)
if typing.TYPE_CHECKING:
from .. import BaseModel
from .._inter... | 225 | 7,618 |
pydantic | pydantic/deprecated/class_validators.py | .py | """Old `@validator` and `@root_validator` function validators from V1."""
from __future__ import annotations as _annotations
from collections.abc import Callable
from functools import partial, partialmethod
from types import FunctionType
from typing import TYPE_CHECKING, Any, Literal, TypeAlias, TypeVar, Union, overl... | 258 | 10,303 |
pydantic | pydantic/deprecated/config.py | .py | from __future__ import annotations as _annotations
import warnings
from typing import TYPE_CHECKING, Any, Literal
from typing_extensions import deprecated
from .._internal import _config
from ..warnings import PydanticDeprecatedSince20
if not TYPE_CHECKING:
# See PyCharm issues https://youtrack.jetbrains.com/is... | 73 | 2,663 |
pydantic | pydantic/deprecated/tools.py | .py | from __future__ import annotations
import json
import warnings
from collections.abc import Callable
from typing import TYPE_CHECKING, Any, TypeVar, Union
from typing_extensions import deprecated
from ..json_schema import DEFAULT_REF_TEMPLATE, GenerateJsonSchema
from ..type_adapter import TypeAdapter
from ..warnings ... | 105 | 3,357 |
pydantic | pydantic/_internal/_utils.py | .py | """Bucket of reusable internal utilities.
This should be reduced as much as possible with functions only used in one place, moved to that place.
"""
from __future__ import annotations as _annotations
import dataclasses
import keyword
import warnings
import weakref
from collections import OrderedDict, defaultdict, de... | 434 | 15,386 |
pydantic | pydantic/_internal/_known_annotated_metadata.py | .py | from __future__ import annotations
from collections import defaultdict
from collections.abc import Iterable
from copy import copy
from functools import lru_cache, partial
from typing import TYPE_CHECKING, Any
from pydantic_core import CoreSchema, PydanticCustomError, ValidationError, to_jsonable_python
from pydantic_... | 406 | 16,894 |
pydantic | pydantic/_internal/_mock_val_ser.py | .py | from __future__ import annotations
from collections.abc import Callable, Iterator, Mapping
from typing import TYPE_CHECKING, Any, Generic, Literal, TypeVar
from pydantic_core import CoreSchema, SchemaSerializer, SchemaValidator
from ..errors import PydanticErrorCodes, PydanticUserError
from ..plugin._schema_validato... | 233 | 9,041 |
pydantic | pydantic/_internal/_namespace_utils.py | .py | from __future__ import annotations
import sys
from collections.abc import Callable, Generator, Iterator, Mapping
from contextlib import contextmanager
from functools import cached_property
from typing import Any, NamedTuple, TypeAlias, TypeVar
from typing_extensions import ParamSpec, TypeAliasType, TypeVarTuple
Glob... | 294 | 12,878 |
pydantic | pydantic/_internal/_config.py | .py | from __future__ import annotations as _annotations
import warnings
from collections.abc import Callable
from contextlib import contextmanager
from re import Pattern
from typing import (
TYPE_CHECKING,
Any,
Literal,
cast,
)
from pydantic_core import core_schema
from typing_extensions import Self
from ... | 388 | 14,172 |
pydantic | pydantic/_internal/_validators.py | .py | """Validator functions for standard library types.
Import of this module is deferred since it contains imports of many standard library modules.
"""
from __future__ import annotations as _annotations
import collections.abc
import math
import re
import typing
from collections.abc import Callable, Sequence
from decima... | 520 | 20,153 |
pydantic | pydantic/_internal/_core_utils.py | .py | from __future__ import annotations
import inspect
from collections.abc import Mapping, Sequence
from typing import TYPE_CHECKING, Any, TypeAlias, TypeGuard
from pydantic_core import CoreSchema, core_schema
from typing_extensions import get_args, get_origin # noqa: UP035
from typing_inspection import typing_objects
... | 177 | 6,537 |
pydantic | pydantic/_internal/_forward_ref.py | .py | from __future__ import annotations as _annotations
from dataclasses import dataclass
from typing import Union
@dataclass
class PydanticRecursiveRef:
type_ref: str
__name__ = 'PydanticRecursiveRef'
__hash__ = object.__hash__
def __call__(self) -> None:
"""Defining __call__ is necessary for t... | 24 | 641 |
pydantic | pydantic/_internal/_generics.py | .py | from __future__ import annotations
import operator
import sys
import types
import typing
from collections import ChainMap
from collections.abc import Generator, Mapping
from contextlib import contextmanager
from contextvars import ContextVar
from functools import reduce
from itertools import zip_longest
from types imp... | 555 | 24,587 |
pydantic | pydantic/_internal/_signature.py | .py | from __future__ import annotations
import dataclasses
from collections.abc import Callable
from inspect import Parameter, Signature
from typing import TYPE_CHECKING, Any
from pydantic_core import PydanticUndefined
from ._typing_extra import signature_no_eval
from ._utils import is_valid_identifier
if TYPE_CHECKING:... | 191 | 6,835 |
pydantic | pydantic/_internal/_repr.py | .py | """Tools to provide pretty/human-readable display of objects."""
from __future__ import annotations as _annotations
import types
from collections.abc import Callable, Collection, Generator, Iterable
from typing import TYPE_CHECKING, Any, ForwardRef, TypeAlias, cast
import typing_extensions
from typing_inspection imp... | 123 | 4,981 |
pydantic | pydantic/_internal/_git.py | .py | """Git utilities, adopted from mypy's git utilities (https://github.com/python/mypy/blob/master/mypy/git.py)."""
from __future__ import annotations
import subprocess
from pathlib import Path
def is_git_repo(dir: Path) -> bool:
"""Is the given directory version-controlled with git?"""
return dir.joinpath('.g... | 28 | 809 |
pydantic | pydantic/_internal/_schema_gather.py | .py | # pyright: reportTypedDictNotRequiredAccess=false, reportGeneralTypeIssues=false, reportArgumentType=false, reportAttributeAccessIssue=false
from __future__ import annotations
from dataclasses import dataclass, field
from typing import TypeAlias, TypedDict
from pydantic_core.core_schema import (
ComputedField,
... | 255 | 11,589 |
pydantic | pydantic/_internal/_decorators_v1.py | .py | """Logic for V1 validators, e.g. `@validator` and `@root_validator`."""
from __future__ import annotations as _annotations
from inspect import Parameter, signature
from typing import Any, TypeAlias, cast
from pydantic_core import core_schema
from typing_extensions import Protocol
from ..errors import PydanticUserEr... | 175 | 6,198 |
pydantic | pydantic/_internal/_decorators.py | .py | """Logic related to validators applied to models etc. via the `@field_validator` and `@model_validator` decorators."""
from __future__ import annotations as _annotations
import types
from collections import deque
from collections.abc import Callable, Iterable
from copy import copy
from dataclasses import dataclass, f... | 865 | 33,509 |
pydantic | pydantic/_internal/_typing_extra.py | .py | """Logic for interacting with type annotations, mostly extensions, shims and hacks to wrap Python's typing module."""
from __future__ import annotations
import re
import sys
import types
import typing
from collections.abc import Callable, MutableMapping
from functools import partial
from inspect import Signature, sig... | 492 | 20,204 |
pydantic | pydantic/_internal/_validate_call.py | .py | from __future__ import annotations as _annotations
import functools
import inspect
from collections.abc import Awaitable, Callable
from functools import partial
from typing import Any
import pydantic_core
from ..config import ConfigDict
from ..plugin._schema_validator import create_schema_validator
from ._config imp... | 142 | 5,366 |
pydantic | pydantic/_internal/_fields.py | .py | """Private logic related to fields (the `Field()` function and `FieldInfo` class), and arguments to `Annotated`."""
from __future__ import annotations as _annotations
import dataclasses
import warnings
from collections.abc import Callable, Mapping
from functools import cache
from inspect import Parameter, ismethoddes... | 887 | 39,664 |
pydantic | pydantic/_internal/_serializers.py | .py | from __future__ import annotations
import collections
import collections.abc
import typing
from typing import Any
from pydantic_core import PydanticOmit, core_schema
SEQUENCE_ORIGIN_MAP: dict[Any, Any] = {
typing.Deque: collections.deque, # noqa: UP006
collections.deque: collections.deque,
list: list,
... | 54 | 1,491 |
pydantic | pydantic/_internal/_dataclasses.py | .py | """Private logic for creating pydantic dataclasses."""
from __future__ import annotations as _annotations
import copy
import dataclasses
import sys
import warnings
from collections.abc import Generator
from contextlib import contextmanager
from functools import partial
from typing import TYPE_CHECKING, Any, ClassVar,... | 316 | 13,156 |
pydantic | pydantic/_internal/_generate_schema.py | .py | """Convert python types to pydantic-core schema."""
from __future__ import annotations as _annotations
import collections.abc
import dataclasses
import datetime
import inspect
import os
import pathlib
import re
import sys
import typing
import warnings
from collections.abc import Callable, Generator, Iterable, Iterato... | 2,980 | 141,195 |
pydantic | pydantic/_internal/_schema_generation_shared.py | .py | """Types and utility functions used by various other internal tools."""
from __future__ import annotations
from collections.abc import Callable
from typing import TYPE_CHECKING, Any, Literal
from pydantic_core import core_schema
from ..annotated_handlers import GetCoreSchemaHandler, GetJsonSchemaHandler
if TYPE_CH... | 127 | 4,869 |
pydantic | pydantic/_internal/_discriminated_union.py | .py | from __future__ import annotations as _annotations
from collections.abc import Hashable, Sequence
from typing import TYPE_CHECKING, Any, cast
from pydantic_core import CoreSchema, core_schema
from ..errors import PydanticUserError
from . import _core_utils
from ._core_utils import (
CoreSchemaField,
)
if TYPE_C... | 495 | 26,276 |
pydantic | pydantic/_internal/_docs_extraction.py | .py | """Utilities related to attribute docstring extraction."""
from __future__ import annotations
import ast
import inspect
import sys
import textwrap
from typing import Any
class DocstringVisitor(ast.NodeVisitor):
def __init__(self) -> None:
super().__init__()
self.target: str | None = None
... | 114 | 4,127 |
pydantic | pydantic/_internal/_model_construction.py | .py | """Private logic for creating models."""
from __future__ import annotations as _annotations
import operator
import sys
import typing
import warnings
import weakref
from abc import ABCMeta
from collections.abc import Callable, MutableMapping
from functools import cache, partial, wraps
from types import FunctionType
fr... | 834 | 36,661 |
pydantic | pydantic/_internal/_core_metadata.py | .py | from __future__ import annotations as _annotations
from typing import TYPE_CHECKING, Any, TypedDict, cast
from warnings import warn
if TYPE_CHECKING:
from ..config import JsonDict, JsonSchemaExtraCallable
from ._schema_generation_shared import (
GetJsonSchemaFunction,
)
class CoreMetadata(TypedD... | 98 | 5,162 |
pydantic | pydantic/_internal/_import_utils.py | .py | from functools import cache
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from pydantic import BaseModel
from pydantic.fields import FieldInfo
@cache
def import_cached_base_model() -> type['BaseModel']:
from pydantic import BaseModel
return BaseModel
@cache
def import_cached_field_info() -> t... | 21 | 402 |
pydantic | release/prepare.py | .py | """Automate the version bump and changelog update process."""
import argparse
import json
import re
import warnings
from datetime import date
from pathlib import Path
import requests
from release.shared import (
GITHUB_TOKEN,
HISTORY_FILE,
PACKAGE_VERSION_FILE,
REPO,
run_command,
)
ROOT_DIR = Pa... | 171 | 5,964 |
pydantic | release/shared.py | .py | """This module contains shared variables and functions for the release scripts."""
import subprocess
def run_command(*args: str) -> str:
"""Run a shell command and return the output."""
p = subprocess.run(args, stdout=subprocess.PIPE, check=True, encoding='utf-8')
return p.stdout.strip()
REPO = 'pydant... | 16 | 456 |
pydantic | release/push.py | .py | """Automate the release draft + PR creation process."""
import re
from pathlib import Path
from subprocess import CalledProcessError
import requests
from release.shared import (
GITHUB_TOKEN,
HISTORY_FILE,
REPO,
run_command,
)
ROOT_DIR = Path(__file__).parent.parent
HISTORY_RELEASE_HEAD_REGEX = r'^#... | 152 | 4,873 |
OpenViking | setup.py | .py | import importlib
import json
import os
import platform
import shutil
import subprocess
import sys
import sysconfig
from pathlib import Path
from setuptools import Extension, setup
from setuptools.command.build_ext import build_ext
from setuptools.command.build_py import build_py
try:
from wheel.bdist_wheel import... | 579 | 23,173 |
OpenViking | bot/demo/werewolf/start_werewolf_demo.py | .py | from __future__ import annotations
import argparse
import json
import os
import shutil
import subprocess
import sys
import time
from pathlib import Path
from typing import Any
from urllib.parse import urlparse
import httpx
PLAYER_IDS = [f"player_{i}" for i in range(1, 7)]
WEREWOLF_CHANNEL_IDS = ["god", *PLAYER_IDS]
... | 334 | 10,420 |
OpenViking | bot/demo/werewolf/werewolf_server.py | .py | """Werewolf game server with message routing and Web UI."""
import asyncio
import html
import json
import re
import time
from dataclasses import dataclass, field
from datetime import datetime
from pathlib import Path
from typing import Any, Dict, List, Optional
from urllib.parse import quote
import httpx
import typer... | 2,291 | 85,166 |
OpenViking | bot/workspace/skills/github-proxy/scripts/convert_url.py | .py | #!/usr/bin/env python3
import sys
import re
DEFAULT_PROXY = "https://githubproxy.cc"
BACKUP_PROXY = "https://ghfast.top"
GITHUB_PATTERNS = [
r"^https?://github\.com/.*",
r"^https?://raw\.githubusercontent\.com/.*",
r"^https?://gist\.github\.com/.*",
r"^https?://gist\.githubusercontent\.com/.*",
]
de... | 59 | 1,473 |
OpenViking | bot/workspace/skills/opencode/list_sessions.py | .py | #!/usr/bin/env python3
"""Test listing OpenCode sessions"""
import json
import time
from opencode_ai import Opencode
from opencode_utils import (
check_serve_status,
execute_cmd,
read_new_messages,
read_status,
write_status,
list_project,
)
from pydantic import BaseModel
print("=" * 80)
print(... | 112 | 3,213 |
OpenViking | bot/workspace/skills/opencode/opencode_utils.py | .py | #!/usr/bin/env python3
"""Simple test for opencode-ai SDK"""
import json
import os
import subprocess
import sys
import time
import traceback
from opencode_ai import Opencode
def execute_cmd(cmd):
try:
result = subprocess.run(
cmd,
shell=True,
text=True,
en... | 161 | 5,110 |
OpenViking | bot/tests/test_sandbox_file_access.py | .py | # Copyright (c) 2026 Beijing Volcano Engine Technology Co., Ltd.
# SPDX-License-Identifier: AGPL-3.0
"""Regression tests for bounded local and remote sandbox file access."""
import json
from pathlib import Path
from types import SimpleNamespace
import pytest
from vikingbot.sandbox.backends.aiosandbox import AioSandbo... | 214 | 7,528 |
OpenViking | bot/tests/test_werewolf_server_security.py | .py | # Copyright (c) 2026 Beijing Volcano Engine Technology Co., Ltd.
# SPDX-License-Identifier: AGPL-3.0
from __future__ import annotations
from pathlib import Path
from unittest.mock import patch
from fastapi.testclient import TestClient
from bot.demo.werewolf.werewolf_server import GameState, create_fastapi_app
def... | 74 | 2,621 |
OpenViking | bot/tests/test_image_tool_sandbox.py | .py | # Copyright (c) 2026 Beijing Volcano Engine Technology Co., Ltd.
# SPDX-License-Identifier: AGPL-3.0
"""Regression tests for image tool sandbox file handling."""
import base64
import importlib.util
import sys
import types
from pathlib import Path
from types import SimpleNamespace
import pytest
class _FakeSandbox:
... | 226 | 8,063 |
OpenViking | bot/tests/test_feedback_stats.py | .py | import json
import pytest
from vikingbot.observability.feedback_stats import (
FEEDBACK_STATS_SORT_FIELDS,
build_feedback_stats_display,
compute_feedback_stats,
format_feedback_stats_markdown,
format_feedback_stats_table,
select_feedback_stats,
validate_feedback_stats_sort_by,
)
def test... | 769 | 29,273 |
OpenViking | bot/tests/test_openapi_auth.py | .py | # Copyright (c) 2026 Beijing Volcano Engine Technology Co., Ltd.
# SPDX-License-Identifier: AGPL-3.0
"""Regression tests for OpenAPI HTTP auth requirements."""
import asyncio
import json
import tempfile
from pathlib import Path
from types import SimpleNamespace
import httpx
import pytest
from fastapi import FastAPI
f... | 1,587 | 58,044 |
OpenViking | bot/tests/test_sandbox_startup.py | .py | # Copyright (c) 2026 Beijing Volcano Engine Technology Co., Ltd.
# SPDX-License-Identifier: AGPL-3.0
"""Regression tests for sandbox construction and startup failures."""
import json
import sys
from pathlib import Path
import pytest
sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
from vikingbot.config.... | 55 | 1,964 |
OpenViking | bot/tests/test_minimax_provider.py | .py | # Copyright (c) 2026 Beijing Volcano Engine Technology Co., Ltd.
# SPDX-License-Identifier: AGPL-3.0
"""Tests for MiniMax provider support (MiniMax-M3, MiniMax-M2.7, MiniMax-M2.7-highspeed)."""
from urllib.parse import urlparse
from vikingbot.providers.registry import ProviderSpec, find_by_model, find_by_name
class... | 186 | 8,639 |
OpenViking | bot/tests/test_langfuse_outcome_metadata.py | .py | from vikingbot.integrations.langfuse import LangfuseClient
class _FakeGeneration:
def __init__(self, metadata=None):
self.metadata = metadata or {}
self.trace_id = "trace-123"
self.id = "obs-123"
def update(self, **kwargs):
if "metadata" in kwargs:
self.metadata = ... | 133 | 4,875 |
OpenViking | bot/tests/test_openviking_api_key_type.py | .py | import json
from pathlib import Path
from types import SimpleNamespace
import pytest
from vikingbot.agent import memory as memory_module
from vikingbot.agent.context import ContextBuilder
from vikingbot.agent.loop import _is_tool_result_success
from vikingbot.agent.memory import MemoryStore
from vikingbot.agent.tools ... | 3,366 | 115,769 |
OpenViking | bot/tests/test_channel_delivery_metadata.py | .py | # Copyright (c) 2026 Beijing Volcano Engine Technology Co., Ltd.
# SPDX-License-Identifier: AGPL-3.0
"""Regression tests for preserving channel delivery metadata."""
import sys
from pathlib import Path
from types import SimpleNamespace
import pytest
sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
from ... | 411 | 14,100 |
OpenViking | bot/tests/test_chat_functionality.py | .py | # Copyright (c) 2026 Beijing Volcano Engine Technology Co., Ltd.
# SPDX-License-Identifier: AGPL-3.0
"""Tests for vikingbot chat functionality - single message and interactive modes."""
import tempfile
from pathlib import Path
import pytest
from vikingbot.bus.events import OutboundMessage
from vikingbot.bus.queue imp... | 177 | 6,015 |
OpenViking | bot/tests/test_compile.py | .py | import asyncio
import base64
import json
from datetime import datetime, timedelta, timezone
from pathlib import Path
from types import SimpleNamespace
import pytest
from vikingbot.agent.loop import AgentIterationLimitExceeded, AgentLoop
from vikingbot.agent.tools.base import Tool, ToolContext
from vikingbot.agent.tool... | 3,580 | 121,705 |
OpenViking | bot/tests/test_outcome_evaluator.py | .py | from datetime import datetime
from vikingbot.observability.outcome import evaluate_response_outcome
def test_evaluate_response_outcome_marks_resolved_without_follow_up():
evaluation = evaluate_response_outcome(
[
{
"role": "assistant",
"content": "hello",
... | 229 | 7,115 |
OpenViking | bot/tests/test_skills_metadata.py | .py | from vikingbot.agent.skills import SkillsLoader
def test_skill_requirements_support_nested_yaml(tmp_path):
skill_dir = tmp_path / "skills" / "lark-ov-compile-progress"
skill_dir.mkdir(parents=True)
(skill_dir / "SKILL.md").write_text(
"""---
name: lark-ov-compile-progress
description: Track OV Com... | 25 | 572 |
OpenViking | bot/tests/test_image_format.py | .py | # Copyright (c) 2026 Beijing Volcano Engine Technology Co., Ltd.
# SPDX-License-Identifier: AGPL-3.0
"""Regression tests for image format detection."""
import sys
from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
from vikingbot.utils.image_format import detect_image_format # noqa... | 25 | 808 |
OpenViking | bot/tests/test_channel_sender_name.py | .py | # Copyright (c) 2026 Beijing Volcano Engine Technology Co., Ltd.
# SPDX-License-Identifier: AGPL-3.0
"""Regression tests for channel sender names."""
import json
import sys
from pathlib import Path
import pytest
sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
from vikingbot.bus.queue import MessageBus ... | 35 | 966 |
OpenViking | bot/tests/test_gateway_startup_security.py | .py | # Copyright (c) 2026 Beijing Volcano Engine Technology Co., Ltd.
# SPDX-License-Identifier: AGPL-3.0
from types import SimpleNamespace
import pytest
from vikingbot.cli import commands
class _AbortCalled(RuntimeError):
pass
class _ValidateCalled(RuntimeError):
pass
def test_gateway_rejects_non_localhost_... | 90 | 2,616 |
OpenViking | bot/tests/test_subagent_skills_context.py | .py | # Copyright (c) 2026 Beijing Volcano Engine Technology Co., Ltd.
# SPDX-License-Identifier: AGPL-3.0
"""Regression tests for subagent prompt skill loading."""
import sys
from pathlib import Path
from types import SimpleNamespace
import pytest
sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
from vikingb... | 125 | 3,447 |
OpenViking | bot/tests/test_openviking_add_resource.py | .py | from unittest.mock import AsyncMock
import pytest
from vikingbot.agent.tools.base import ToolContext
from vikingbot.agent.tools.ov_file import VikingAddResourceTool
from vikingbot.openviking_mount.ov_server import VikingClient
class _FakeClient:
def __init__(self, root_uri):
self.root_uri = root_uri
... | 73 | 2,559 |
OpenViking | bot/tests/test_agent_loop_outcome.py | .py | import sys
from datetime import datetime
from pathlib import Path
import pytest
sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
from vikingbot.agent import loop as loop_module
from vikingbot.agent.context import ContextBuilder
from vikingbot.agent.loop import AgentLoop
from vikingbot.bus.events import I... | 1,044 | 38,810 |
OpenViking | bot/tests/conftest.py | .py | # Copyright (c) 2026 Beijing Volcano Engine Technology Co., Ltd.
# SPDX-License-Identifier: AGPL-3.0
"""Global test fixtures"""
import asyncio
import shutil
from pathlib import Path
from typing import Generator
import pytest
# Test data root directory
PROJECT_ROOT = Path(__file__).parent.parent
TEST_TMP_DIR = PROJE... | 32 | 791 |
OpenViking | bot/vikingbot/__main__.py | .py | """
Entry point for running vikingbot as a module: python -m vikingbot
"""
import sys
from vikingbot.cli.commands import app
if __name__ == "__main__":
# sys.argv = sys.argv + ['gateway']
app()
| 12 | 205 |
OpenViking | bot/vikingbot/__init__.py | .py | """
vikingbot - A lightweight AI agent framework
"""
import warnings
from importlib.metadata import PackageNotFoundError
from importlib.metadata import version as _pkg_version
try:
__version__ = _pkg_version("openviking")
except PackageNotFoundError:
__version__ = "0.0.0+unknown"
__logo__ = "🐈"
# Suppress ... | 33 | 953 |
OpenViking | bot/vikingbot/sandbox/manager.py | .py | """Sandbox manager for creating and managing sandbox instances."""
from pathlib import Path
from loguru import logger
from vikingbot.config.schema import Config, SessionKey
from vikingbot.sandbox.backends import get_backend
from vikingbot.sandbox.base import SandboxBackend, UnsupportedBackendError
class SandboxMan... | 118 | 4,977 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.