Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions bson/__init__.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Stubs for bson (Python 3)
#
# NOTE: This dynamically typed stub was automatically generated by stubgen.

import datetime
from typing import Any, BinaryIO, Iterator, List, Mapping, MutableMapping, Sequence

from bson.binary import Binary as Binary
from bson.code import Code as Code
from bson.codec_options import CodecOptions as CodecOptions
from bson.dbref import DBRef as DBRef
from bson.decimal128 import Decimal128 as Decimal128
from bson.errors import (InvalidBSON as InvalidBSON,
InvalidDocument as InvalidDocument,
InvalidStringData as InvalidStringData)
from bson.int64 import Int64 as Int64
from bson.max_key import MaxKey as MaxKey
from bson.min_key import MinKey as MinKey
from bson.objectid import ObjectId as ObjectId
from bson.regex import Regex as Regex
from bson.son import SON as SON
from bson.timestamp import Timestamp as Timestamp
from bson.tz_util import utc as utc

EPOCH_AWARE: datetime.datetime
EPOCH_NAIVE: datetime.datetime
BSONNUM: bytes
BSONSTR: bytes
BSONOBJ: bytes
BSONARR: bytes
BSONBIN: bytes
BSONUND: bytes
BSONOID: bytes
BSONBOO: bytes
BSONDAT: bytes
BSONNUL: bytes
BSONRGX: bytes
BSONREF: bytes
BSONCOD: bytes
BSONSYM: bytes
BSONCWS: bytes
BSONINT: bytes
BSONTIM: bytes
BSONLON: bytes
BSONDEC: bytes
BSONMIN: bytes
BSONMAX: bytes

def gen_list_name() -> Iterator[bytes]: ...
def decode_all(data: Sequence[bytes], codec_options: CodecOptions = ...) -> List[Mapping[Any, Any]]: ...

def decode_iter(data: Sequence[bytes], codec_options: CodecOptions = ...) -> Iterator[MutableMapping[Any, Any]]: ...
def decode_file_iter(file_obj: BinaryIO, codec_options: CodecOptions = ...) -> Iterator[MutableMapping[Any, Any]]: ...
def is_valid(bson: bytes) -> bool: ...

class BSON(bytes):
@classmethod
def encode(cls, document: Mapping[Any, Any], check_keys: bool = ..., codec_options: CodecOptions = ...) -> BSON: ... # type: ignore
def decode(self, codec_options: CodecOptions = ...) -> MutableMapping[Any, Any]: ... # type: ignore

def has_c() -> bool: ...
36 changes: 36 additions & 0 deletions bson/binary.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Stubs for bson.binary (Python 3)
#
# NOTE: This dynamically typed stub was automatically generated by stubgen.

from typing import Any, Dict, Iterable, Tuple
from uuid import UUID

BINARY_SUBTYPE: int = ...
FUNCTION_SUBTYPE: int = ...
OLD_BINARY_SUBTYPE: int = ...
OLD_UUID_SUBTYPE: int = ...
UUID_SUBTYPE: int = ...
STANDARD: int = ...
PYTHON_LEGACY: int = ...
JAVA_LEGACY: int = ...
CSHARP_LEGACY: int = ...
ALL_UUID_SUBTYPES: Iterable[int] = ...
ALL_UUID_REPRESENTATIONS: Iterable[int] = ...
UUID_REPRESENTATION_NAMES: Dict[int, str] = ...
MD5_SUBTYPE: int = ...
USER_DEFINED_SUBTYPE: int = ...

class Binary(bytes):
def __new__(cls, data: bytes, subtype: int = ...) -> Binary: ...
@property
def subtype(self) -> int: ...
def __getnewargs__(self) -> Tuple[bytes, int]: ... # type: ignore
def __eq__(self, other: Any) -> bool: ...
def __hash__(self) -> int: ...
def __ne__(self, other: Any) -> bool: ...

class UUIDLegacy(Binary):
def __new__(cls, obj: UUID) -> UUIDLegacy: ...
def __getnewargs__(self) -> Tuple[UUID]: ... # type: ignore
@property
def uuid(self) -> UUID: ...
12 changes: 12 additions & 0 deletions bson/code.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Stubs for bson.code (Python 3)
#
# NOTE: This dynamically typed stub was automatically generated by stubgen.

from typing import Any, Mapping, Optional, Union

class Code(str):
def __new__(cls, code: Union[Code, str], scope: Optional[Mapping[str, Any]] = ..., **kwargs: Any) -> Code: ...
@property
def scope(self) -> Optional[Mapping[str, Any]]: ...
def __eq__(self, other: Any) -> bool: ...
def __ne__(self, other: Any) -> bool: ...
26 changes: 26 additions & 0 deletions bson/codec_options.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Stubs for bson.codec_options (Python 3)
#
# NOTE: This dynamically typed stub was automatically generated by stubgen.

import datetime
from typing import Any, NamedTuple, Optional

_options_base = NamedTuple('_options_base', [
('document_class', type),
('tz_aware', bool),
('uuid_representation', int),
('unicode_decode_error_handler', str),
('tzinfo', datetime.tzinfo),
])

class CodecOptions(_options_base):
def __new__(
cls,
document_class: type = ...,
tz_aware: bool = ...,
uuid_representation: int = ...,
unicode_decode_error_handler: str = ...,
tzinfo: Optional[datetime.tzinfo] = ...) -> CodecOptions: ...
def with_options(self, **kwargs: Any) -> CodecOptions: ...

DEFAULT_CODEC_OPTIONS: CodecOptions = ...
27 changes: 27 additions & 0 deletions bson/dbref.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Stubs for bson.dbref (Python 3)
#
# NOTE: This dynamically typed stub was automatically generated by stubgen.

from typing import Any, Mapping, Optional

from bson.son import SON

class DBRef:
def __init__(
self,
collection: str,
id: Any, database: Optional[str] = ...,
_extra: Mapping[str, Any] = ...,
**kwargs: Any) -> None: ...
@property
def collection(self) -> str: ...
@property
def id(self) -> Any: ...
@property
def database(self) -> Optional[str]: ...
def __getattr__(self, key: str) -> Any: ...
def as_doc(self) -> SON[str, Any]: ...
def __eq__(self, other: Any) -> bool: ...
def __ne__(self, other: Any) -> bool: ...
def __hash__(self) -> int: ...
def __deepcopy__(self, memo: Any) -> DBRef: ...
18 changes: 18 additions & 0 deletions bson/decimal128.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Stubs for bson.decimal128 (Python 3)
#
# NOTE: This dynamically typed stub was automatically generated by stubgen.

import decimal
from typing import Any, Union

def create_decimal128_context() -> decimal.Context: ...

class Decimal128:
def __init__(self, value: Union[str, decimal.Decimal]) -> None: ...
def to_decimal(self) -> decimal.Decimal: ...
@classmethod
def from_bid(cls, value: bytes) -> Decimal128: ...
@property
def bid(self) -> bytes: ...
def __eq__(self, other: Any) -> bool: ...
def __ne__(self, other: Any) -> bool: ...
9 changes: 9 additions & 0 deletions bson/errors.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Stubs for bson.errors (Python 3)
#
# NOTE: This dynamically typed stub was automatically generated by stubgen.

class BSONError(Exception): ...
class InvalidBSON(BSONError): ...
class InvalidStringData(BSONError): ...
class InvalidDocument(BSONError): ...
class InvalidId(BSONError): ...
7 changes: 7 additions & 0 deletions bson/int64.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Stubs for bson.int64 (Python 3)
#
# NOTE: This dynamically typed stub was automatically generated by stubgen.

long = int

class Int64(long): ...
42 changes: 42 additions & 0 deletions bson/json_util.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Stubs for bson.json_util (Python 3)
#
# NOTE: This dynamically typed stub was automatically generated by stubgen.

from bson.codec_options import CodecOptions
from typing import Any

class DatetimeRepresentation:
LEGACY: int = ...
NUMBERLONG: int = ...
ISO8601: int = ...

class JSONMode:
LEGACY: int = ...
RELAXED: int = ...
CANONICAL: int = ...

class JSONOptions(CodecOptions):
json_mode: int = ...
strict_number_long: bool = ...
datetime_representation: int = ...
strict_uuid: bool = ...
def __new__(
cls,
strict_number_long: bool = ...,
datetime_representation: int = ...,
strict_uuid: bool = ...,
json_mode: int = ...,
*args: Any,
**kwargs: Any) -> JSONOptions: ...

LEGACY_JSON_OPTIONS: JSONOptions = ...
DEFAULT_JSON_OPTIONS: JSONOptions = ...
CANONICAL_JSON_OPTIONS: JSONOptions = ...
RELAXED_JSON_OPTIONS: JSONOptions = ...
STRICT_JSON_OPTIONS: JSONOptions = ...

def dumps(obj: Any, *args: Any, **kwargs: Any) -> str: ...
def loads(s: str, *args: Any, **kwargs: Any) -> Any: ...
def object_pairs_hook(pairs: Any, json_options: JSONOptions = ...) -> Any: ...
def object_hook(dct: Any, json_options: JSONOptions = ...) -> Any: ...
def default(obj: Any, json_options: JSONOptions = ...) -> Any: ...
14 changes: 14 additions & 0 deletions bson/max_key.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Stubs for bson.max_key (Python 3)
#
# NOTE: This dynamically typed stub was automatically generated by stubgen.

from typing import Any

class MaxKey:
def __eq__(self, other: Any) -> bool: ...
def __hash__(self) -> int: ...
def __ne__(self, other: Any) -> bool: ...
def __le__(self, other: Any) -> bool: ...
def __lt__(self, dummy: Any) -> bool: ...
def __ge__(self, dummy: Any) -> bool: ...
def __gt__(self, other: Any) -> bool: ...
14 changes: 14 additions & 0 deletions bson/min_key.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Stubs for bson.min_key (Python 3)
#
# NOTE: This dynamically typed stub was automatically generated by stubgen.

from typing import Any

class MinKey:
def __eq__(self, other: Any) -> bool: ...
def __hash__(self) -> int: ...
def __ne__(self, other: Any) -> bool: ...
def __le__(self, dummy: Any) -> bool: ...
def __lt__(self, other: Any) -> bool: ...
def __ge__(self, other: Any) -> bool: ...
def __gt__(self, dummy: Any) -> bool: ...
26 changes: 26 additions & 0 deletions bson/objectid.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Stubs for bson.objectid (Python 3)
#
# NOTE: This dynamically typed stub was automatically generated by stubgen.

import datetime
from typing import Any, Optional, Union

from bson.errors import InvalidId as InvalidId

class ObjectId:
def __init__(self, oid: Optional[Union[str, ObjectId, bytes]] = ...) -> None: ...
@classmethod
def from_datetime(cls, generation_time: datetime.datetime) -> ObjectId: ...
@classmethod
def is_valid(cls, oid: Any) -> bool: ...
@property
def binary(self) -> bytes: ...
@property
def generation_time(self) -> datetime.datetime: ...
def __eq__(self, other: Any) -> bool: ...
def __ne__(self, other: Any) -> bool: ...
def __lt__(self, other: Any) -> bool: ...
def __le__(self, other: Any) -> bool: ...
def __gt__(self, other: Any) -> bool: ...
def __ge__(self, other: Any) -> bool: ...
def __hash__(self) -> int: ...
Empty file added bson/py.typed
Empty file.
16 changes: 16 additions & 0 deletions bson/raw_bson.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Stubs for bson.raw_bson (Python 3)
#
# NOTE: This dynamically typed stub was automatically generated by stubgen.

from typing import Any, Dict, Optional, TypeVar
from bson.codec_options import CodecOptions

_Key = TypeVar('_Key')
_Value = TypeVar('_Value')

class RawBSONDocument(Dict[_Key, _Value]):
def __init__(self, bson_bytes: bytes, codec_options: Optional[CodecOptions] = ...) -> None: ...
@property
def raw(self) -> bytes: ...

DEFAULT_RAW_BSON_OPTIONS: CodecOptions
17 changes: 17 additions & 0 deletions bson/regex.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Stubs for bson.regex (Python 3)
#
# NOTE: This dynamically typed stub was automatically generated by stubgen.

from typing import Any, Pattern, Union

def str_flags_to_int(str_flags: str) -> int: ...

class Regex:
@classmethod
def from_native(cls, regex: Pattern[str]) -> Regex: ...
pattern: Union[str, bytes] = ...
flags: int = ...
def __init__(self, pattern: Union[str, bytes], flags: int = ...) -> None: ...
def __eq__(self, other: Any) -> bool: ...
def __ne__(self, other: Any) -> bool: ...
def try_compile(self) -> Pattern[str]: ...
25 changes: 25 additions & 0 deletions bson/son.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Stubs for bson.son (Python 3)
#
# NOTE: This dynamically typed stub was automatically generated by stubgen.

from typing import Any, Dict, Iterable, Iterator, List, Mapping, Optional, Tuple, TypeVar, Union

RE_TYPE: Any

_Key = TypeVar('_Key')
_Value = TypeVar('_Value')

class SON(Dict[_Key, _Value]):
def __init__(
self,
data: Optional[Union[Mapping[_Key, _Value], Iterable[Tuple[_Key, _Value]]]] = ...,
**kwargs: _Value) -> None: ...
def __new__(cls, *args: Any, **kwargs: Any) -> SON[_Key, _Value]: ...
def copy(self) -> SON[_Key, _Value]: ...
def has_key(self, key: _Key) -> bool: ...
def iteritems(self) -> Iterator[Tuple[_Key, _Value]]: ...
def iterkeys(self) -> Iterator[_Key]: ...
def itervalues(self) -> Iterator[_Value]: ...
def setdefault(self, key: _Key, default: Optional[_Value] = ...) -> _Value: ...
def popitem(self) -> Tuple[_Key, _Value]: ...
def to_dict(self) -> Dict[_Key, _Value]: ...
23 changes: 23 additions & 0 deletions bson/timestamp.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Stubs for bson.timestamp (Python 3)
#
# NOTE: This dynamically typed stub was automatically generated by stubgen.

import datetime
from typing import Any, Union

UPPERBOUND: int

class Timestamp:
def __init__(self, time: Union[datetime.datetime, int], inc: int) -> None: ...
@property
def time(self) -> int: ...
@property
def inc(self) -> int: ...
def __eq__(self, other: Any) -> bool: ...
def __hash__(self) -> int: ...
def __ne__(self, other: Any) -> bool: ...
def __lt__(self, other: Any) -> bool: ...
def __le__(self, other: Any) -> bool: ...
def __gt__(self, other: Any) -> bool: ...
def __ge__(self, other: Any) -> bool: ...
def as_datetime(self) -> datetime.datetime: ...
Loading