Types

yadisk.types.AnyClient

Client or AsyncClient

alias of Client | AsyncClient

yadisk.types.AnyResponse

Response or AsyncResponse

alias of Response | AsyncResponse

yadisk.types.AsyncConsumeCallback

Callback function (may be asynchronous) that is invoked to consume the streamed HTTP response body

alias of Callable[[bytes], None] | Callable[[bytes], Awaitable[None]]

class yadisk.types.AsyncFileLike(*args, **kwargs)[source]

Bases: Protocol

This protocol describes the bare minimum set of required methods for an async file-like object (open in either binary or unicode mode).

async read(size: int = Ellipsis, /) str | bytes[source]

Reads size bytes or characters.

Parameters:

sizeint, number of bytes/characters to read from the file

Returns:

data that was read from the file

async seek(pos: int, whence: int = Ellipsis, /) int[source]

Performs a seek operation on a file.

Parameters:
  • posint, position to seek to

  • whenceint, 0 (seek absolute position), 1 (seek relative to current position) or 2 (seek to file’s end)

Returns:

int, absolute position within the file after the seek operation

async tell() int[source]

Returns current position within the file.

Returns:

int, current position within the file

async write(buffer: Any, /) int[source]

Writes data (contained in buffer).

Parameters:

buffer – data to be written

Returns:

the number of written bytes/characters

yadisk.types.AsyncFileOrPath

This is used to specify a source file to upload (async variant)

alias of str | bytes | BinaryIO | AsyncFileLike | Callable[[], AsyncIterator[bytes]]

yadisk.types.AsyncFileOrPathDestination

This is used to specify a destination file to download into (async variant)

alias of str | bytes | BinaryIO | BinaryAsyncFileLike

yadisk.types.AsyncOpenFileCallback

Function that is used for opening local files (async variant)

alias of Callable[[str | bytes, Literal[‘rb’] | Literal[‘wb’]], Awaitable[BinaryAsyncFileLike]] | Callable[[str | bytes, Literal[‘rb’] | Literal[‘wb’]], Awaitable[BinaryIO]]

yadisk.types.AsyncPayload

Request payload - data to be uploaded (async variant)

alias of bytes | Iterator[bytes] | AsyncIterator[bytes] | BinaryIO | BinaryAsyncFileLike

yadisk.types.AsyncSessionFactory

Function that returns an instance of AsyncSession

alias of Callable[[], AsyncSession]

yadisk.types.AsyncSessionName

Valid asynchronous session name (see Available Session Implementations)

alias of Literal[‘aiohttp’] | Literal[‘httpx’]

class yadisk.types.AvailableUntilVerbose[source]

Bases: TypedDict

Verbose information about the expiration date of a shared resource.

Variables:
  • enabledbool, whether the expiration date is enabled

  • valueint, timestamp indicating the expiration date

class yadisk.types.BinaryAsyncFileLike(*args, **kwargs)[source]

Bases: Protocol

This protocol describes the bare minimum set of required methods for an async file-like object open in binary mode.

async read(size: int = Ellipsis, /) bytes[source]

Reads size bytes.

Parameters:

sizeint, number of bytes/characters to read from the file

Returns:

data that was read from the file

async seek(pos: int, whence: int = Ellipsis, /) int[source]

Performs a seek operation on a file.

Parameters:
  • posint, position to seek to

  • whenceint, 0 (seek absolute position), 1 (seek relative to current position) or 2 (seek to file’s end)

Returns:

int, absolute position within the file after the seek operation

async tell() int[source]

Returns current position within the file.

Returns:

int, current position within the file

async write(buffer: Any, /) int[source]

Writes data (contained in buffer).

Parameters:

buffer – data to be written

Returns:

the number of written bytes

yadisk.types.ConsumeCallback

Callback function that is invoked to consume the streamed HTTP response body

alias of Callable[[bytes], None]

class yadisk.types.ExternalOrganizationIdVerbose[source]

Bases: TypedDict

Verbose information about the external organization ID of a shared resource.

Variables:
  • enabledbool, whether the external organization ID is enabled

  • valuestr, external organization ID

yadisk.types.FileOpenMode

File mode for OpenFileCallback and AsyncOpenFileCallback

alias of Literal[‘rb’] | Literal[‘wb’]

yadisk.types.FileOrPath

This is used to specify a source file to upload

alias of str | bytes | BinaryIO | Callable[[], Iterator[bytes]]

yadisk.types.FileOrPathDestination

This is used to specify a destination file to download into

alias of str | bytes | BinaryIO

yadisk.types.HTTPMethod

HTTP request method

alias of Literal[‘GET’] | Literal[‘POST’] | Literal[‘PUT’] | Literal[‘PATCH’] | Literal[‘DELETE’] | Literal[‘OPTIONS’] | Literal[‘HEAD’] | Literal[‘CONNECT’] | Literal[‘TRACE’]

yadisk.types.Headers

Type used for passing HTTP request headers

alias of Mapping[str, str]

yadisk.types.JSON

JSON data (parsed)

alias of dict | list | str | int | float | None

yadisk.types.OpenFileCallback

Function that is used for opening local files (like open)

alias of Callable[[str | bytes, Literal[‘rb’] | Literal[‘wb’]], BinaryIO]

yadisk.types.OperationStatus

Yandex.Disk’s asynchronous operation status

alias of Literal[‘in-progress’] | Literal[‘success’] | Literal[‘failed’]

class yadisk.types.PasswordVerbose[source]

Bases: TypedDict

Verbose information about the password of a shared resource.

Variables:
  • enabledbool, whether the password is enabled

  • valuestr, password to access the resource

yadisk.types.Payload

Request payload - data to be uploaded

alias of bytes | Iterator[bytes] | BinaryIO

class yadisk.types.PublicSettings[source]

Bases: TypedDict

Public settings of a shared resource. This type describes the input for requests that modify public settings. For the related response object, see PublicSettingsObject.

Variables:
  • available_untilint, timestamp indicating the expiration date of the link

  • read_onlybool, whether the resource is read-only

  • available_until_verboseAvailableUntilVerbose, verbose information about the expiration date

  • passwordstr, password to access the resource

  • password_verbosePasswordVerbose, verbose information about the password

  • external_organization_idstr, external organization ID

  • external_organization_id_verboseExternalOrganizationIdVerbose, verbose information about the external organization ID

  • accessesList[PublicSettingsAccess], list of access settings

Note

It appears that passing available_until as an empty string disables the expiration date. Similarly, password can be disabled by passing False or 0. This is not officially documented, though.

class yadisk.types.PublicSettingsAccess[source]

Bases: TypedDict

Access settings of a shared resource.

Variables:
  • macrosList[Union[Literal[“employees”], Literal[“all”]]],, specifies who has access to the shared resource, must contain only one element

  • org_idint, organization ID

  • user_idsList[str], list of user IDs

  • group_idsList[int], list of group IDs

  • department_idsList[int], list of department IDs

  • rightslist[str], list of access rights

Valid access rights:

  • write: write access

  • read: read access

  • read_without_download: read access without download

  • read_with_password: read access with password

  • read_with_password_without_download: read access with password and without download

yadisk.types.SessionFactory

Function that returns an instance of Session

alias of Callable[[], Session]

yadisk.types.SessionName

Valid session name (see Available Session Implementations)

alias of Literal[‘httpx’] | Literal[‘pycurl’] | Literal[‘requests’]

yadisk.types.TimeoutParameter

Request timeout (in seconds). Can be a single number, None or a tuple. If the timeout is specified as a tuple, then the first value is the connect timeout, and the second value is the read timeout. Otherwise, both connect and read timeouts are set to the same value. A value of None means no timeout. If the timeout’s value is ..., the default timeout is used (either settings.DEFAULT_TIMEOUT or settings.DEFAULT_UPLOAD_TIMEOUT)

alias of float | tuple[float | None, float | None] | None