Skip to content

Commit 879a8ba

Browse files
committed
Fix errors import to avoid circular dependency
1 parent 5516fdc commit 879a8ba

File tree

2 files changed

+10
-15
lines changed

2 files changed

+10
-15
lines changed

DESCRIPTION.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Source code is also available at: https://github.com/snowflakedb/snowflake-conne
1111
- Bumped numpy dependency from <2.1.0 to <=2.2.4
1212
- Added Windows support for Python 3.13.
1313
- Add `bulk_upload_chunks` parameter to `write_pandas` function. Setting this parameter to True changes the behaviour of write_pandas function to first write all the data chunks to the local disk and then perform the wildcard upload of the chunks folder to the stage. In default behaviour the chunks are being saved, uploaded and deleted one by one.
14-
- Implemented lazy import for pandas to improve module loading performance.
14+
- Implemented lazy import for pandas to improve loading performance.
1515

1616

1717
- v3.15.1(May 20, 2025)

src/snowflake/connector/options.py

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ class MissingOptionalDependency:
3232

3333
def __getattr__(self, item):
3434
from . import errors
35+
3536
raise errors.MissingDependencyError(self._dep_name)
3637

3738

@@ -60,13 +61,6 @@ def warn_incompatible_dep(
6061
)
6162

6263

63-
def pandas():
64-
try:
65-
return importlib.import_module("pandas")
66-
except ImportError:
67-
return MissingPandas()
68-
69-
7064
def _import_or_missing_pandas_option() -> (
7165
tuple[ModuleLikeObject, ModuleLikeObject, bool]
7266
):
@@ -139,13 +133,6 @@ def _import_or_missing_keyring_option() -> tuple[ModuleLikeObject, bool]:
139133

140134

141135
# Create actual constants to be imported from this file
142-
try:
143-
pyarrow = importlib.import_module("pyarrow")
144-
except ImportError:
145-
# Defer errors import to avoid circular dependency
146-
from . import errors
147-
raise errors.MissingDependencyError("pyarrow")
148-
149136
keyring, installed_keyring = _import_or_missing_keyring_option()
150137

151138

@@ -156,6 +143,14 @@ def __getattr__(name):
156143
except ImportError:
157144
return MissingPandas()
158145

146+
elif name == "pyarrow":
147+
try:
148+
return importlib.import_module("pyarrow")
149+
except ImportError:
150+
from . import errors
151+
152+
raise errors.MissingDependencyError("pyarrow")
153+
159154
elif name == "installed_pandas":
160155
return installed_pandas()
161156

0 commit comments

Comments
 (0)