Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Type annotation incorrect for job_config argument(s) #1605

@tswast

Description

@tswast

To make mypy happy when I have an optional job_config, I'm having to write code like this:

        if job_config is not None:
            query_job = self.bqclient.query(sql, job_config=job_config)
        else:
            query_job = self.bqclient.query(sql)

This if/else should be unnecessary, but mypy complains that job_config argument to query can't be None.

The root cause is that the type annotation is only QueryJobConfig

job_config: QueryJobConfig = None,

It should be Optional[QueryJobConfig].

This same issue occurs in copy_table and extract_table.

Metadata

Metadata

Assignees

No one assigned

    Labels

    api: bigqueryIssues related to the googleapis/python-bigquery API.priority: p3Desirable enhancement or fix. May not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions