Skip to content

Commit 4ada5f8

Browse files
authored
feat: lazy import numpy like pandas (#4653)
1 parent 9ac41cc commit 4ada5f8

17 files changed

Lines changed: 25 additions & 17 deletions

File tree

examples/sushi/helper.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import typing as t
33
from datetime import datetime, timedelta
44

5-
import numpy as np
5+
import numpy as np # noqa: TID253
66

77

88
def set_seed(dt: datetime) -> None:

examples/sushi/models/items.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import typing as t
33
from datetime import datetime
44

5-
import numpy as np
5+
import numpy as np # noqa: TID253
66
import pandas as pd # noqa: TID253
77
from helper import iter_dates # type: ignore
88
from sqlglot.expressions import to_column

examples/sushi/models/order_items.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import typing as t
33
from datetime import datetime
44

5-
import numpy as np
5+
import numpy as np # noqa: TID253
66
import pandas as pd # noqa: TID253
77
from helper import iter_dates # type: ignore
88
from sqlglot import exp

examples/sushi/models/raw_marketing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import typing as t
33
from datetime import datetime
44

5-
import numpy as np
5+
import numpy as np # noqa: TID253
66
import pandas as pd # noqa: TID253
77
from sqlglot import exp
88

examples/wursthall/models/db/order_f.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import typing as t
33
from datetime import datetime
44

5-
import numpy as np
5+
import numpy as np # noqa: TID253
66
import pandas as pd # noqa: TID253
77
from models.src.shared import DATA_START_DATE_STR, set_seed # type: ignore
88
from sqlglot import parse_one

examples/wursthall/models/src/order_item_details.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from dataclasses import dataclass
44
from datetime import datetime
55

6-
import numpy as np
6+
import numpy as np # noqa: TID253
77
import pandas as pd # noqa: TID253
88
from faker import Faker
99
from models.src.shared import DATA_START_DATE_STR, iter_dates, set_seed # type: ignore

examples/wursthall/models/src/shared.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import typing as t
55
from datetime import date, timedelta
66

7-
import numpy as np
7+
import numpy as np # noqa: TID253
88
from faker import Faker
99

1010
SEED = 99999999

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,5 +275,6 @@ extend-select = ["TID"]
275275

276276
[tool.ruff.lint.flake8-tidy-imports]
277277
banned-module-level-imports = [
278-
"pandas",
278+
"pandas",
279+
"numpy",
279280
]

sqlmesh/core/console.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import logging
99
import textwrap
1010
from pathlib import Path
11-
import numpy as np
1211
from hyperscript import h
1312
from rich.console import Console as RichConsole
1413
from rich.live import Live
@@ -2497,6 +2496,7 @@ def show_linter_violations(
24972496
def _cells_match(x: t.Any, y: t.Any) -> bool:
24982497
"""Helper function to compare two cells and returns true if they're equal, handling array objects."""
24992498
import pandas as pd
2499+
import numpy as np
25002500

25012501
# Convert array-like objects to list for consistent comparison
25022502
def _normalize(val: t.Any) -> t.Any:

sqlmesh/core/engine_adapter/mssql.py

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

55
import typing as t
66

7-
import numpy as np
87
from sqlglot import exp
98

109
from sqlmesh.core.dialect import to_schema
@@ -215,6 +214,7 @@ def _df_to_source_queries(
215214
target_table: TableName,
216215
) -> t.List[SourceQuery]:
217216
import pandas as pd
217+
import numpy as np
218218

219219
assert isinstance(df, pd.DataFrame)
220220
temp_table = self._get_temp_table(target_table or "pandas")

0 commit comments

Comments
 (0)