Skip to content

Commit ab3d46a

Browse files
committed
fix linting
1 parent f3b7afa commit ab3d46a

File tree

9 files changed

+27
-14
lines changed

9 files changed

+27
-14
lines changed

dlt/extract/resource.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ def add_limit(self, max_items: int) -> "DltResource": # noqa: A003
314314
"""
315315

316316
# make sure max_items is a number, to allow "None" as value for unlimited
317-
if max_items == None:
317+
if max_items is None:
318318
max_items = -1
319319

320320
def _gen_wrap(gen: TPipeStep) -> TPipeStep:

docs/examples/connector_x_arrow/load_arrow.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import dlt
44
from dlt.sources.credentials import ConnectionStringCredentials
55

6+
67
def read_sql_x(
78
conn_str: ConnectionStringCredentials = dlt.secrets.value,
89
query: str = dlt.config.value,
@@ -14,6 +15,7 @@ def read_sql_x(
1415
protocol="binary",
1516
)
1617

18+
1719
def genome_resource():
1820
# create genome resource with merge on `upid` primary key
1921
genome = dlt.resource(

docs/examples/google_sheets/google_sheets.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,15 @@
99
)
1010
from dlt.common.typing import DictStrAny, StrAny
1111

12+
1213
def _initialize_sheets(
1314
credentials: Union[GcpOAuthCredentials, GcpServiceAccountCredentials]
1415
) -> Any:
1516
# Build the service object.
1617
service = build("sheets", "v4", credentials=credentials.to_native_credentials())
1718
return service
1819

20+
1921
@dlt.source
2022
def google_spreadsheet(
2123
spreadsheet_id: str,
@@ -55,6 +57,7 @@ def get_sheet(sheet_name: str) -> Iterator[DictStrAny]:
5557
for name in sheet_names
5658
]
5759

60+
5861
if __name__ == "__main__":
5962
pipeline = dlt.pipeline(destination="duckdb")
6063
# see example.secrets.toml to where to put credentials
@@ -67,4 +70,4 @@ def get_sheet(sheet_name: str) -> Iterator[DictStrAny]:
6770
sheet_names=range_names,
6871
)
6972
)
70-
print(info)
73+
print(info)

docs/examples/incremental_loading/zendesk.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,11 @@
66
from dlt.common.typing import TAnyDateTime
77
from dlt.sources.helpers.requests import client
88

9+
910
@dlt.source(max_table_nesting=2)
1011
def zendesk_support(
1112
credentials: Dict[str, str] = dlt.secrets.value,
12-
start_date: Optional[TAnyDateTime] = pendulum.datetime( # noqa: B008
13-
year=2000, month=1, day=1
14-
),
13+
start_date: Optional[TAnyDateTime] = pendulum.datetime(year=2000, month=1, day=1), # noqa: B008
1514
end_date: Optional[TAnyDateTime] = None,
1615
):
1716
"""
@@ -113,11 +112,12 @@ def get_pages(
113112
if not response_json["end_of_stream"]:
114113
get_url = response_json["next_page"]
115114

115+
116116
if __name__ == "__main__":
117117
# create dlt pipeline
118118
pipeline = dlt.pipeline(
119119
pipeline_name="zendesk", destination="duckdb", dataset_name="zendesk_data"
120120
)
121121

122122
load_info = pipeline.run(zendesk_support())
123-
print(load_info)
123+
print(load_info)

docs/examples/nested_data/nested_data.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
CHUNK_SIZE = 10000
1515

16+
1617
# You can limit how deep dlt goes when generating child tables.
1718
# By default, the library will descend and generate child tables
1819
# for all nested lists, without a limit.
@@ -81,6 +82,7 @@ def load_documents(self) -> Iterator[TDataItem]:
8182
while docs_slice := list(islice(cursor, CHUNK_SIZE)):
8283
yield map_nested_in_place(convert_mongo_objs, docs_slice)
8384

85+
8486
def convert_mongo_objs(value: Any) -> Any:
8587
if isinstance(value, (ObjectId, Decimal128)):
8688
return str(value)

docs/examples/pdf_to_weaviate/pdf_to_weaviate.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from dlt.destinations.impl.weaviate import weaviate_adapter
55
from PyPDF2 import PdfReader
66

7+
78
@dlt.resource(selected=False)
89
def list_files(folder_path: str):
910
folder_path = os.path.abspath(folder_path)
@@ -15,6 +16,7 @@ def list_files(folder_path: str):
1516
"mtime": os.path.getmtime(file_path),
1617
}
1718

19+
1820
@dlt.transformer(primary_key="page_id", write_disposition="merge")
1921
def pdf_to_text(file_item, separate_pages: bool = False):
2022
if not separate_pages:
@@ -28,6 +30,7 @@ def pdf_to_text(file_item, separate_pages: bool = False):
2830
page_item["page_id"] = file_item["file_name"] + "_" + str(page_no)
2931
yield page_item
3032

33+
3134
pipeline = dlt.pipeline(pipeline_name="pdf_to_text", destination="weaviate")
3235

3336
# this constructs a simple pipeline that: (1) reads files from "invoices" folder (2) filters only those ending with ".pdf"
@@ -51,4 +54,4 @@ def pdf_to_text(file_item, separate_pages: bool = False):
5154

5255
client = weaviate.Client("http://localhost:8080")
5356
# get text of all the invoices in InvoiceText class we just created above
54-
print(client.query.get("InvoiceText", ["text", "file_name", "mtime", "page_id"]).do())
57+
print(client.query.get("InvoiceText", ["text", "file_name", "mtime", "page_id"]).do())

docs/examples/qdrant_zendesk/qdrant.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,12 @@
1010

1111
from dlt.common.configuration.inject import with_config
1212

13+
1314
# function from: https://github.com/dlt-hub/verified-sources/tree/master/sources/zendesk
1415
@dlt.source(max_table_nesting=2)
1516
def zendesk_support(
1617
credentials: Dict[str, str] = dlt.secrets.value,
17-
start_date: Optional[TAnyDateTime] = pendulum.datetime( # noqa: B008
18-
year=2000, month=1, day=1
19-
),
18+
start_date: Optional[TAnyDateTime] = pendulum.datetime(year=2000, month=1, day=1), # noqa: B008
2019
end_date: Optional[TAnyDateTime] = None,
2120
):
2221
"""
@@ -80,13 +79,15 @@ def _parse_date_or_none(value: Optional[str]) -> Optional[pendulum.DateTime]:
8079
return None
8180
return ensure_pendulum_datetime(value)
8281

82+
8383
# modify dates to return datetime objects instead
8484
def _fix_date(ticket):
8585
ticket["updated_at"] = _parse_date_or_none(ticket["updated_at"])
8686
ticket["created_at"] = _parse_date_or_none(ticket["created_at"])
8787
ticket["due_at"] = _parse_date_or_none(ticket["due_at"])
8888
return ticket
8989

90+
9091
# function from: https://github.com/dlt-hub/verified-sources/tree/master/sources/zendesk
9192
def get_pages(
9293
url: str,
@@ -127,6 +128,7 @@ def get_pages(
127128
if not response_json["end_of_stream"]:
128129
get_url = response_json["next_page"]
129130

131+
130132
if __name__ == "__main__":
131133
# create a pipeline with an appropriate name
132134
pipeline = dlt.pipeline(
@@ -146,7 +148,6 @@ def get_pages(
146148

147149
print(load_info)
148150

149-
150151
# running the Qdrant client to connect to your Qdrant database
151152

152153
@with_config(sections=("destination", "qdrant", "credentials"))

docs/examples/transformers/pokemon.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import dlt
22
from dlt.sources.helpers import requests
33

4+
45
@dlt.source(max_table_nesting=2)
56
def source(pokemon_api_url: str):
67
""""""
@@ -46,6 +47,7 @@ def species(pokemon_details):
4647

4748
return (pokemon_list | pokemon, pokemon_list | pokemon | species)
4849

50+
4951
if __name__ == "__main__":
5052
# build duck db pipeline
5153
pipeline = dlt.pipeline(
@@ -54,4 +56,4 @@ def species(pokemon_details):
5456

5557
# the pokemon_list resource does not need to be loaded
5658
load_info = pipeline.run(source("https://pokeapi.co/api/v2/pokemon"))
57-
print(load_info)
59+
print(load_info)

tests/extract/test_sources.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -792,7 +792,7 @@ def test_limit_infinite_counter() -> None:
792792

793793
@pytest.mark.parametrize("limit", (None, -1, 0, 10))
794794
def test_limit_edge_cases(limit: int) -> None:
795-
r = dlt.resource(range(20), name="infinity").add_limit(limit)
795+
r = dlt.resource(range(20), name="infinity").add_limit(limit) # type: ignore
796796

797797
@dlt.resource()
798798
async def r_async():
@@ -812,7 +812,7 @@ async def r_async():
812812
elif limit == 0:
813813
assert sync_list == []
814814
else:
815-
assert False
815+
raise AssertionError(f"Unexpected limit: {limit}")
816816

817817

818818
def test_limit_source() -> None:

0 commit comments

Comments
 (0)