Skip to main content
Version: devel

dlt.common.warnings

DltDeprecationWarning Objects

class DltDeprecationWarning(DeprecationWarning)

View source on GitHub

A dlt specific deprecation warning.

This warning is raised when using deprecated functionality in dlt. It provides information on when the deprecation was introduced and the expected version in which the corresponding functionality will be removed.

Attributes:

  • message - Description of the warning.
  • since - Version in which the deprecation was introduced.
  • expected_due - Version in which the corresponding functionality is expected to be removed.

TNoExtraKwargs Objects

class TNoExtraKwargs(typing_extensions.TypedDict)

View source on GitHub

Empty schema for a **kwargs that only collects deprecated argument names.

SkipDeprecation Objects

class SkipDeprecation()

View source on GitHub

Sentinel returned by a Deprecated.convert to write nothing to the replacement field.

Deprecated Objects

class Deprecated()

View source on GitHub

Marks a deprecation-schema field as deprecated in favor of maps_to.

Used inside Annotated[<old value type>, Deprecated(...)] in a deprecation schema consumed by apply_deprecations.

Arguments:

  • maps_to str - Name of the replacement field the old value is written to.
  • convert Callable[[Any], Any] - Maps the old value to the replacement value. Return SkipDeprecation to write nothing. Defaults to identity.
  • message Optional[str] - Custom deprecation message. Defaults to a generated one.
  • since Optional[VersionString] - Version the field was deprecated in. Overrides the default passed to apply_deprecations.
  • expected_due Optional[VersionString] - Version the field is removed in.

apply_deprecations

def apply_deprecations(deprecation_spec: typing.Type[_TypedDict],
doc: DictStrAny,
*,
path: str = ".",
since: typing.Optional[VersionString] = None,
expected_due: typing.Optional[VersionString] = None,
warn: bool = True,
remove: bool = True,
prefer_new: bool = True,
stacklevel: int = 2) -> DictStrAny

View source on GitHub

Convert deprecated keys in doc to their replacements declared in deprecation_spec.

For every Annotated[..., Deprecated(...)] field of deprecation_spec present in doc: emits a DltDeprecationWarning (unless warn is False), runs the marker's convert, writes the result under Deprecated.maps_to, and drops the old key (unless remove is False). A field typed as a nested deprecation TypedDict migrates its sub-document recursively. Mutates doc in place and returns it.

Arguments:

  • deprecation_spec _Type[TypedDict] - TypedDict whose keys are deprecated field names.
  • doc DictStrAny - Dictionary to migrate in place.
  • path str - Location label used in the warning message.
  • since Optional[VersionString] - Default deprecation version for fields without one.
  • expected_due Optional[VersionString] - Default removal version.
  • warn bool - Emit DltDeprecationWarning for each converted field.
  • remove bool - Drop the old key after conversion.
  • prefer_new bool - When both old and replacement keys are present, keep the replacement.
  • stacklevel int - warnings.warn stacklevel, points at the caller's caller by default.

Returns:

  • DictStrAny - The same doc, mutated.

This demo works on codespaces. Codespaces is a development environment available for free to anyone with a Github account. You'll be asked to fork the demo repository and from there the README guides you with further steps.
The demo uses the Continue VSCode extension.

Off to codespaces!

DHelp

Ask a question

Welcome to "Codex Central", your next-gen help center, driven by OpenAI's GPT-4 model. It's more than just a forum or a FAQ hub – it's a dynamic knowledge base where coders can find AI-assisted solutions to their pressing problems. With GPT-4's powerful comprehension and predictive abilities, Codex Central provides instantaneous issue resolution, insightful debugging, and personalized guidance. Get your code running smoothly with the unparalleled support at Codex Central - coding help reimagined with AI prowess.