Skip to content

Commit

Permalink
format codebase
Browse files Browse the repository at this point in the history
  • Loading branch information
sh-rp committed Aug 24, 2023
1 parent 49d6ba7 commit 5d20c60
Show file tree
Hide file tree
Showing 396 changed files with 14,979 additions and 7,186 deletions.
17 changes: 10 additions & 7 deletions dlt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,20 @@
For more detailed info, see https://dlthub.com/docs/walkthroughs
"""

from dlt.version import __version__
from dlt import sources
from dlt.common.configuration.accessors import config, secrets
from dlt.common.typing import TSecretValue as _TSecretValue
from dlt.common.configuration.specs import CredentialsConfiguration as _CredentialsConfiguration
from dlt.common.pipeline import source_state as state
from dlt.common.schema import Schema

from dlt import sources
from dlt.extract.decorators import source, resource, transformer, defer
from dlt.pipeline import pipeline as _pipeline, run, attach, Pipeline, dbt, current as _current, mark as _mark
from dlt.pipeline import progress
from dlt.common.typing import TSecretValue as _TSecretValue
from dlt.extract.decorators import defer, resource, source, transformer
from dlt.pipeline import Pipeline, attach
from dlt.pipeline import current as _current
from dlt.pipeline import dbt
from dlt.pipeline import mark as _mark
from dlt.pipeline import pipeline as _pipeline
from dlt.pipeline import progress, run
from dlt.version import __version__

pipeline = _pipeline
current = _current
Expand Down
446 changes: 349 additions & 97 deletions dlt/cli/_dlt.py

Large diffs are not rendered by default.

41 changes: 32 additions & 9 deletions dlt/cli/config_toml_writer.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
from typing import Any, NamedTuple, Tuple, Iterable
from collections.abc import Sequence as C_Sequence
from typing import Any, Iterable, NamedTuple, Tuple

import tomlkit
from tomlkit.items import Table as TOMLTable
from tomlkit.container import Container as TOMLContainer
from collections.abc import Sequence as C_Sequence
from tomlkit.items import Table as TOMLTable

from dlt.common import pendulum
from dlt.common.configuration.specs import BaseConfiguration, is_base_configuration_inner_hint, extract_inner_hint
from dlt.common.configuration.specs import (
BaseConfiguration,
extract_inner_hint,
is_base_configuration_inner_hint,
)
from dlt.common.data_types import py_type_to_sc_type
from dlt.common.typing import AnyType, is_final_type, is_optional_type

Expand Down Expand Up @@ -53,13 +58,15 @@ def write_value(
hint: AnyType,
overwrite_existing: bool,
default_value: Any = None,
is_default_of_interest: bool = False
is_default_of_interest: bool = False,
) -> None:
# skip if table contains the name already
if name in toml_table and not overwrite_existing:
return
# do not dump final and optional fields if they are not of special interest
if (is_final_type(hint) or is_optional_type(hint) or default_value is not None) and not is_default_of_interest:
if (
is_final_type(hint) or is_optional_type(hint) or default_value is not None
) and not is_default_of_interest:
return
# get the inner hint to generate cool examples
hint = extract_inner_hint(hint)
Expand All @@ -84,10 +91,19 @@ def write_spec(toml_table: TOMLTable, config: BaseConfiguration, overwrite_exist
default_value = getattr(config, name, None)
# check if field is of particular interest and should be included if it has default
is_default_of_interest = name in config.__config_gen_annotations__
write_value(toml_table, name, hint, overwrite_existing, default_value=default_value, is_default_of_interest=is_default_of_interest)
write_value(
toml_table,
name,
hint,
overwrite_existing,
default_value=default_value,
is_default_of_interest=is_default_of_interest,
)


def write_values(toml: TOMLContainer, values: Iterable[WritableConfigValue], overwrite_existing: bool) -> None:
def write_values(
toml: TOMLContainer, values: Iterable[WritableConfigValue], overwrite_existing: bool
) -> None:
for value in values:
toml_table: TOMLTable = toml # type: ignore
for section in value.sections:
Expand All @@ -98,4 +114,11 @@ def write_values(toml: TOMLContainer, values: Iterable[WritableConfigValue], ove
else:
toml_table = toml_table[section] # type: ignore

write_value(toml_table, value.name, value.hint, overwrite_existing, default_value=value.default_value, is_default_of_interest=True)
write_value(
toml_table,
value.name,
value.hint,
overwrite_existing,
default_value=value.default_value,
is_default_of_interest=True,
)

0 comments on commit 5d20c60

Please sign in to comment.