Skip to content

Commit c19532e

Browse files
committed
Chore: Migrate from mypy to ty
ty check --fix omniload
1 parent 354a03e commit c19532e

31 files changed

Lines changed: 123 additions & 123 deletions

File tree

omniload/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import pytest
66

7-
from .main_test import DESTINATIONS, SOURCES # type: ignore
7+
from .main_test import DESTINATIONS, SOURCES
88

99

1010
def pytest_configure(config):

omniload/main.py

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -95,21 +95,21 @@ def ingest(
9595
help="The URI of the [green]source[/green]",
9696
envvar=["SOURCE_URI", "OMNILOAD_SOURCE_URI"],
9797
),
98-
], # type: ignore
98+
],
9999
dest_uri: Annotated[
100100
str,
101101
typer.Option(
102102
help="The URI of the [cyan]destination[/cyan]",
103103
envvar=["DESTINATION_URI", "OMNILOAD_DESTINATION_URI"],
104104
),
105-
], # type: ignore
105+
],
106106
source_table: Annotated[
107107
str,
108108
typer.Option(
109109
help="The table name in the [green]source[/green] to fetch",
110110
envvar=["SOURCE_TABLE", "OMNILOAD_SOURCE_TABLE"],
111111
),
112-
], # type: ignore
112+
],
113113
dest_table: Annotated[
114114
str,
115115
typer.Option(
@@ -123,170 +123,170 @@ def ingest(
123123
help="The incremental key from the table to be used for incremental strategies",
124124
envvar=["INCREMENTAL_KEY", "OMNILOAD_INCREMENTAL_KEY"],
125125
),
126-
] = None, # type: ignore
126+
] = None,
127127
incremental_strategy: Annotated[
128128
IncrementalStrategy,
129129
typer.Option(
130130
help="The incremental strategy to use",
131131
envvar=["INCREMENTAL_STRATEGY", "OMNILOAD_INCREMENTAL_STRATEGY"],
132132
),
133-
] = IncrementalStrategy.create_replace, # type: ignore
133+
] = IncrementalStrategy.create_replace,
134134
interval_start: Annotated[
135135
Optional[datetime],
136136
typer.Option(
137137
help="The start of the interval the incremental key will cover",
138138
formats=DATE_FORMATS,
139139
envvar=["INTERVAL_START", "OMNILOAD_INTERVAL_START"],
140140
),
141-
] = None, # type: ignore
141+
] = None,
142142
interval_end: Annotated[
143143
Optional[datetime],
144144
typer.Option(
145145
help="The end of the interval the incremental key will cover",
146146
formats=DATE_FORMATS,
147147
envvar=["INTERVAL_END", "OMNILOAD_INTERVAL_END"],
148148
),
149-
] = None, # type: ignore
149+
] = None,
150150
primary_key: Annotated[
151151
Optional[list[str]],
152152
typer.Option(
153153
help="The key that will be used to deduplicate the resulting table",
154154
envvar=["PRIMARY_KEY", "OMNILOAD_PRIMARY_KEY"],
155155
),
156-
] = None, # type: ignore
156+
] = None,
157157
partition_by: Annotated[
158158
Optional[str],
159159
typer.Option(
160160
help="The partition key to be used for partitioning the destination table",
161161
envvar=["PARTITION_BY", "OMNILOAD_PARTITION_BY"],
162162
),
163-
] = None, # type: ignore
163+
] = None,
164164
cluster_by: Annotated[
165165
Optional[str],
166166
typer.Option(
167167
help="The clustering key to be used for clustering the destination table, not every destination supports clustering.",
168168
envvar=["CLUSTER_BY", "OMNILOAD_CLUSTER_BY"],
169169
),
170-
] = None, # type: ignore
170+
] = None,
171171
dry_run: Annotated[
172172
Optional[bool],
173173
typer.Option(
174174
help="Display data transfer plan but don't invoke it",
175175
envvar=["DRY_RUN", "OMNILOAD_DRY_RUN"],
176176
),
177-
] = False, # type: ignore
177+
] = False,
178178
full_refresh: Annotated[
179179
bool,
180180
typer.Option(
181181
help="Ignore the state and refresh the destination table completely",
182182
envvar=["FULL_REFRESH", "OMNILOAD_FULL_REFRESH"],
183183
),
184-
] = False, # type: ignore
184+
] = False,
185185
progress: Annotated[
186186
Progress,
187187
typer.Option(
188188
help="The progress display type, must be one of 'interactive', 'log'",
189189
envvar=["PROGRESS", "OMNILOAD_PROGRESS"],
190190
),
191-
] = Progress.interactive, # type: ignore
191+
] = Progress.interactive,
192192
sql_backend: Annotated[
193193
SqlBackend,
194194
typer.Option(
195195
help="The SQL backend to use",
196196
envvar=["SQL_BACKEND", "OMNILOAD_SQL_BACKEND"],
197197
),
198-
] = SqlBackend.default, # type: ignore
198+
] = SqlBackend.default,
199199
loader_file_format: Annotated[
200200
Optional[LoaderFileFormat],
201201
typer.Option(
202202
help="The file format to use when loading data",
203203
envvar=["LOADER_FILE_FORMAT", "OMNILOAD_LOADER_FILE_FORMAT"],
204204
),
205-
] = None, # type: ignore
205+
] = None,
206206
page_size: Annotated[
207207
Optional[int],
208208
typer.Option(
209209
help="The page size to be used when fetching data from SQL sources",
210210
envvar=["PAGE_SIZE", "OMNILOAD_PAGE_SIZE"],
211211
),
212-
] = 50000, # type: ignore
212+
] = 50000,
213213
loader_file_size: Annotated[
214214
Optional[int],
215215
typer.Option(
216216
help="The file size to be used by the loader to split the data into multiple files. This can be set independent of the page size, since page size is used for fetching the data from the sources whereas this is used for the processing/loading part.",
217217
envvar=["LOADER_FILE_SIZE", "OMNILOAD_LOADER_FILE_SIZE"],
218218
),
219-
] = 100000, # type: ignore
219+
] = 100000,
220220
schema_naming: Annotated[
221221
SchemaNaming,
222222
typer.Option(
223223
help="The naming convention to use when moving the tables from source to destination. The default behavior is explained here: https://dlthub.com/docs/general-usage/schema#naming-convention",
224224
envvar=["SCHEMA_NAMING", "OMNILOAD_SCHEMA_NAMING"],
225225
),
226-
] = SchemaNaming.default, # type: ignore
226+
] = SchemaNaming.default,
227227
pipelines_dir: Annotated[
228228
Optional[str],
229229
typer.Option(
230230
help="The path to store dlt-related pipeline metadata. By default, omniload will create a temporary directory and delete it after the execution is done in order to make retries stateless.",
231231
envvar=["PIPELINES_DIR", "OMNILOAD_PIPELINES_DIR"],
232232
),
233-
] = None, # type: ignore
233+
] = None,
234234
extract_parallelism: Annotated[
235235
Optional[int],
236236
typer.Option(
237237
help="The number of parallel jobs to run for extracting data from the source, only applicable for certain sources",
238238
envvar=["EXTRACT_PARALLELISM", "OMNILOAD_EXTRACT_PARALLELISM"],
239239
),
240-
] = 5, # type: ignore
240+
] = 5,
241241
sql_reflection_level: Annotated[
242242
SqlReflectionLevel,
243243
typer.Option(
244244
help="The reflection level to use when reflecting the table schema from the source",
245245
envvar=["SQL_REFLECTION_LEVEL", "OMNILOAD_SQL_REFLECTION_LEVEL"],
246246
),
247-
] = SqlReflectionLevel.full, # type: ignore
247+
] = SqlReflectionLevel.full,
248248
sql_limit: Annotated[
249249
Optional[int],
250250
typer.Option(
251251
help="The limit to use when fetching data from the source",
252252
envvar=["SQL_LIMIT", "OMNILOAD_SQL_LIMIT"],
253253
),
254-
] = None, # type: ignore
254+
] = None,
255255
sql_exclude_columns: Annotated[
256256
Optional[list[str]],
257257
typer.Option(
258258
help="The columns to exclude from the source table",
259259
envvar=["SQL_EXCLUDE_COLUMNS", "OMNILOAD_SQL_EXCLUDE_COLUMNS"],
260260
),
261-
] = [], # type: ignore
261+
] = [],
262262
columns: Annotated[
263263
Optional[list[str]],
264264
typer.Option(
265265
help="The column types to be used for the destination table in the format of 'column_name:column_type'",
266266
envvar=["OMNILOAD_COLUMNS"],
267267
),
268-
] = None, # type: ignore
268+
] = None,
269269
yield_limit: Annotated[
270270
Optional[int],
271271
typer.Option(
272272
help="Limit the number of pages yielded from the source",
273273
envvar=["YIELD_LIMIT", "OMNILOAD_YIELD_LIMIT"],
274274
),
275-
] = None, # type: ignore
275+
] = None,
276276
staging_bucket: Annotated[
277277
Optional[str],
278278
typer.Option(
279279
help="The staging bucket to be used for the ingestion, must be prefixed with 'gs://' or 's3://'",
280280
envvar=["STAGING_BUCKET", "OMNILOAD_STAGING_BUCKET"],
281281
),
282-
] = None, # type: ignore
282+
] = None,
283283
mask: Annotated[
284284
Optional[list[str]],
285285
typer.Option(
286286
help="Column masking configuration in format 'column:algorithm[:param]'. Can be specified multiple times.",
287287
envvar=["MASK", "OMNILOAD_MASK"],
288288
),
289-
] = [], # type: ignore
289+
] = [],
290290
):
291291
import hashlib
292292
import tempfile
@@ -472,7 +472,7 @@ def parse_columns(columns: list[str]) -> dict:
472472

473473
column_hints[key]["primary_key"] = True
474474

475-
pipeline = dlt.pipeline( # type: ignore
475+
pipeline = dlt.pipeline(
476476
pipeline_name=m.hexdigest(),
477477
destination=dlt_dest,
478478
progress=progressInstance,
@@ -657,13 +657,13 @@ def run_pipeline():
657657
table=dest_table,
658658
staging_bucket=staging_bucket,
659659
),
660-
write_disposition=write_disposition, # type: ignore
660+
write_disposition=write_disposition,
661661
primary_key=(
662662
primary_key if primary_key and len(primary_key) > 0 else None
663-
), # type: ignore
663+
),
664664
loader_file_format=(
665-
loader_file_format.value if loader_file_format is not None else None # type: ignore
666-
), # type: ignore
665+
loader_file_format.value if loader_file_format is not None else None
666+
),
667667
)
668668

669669
# Databricks concurrency error patterns that are safe to retry
@@ -796,7 +796,7 @@ def example_uris():
796796

797797
@app.command()
798798
def version():
799-
from omniload import __version__ # type: ignore
799+
from omniload import __version__
800800

801801
print(f"v{__version__}")
802802

omniload/main_test.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -23,28 +23,28 @@
2323

2424
import duckdb
2525
import numpy as np
26-
import pandas as pd # type: ignore
26+
import pandas as pd
2727
import pendulum
28-
import pyarrow as pa # type: ignore
29-
import pyarrow.csv # type: ignore
30-
import pyarrow.ipc as ipc # type: ignore
31-
import pyarrow.parquet as pya_parquet # type: ignore
28+
import pyarrow as pa
29+
import pyarrow.csv
30+
import pyarrow.ipc as ipc
31+
import pyarrow.parquet as pya_parquet
3232
import pytest
3333
import requests
3434
import sqlalchemy
35-
from confluent_kafka import Producer # type: ignore
35+
from confluent_kafka import Producer
3636
from dlt.sources.filesystem import glob_files
3737
from elasticsearch import Elasticsearch
38-
from fsspec.implementations.memory import MemoryFileSystem # type: ignore
38+
from fsspec.implementations.memory import MemoryFileSystem
3939
from sqlalchemy.pool import NullPool
40-
from testcontainers.clickhouse import ClickHouseContainer # type: ignore
41-
from testcontainers.core.container import DockerContainer # type: ignore
42-
from testcontainers.core.waiting_utils import wait_for_logs # type: ignore
43-
from testcontainers.kafka import KafkaContainer # type: ignore
44-
from testcontainers.localstack import LocalStackContainer # type: ignore
45-
from testcontainers.mongodb import MongoDbContainer # type: ignore
46-
from testcontainers.mysql import MySqlContainer # type: ignore
47-
from testcontainers.postgres import PostgresContainer # type: ignore
40+
from testcontainers.clickhouse import ClickHouseContainer
41+
from testcontainers.core.container import DockerContainer
42+
from testcontainers.core.waiting_utils import wait_for_logs
43+
from testcontainers.kafka import KafkaContainer
44+
from testcontainers.localstack import LocalStackContainer
45+
from testcontainers.mongodb import MongoDbContainer
46+
from testcontainers.mysql import MySqlContainer
47+
from testcontainers.postgres import PostgresContainer
4848
from typer.testing import CliRunner
4949

5050
from omniload.main import app
@@ -737,9 +737,9 @@ def insert_documents(self, documents: list):
737737
"""Insert documents using Couchbase Python SDK from test machine."""
738738
from datetime import timedelta
739739

740-
from couchbase.auth import PasswordAuthenticator # type: ignore
741-
from couchbase.cluster import Cluster # type: ignore
742-
from couchbase.options import ClusterOptions # type: ignore
740+
from couchbase.auth import PasswordAuthenticator
741+
from couchbase.cluster import Cluster
742+
from couchbase.options import ClusterOptions
743743

744744
# Connect using SDK (from test machine to container)
745745
auth = PasswordAuthenticator(self.username, self.password)

omniload/src/arrow/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from typing import Any, Optional
22

33
import dlt
4-
import pyarrow as pa # type: ignore
4+
import pyarrow as pa
55
from dlt.common.schema.typing import TColumnNames, TTableSchemaColumns
66
from dlt.extract.items import TTableHintTemplate
77

@@ -22,7 +22,7 @@ def memory_mapped_arrow(
2222
def arrow_mmap(
2323
incremental: Optional[dlt.sources.incremental[Any]] = incremental,
2424
):
25-
import pyarrow.ipc as ipc # type: ignore
25+
import pyarrow.ipc as ipc
2626

2727
with pa.memory_map(path, "rb") as mmap:
2828
reader: ipc.RecordBatchFileReader = ipc.open_file(mmap)

omniload/src/blob_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
import pytest
55

6-
from omniload.src.blob import parse_uri # type: ignore
6+
from omniload.src.blob import parse_uri
77

88

99
@dataclass

omniload/src/chess/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ def players_games(
117117
def _get_archive(url: str) -> List[TDataItem]:
118118
try:
119119
games = get_url_with_retry(url).get("games", [])
120-
return games # type: ignore
120+
return games
121121
except requests.HTTPError as http_err:
122122
# sometimes archives are not available and the error seems to be permanent
123123
if http_err.response.status_code == 404:

omniload/src/chess/helpers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
def get_url_with_retry(url: str) -> StrAny:
2424
r = requests.get(url)
25-
return r.json() # type: ignore
25+
return r.json()
2626

2727

2828
def get_path_with_retry(path: str) -> StrAny:

omniload/src/collector/spinner.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def update(
1818
name: str,
1919
inc: int = 1,
2020
total: Optional[int] = None,
21-
message: Optional[str] = None, # type: ignore
21+
message: Optional[str] = None,
2222
label: str = "",
2323
**kwargs,
2424
) -> None:

omniload/src/destinations.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ def open_connection(self):
222222
):
223223
return super().open_connection()
224224

225-
import pyodbc # type: ignore
225+
import pyodbc
226226

227227
dsn = ";".join(
228228
[f"{k}={v}" for k, v in cfg.items() if k not in self.SKIP_CREDENTIALS]
@@ -561,7 +561,7 @@ def dlt_dest(self, uri: str, **kwargs):
561561
region_name = source_params.get("region_name", [None])[0]
562562

563563
if not access_key_id and not secret_access_key:
564-
import botocore.session # type: ignore
564+
import botocore.session
565565

566566
session = botocore.session.Session(profile=profile_name)
567567
default = session.get_credentials()

0 commit comments

Comments
 (0)