Skip to content

Conversation

@alimcmaster1
Copy link
Member

Add Types to args for to_gbq and read_gbq.

@alimcmaster1 alimcmaster1 added the Typing type annotations, mypy/pyright type checking label Jan 3, 2020
@jreback jreback added this to the 1.0 milestone Jan 3, 2020
query: str,
project_id: Optional[str] = None,
index_col: Optional[str] = None,
col_order: Optional[List[str]] = None,
Copy link
Member

Choose a reason for hiding this comment

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

Does this explicitly need to be a List or does Sequence work as well?

Copy link
Member Author

@alimcmaster1 alimcmaster1 Jan 4, 2020

Choose a reason for hiding this comment

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

Ahh good point - tried the other basic sequence types and they throw. Since it's used to retrieve columns from a DataFrame. Like df[col_order]. So think List it is!

pandas/io/gbq.py Outdated
auth_local_webserver: bool = False,
dialect: Optional[str] = None,
location: Optional[str] = None,
configuration: Optional[Dict] = None,
Copy link
Member

Choose a reason for hiding this comment

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

Can subtypes be added for Dict here?

Copy link
Member Author

@alimcmaster1 alimcmaster1 Jan 4, 2020

Choose a reason for hiding this comment

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

Added Dict[str, Any] since it is essentially key value pairs that are sent to the GBQ api. Unsure if we can be any stricter on the values?

https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs#configuration.query

@jreback jreback merged commit 4206fd4 into pandas-dev:master Jan 4, 2020
@jreback
Copy link
Contributor

jreback commented Jan 4, 2020

thanks @alimcmaster1

you might want to push these annotations to pandas-gbq as well

@alimcmaster1
Copy link
Member Author

thanks @alimcmaster1

you might want to push these annotations to pandas-gbq as well

Thanks will do!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Typing type annotations, mypy/pyright type checking

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants