Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"setuptools",
"db-dtypes >=1.0.4,<2.0.0",
"numpy >=1.18.1",
"pandas >=1.1.4",
"pandas >=1.1.4, <3.0.0",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

While pinning the dependency here is correct, for added robustness it's good practice to also add a runtime check. This prevents issues if dependency constraints are bypassed during installation (e.g., with pip install --no-deps).

This project already has a pattern for this for the google-cloud-bigquery dependency (see lines 37-39 and the implementation in pandas_gbq/features.py).

I recommend adding a similar check for the pandas version. You could add a check in pandas_gbq/features.py to raise an ImportError if pandas>=3.0.0 is detected.

For example, you could add something like this to pandas_gbq/features.py and call it on package import:

PANDAS_MAXIMUM_VERSION = "3.0.0"

# ... in Features class ...
def pandas_check_version_is_compatible(self):
    import packaging.version
    
    max_version = packaging.version.parse(PANDAS_MAXIMUM_VERSION)
    if self.pandas_installed_version >= max_version:
        raise ImportError(
            f"pandas-gbq is not compatible with pandas>={PANDAS_MAXIMUM_VERSION}. "
            f"Installed version: {self.pandas_installed_version}"
        )

A corresponding unit test in tests/unit/test_features.py would also be needed.

"pyarrow >=4.0.0",
"pydata-google-auth >=1.5.0",
"psutil >=5.9.8",
Expand Down
Loading