diff --git a/google/cloud/bigquery/client.py b/google/cloud/bigquery/client.py index e17d6b8da..496015b21 100644 --- a/google/cloud/bigquery/client.py +++ b/google/cloud/bigquery/client.py @@ -2182,12 +2182,12 @@ def list_jobs( parent_job: Optional[Union[QueryJob, str]] = None, max_results: Optional[int] = None, page_token: Optional[str] = None, - all_users: bool = None, + all_users: Optional[bool] = None, state_filter: Optional[str] = None, retry: retries.Retry = DEFAULT_RETRY, timeout: TimeoutType = DEFAULT_TIMEOUT, - min_creation_time: datetime.datetime = None, - max_creation_time: datetime.datetime = None, + min_creation_time: Optional[datetime.datetime] = None, + max_creation_time: Optional[datetime.datetime] = None, page_size: Optional[int] = None, ) -> page_iterator.Iterator: """List jobs for the project associated with this client. @@ -3407,7 +3407,7 @@ def insert_rows( self, table: Union[Table, TableReference, str], rows: Union[Iterable[Tuple], Iterable[Mapping[str, Any]]], - selected_fields: Sequence[SchemaField] = None, + selected_fields: Optional[Sequence[SchemaField]] = None, **kwargs, ) -> Sequence[Dict[str, Any]]: """Insert rows into a table via the streaming API. @@ -3483,7 +3483,7 @@ def insert_rows_from_dataframe( self, table: Union[Table, TableReference, str], dataframe, - selected_fields: Sequence[SchemaField] = None, + selected_fields: Optional[Sequence[SchemaField]] = None, chunk_size: int = 500, **kwargs: Dict, ) -> Sequence[Sequence[dict]]: @@ -3546,8 +3546,8 @@ def insert_rows_json( row_ids: Union[ Iterable[Optional[str]], AutoRowIDs, None ] = AutoRowIDs.GENERATE_UUID, - skip_invalid_rows: bool = None, - ignore_unknown_values: bool = None, + skip_invalid_rows: Optional[bool] = None, + ignore_unknown_values: Optional[bool] = None, template_suffix: Optional[str] = None, retry: retries.Retry = DEFAULT_RETRY, timeout: TimeoutType = DEFAULT_TIMEOUT, @@ -3738,7 +3738,7 @@ def list_partitions( def list_rows( self, table: Union[Table, TableListItem, TableReference, str], - selected_fields: Sequence[SchemaField] = None, + selected_fields: Optional[Sequence[SchemaField]] = None, max_results: Optional[int] = None, page_token: Optional[str] = None, start_index: Optional[int] = None, @@ -3851,7 +3851,7 @@ def _list_rows_from_query_results( project: str, schema: SchemaField, total_rows: Optional[int] = None, - destination: Union[Table, TableReference, TableListItem, str] = None, + destination: Optional[Union[Table, TableReference, TableListItem, str]] = None, max_results: Optional[int] = None, start_index: Optional[int] = None, page_size: Optional[int] = None, diff --git a/google/cloud/bigquery/job/query.py b/google/cloud/bigquery/job/query.py index 7de209b8d..57186acbc 100644 --- a/google/cloud/bigquery/job/query.py +++ b/google/cloud/bigquery/job/query.py @@ -1693,7 +1693,7 @@ def to_arrow( def to_dataframe( self, bqstorage_client: Optional["bigquery_storage.BigQueryReadClient"] = None, - dtypes: Dict[str, Any] = None, + dtypes: Optional[Dict[str, Any]] = None, progress_bar_type: Optional[str] = None, create_bqstorage_client: bool = True, max_results: Optional[int] = None, @@ -1879,7 +1879,7 @@ def to_dataframe( def to_geodataframe( self, bqstorage_client: Optional["bigquery_storage.BigQueryReadClient"] = None, - dtypes: Dict[str, Any] = None, + dtypes: Optional[Dict[str, Any]] = None, progress_bar_type: Optional[str] = None, create_bqstorage_client: bool = True, max_results: Optional[int] = None, diff --git a/google/cloud/bigquery/table.py b/google/cloud/bigquery/table.py index 633043322..dcba10428 100644 --- a/google/cloud/bigquery/table.py +++ b/google/cloud/bigquery/table.py @@ -1853,7 +1853,7 @@ def to_arrow( def to_dataframe_iterable( self, bqstorage_client: Optional["bigquery_storage.BigQueryReadClient"] = None, - dtypes: Dict[str, Any] = None, + dtypes: Optional[Dict[str, Any]] = None, max_queue_size: int = _pandas_helpers._MAX_QUEUE_SIZE_DEFAULT, # type: ignore ) -> "pandas.DataFrame": """Create an iterable of pandas DataFrames, to process the table as a stream. @@ -1929,7 +1929,7 @@ def to_dataframe_iterable( def to_dataframe( self, bqstorage_client: Optional["bigquery_storage.BigQueryReadClient"] = None, - dtypes: Dict[str, Any] = None, + dtypes: Optional[Dict[str, Any]] = None, progress_bar_type: Optional[str] = None, create_bqstorage_client: bool = True, geography_as_object: bool = False, @@ -2227,7 +2227,7 @@ def __can_cast_timestamp_ns(column): def to_geodataframe( self, bqstorage_client: Optional["bigquery_storage.BigQueryReadClient"] = None, - dtypes: Dict[str, Any] = None, + dtypes: Optional[Dict[str, Any]] = None, progress_bar_type: Optional[str] = None, create_bqstorage_client: bool = True, geography_column: Optional[str] = None, diff --git a/noxfile.py b/noxfile.py index 4ddd4eaaf..a2b7a6843 100644 --- a/noxfile.py +++ b/noxfile.py @@ -22,7 +22,7 @@ import nox -MYPY_VERSION = "mypy==0.910" +MYPY_VERSION = "mypy==1.6.1" PYTYPE_VERSION = "pytype==2021.4.9" BLACK_VERSION = "black==23.7.0" BLACK_PATHS = ( @@ -137,7 +137,7 @@ def mypy(session): "types-requests", "types-setuptools", ) - session.run("mypy", "google/cloud") + session.run("mypy", "google/cloud", "--show-traceback") @nox.session(python=DEFAULT_PYTHON_VERSION) diff --git a/samples/snippets/authenticate_service_account_test.py b/samples/snippets/authenticate_service_account_test.py index 4b5711f80..fbdd2d064 100644 --- a/samples/snippets/authenticate_service_account_test.py +++ b/samples/snippets/authenticate_service_account_test.py @@ -17,7 +17,7 @@ import google.auth -import authenticate_service_account +import authenticate_service_account # type: ignore if typing.TYPE_CHECKING: import pytest diff --git a/samples/snippets/authorized_view_tutorial_test.py b/samples/snippets/authorized_view_tutorial_test.py index cae870486..e2220fb54 100644 --- a/samples/snippets/authorized_view_tutorial_test.py +++ b/samples/snippets/authorized_view_tutorial_test.py @@ -18,7 +18,7 @@ from google.cloud import bigquery import pytest -import authorized_view_tutorial +import authorized_view_tutorial # type: ignore @pytest.fixture(scope="module") diff --git a/samples/snippets/create_partitioned_table_test.py b/samples/snippets/create_partitioned_table_test.py index 0f684fcb0..e4d7ec20e 100644 --- a/samples/snippets/create_partitioned_table_test.py +++ b/samples/snippets/create_partitioned_table_test.py @@ -14,7 +14,7 @@ import typing -import create_partitioned_table +import create_partitioned_table # type: ignore if typing.TYPE_CHECKING: import pytest diff --git a/samples/snippets/create_table_cmek_test.py b/samples/snippets/create_table_cmek_test.py index 2b15fb350..e8626b84c 100644 --- a/samples/snippets/create_table_cmek_test.py +++ b/samples/snippets/create_table_cmek_test.py @@ -14,7 +14,7 @@ import typing -import create_table_cmek +import create_table_cmek # type: ignore if typing.TYPE_CHECKING: import pytest diff --git a/samples/snippets/create_table_external_data_configuration_test.py b/samples/snippets/create_table_external_data_configuration_test.py index e97d7170d..bf81a75f9 100644 --- a/samples/snippets/create_table_external_data_configuration_test.py +++ b/samples/snippets/create_table_external_data_configuration_test.py @@ -14,7 +14,7 @@ import typing -import create_table_external_data_configuration +import create_table_external_data_configuration # type: ignore if typing.TYPE_CHECKING: import pytest diff --git a/samples/snippets/create_table_external_hive_partitioned_test.py b/samples/snippets/create_table_external_hive_partitioned_test.py index 37deb8b12..5b8cbe1c3 100644 --- a/samples/snippets/create_table_external_hive_partitioned_test.py +++ b/samples/snippets/create_table_external_hive_partitioned_test.py @@ -14,7 +14,7 @@ import typing -import create_table_external_hive_partitioned +import create_table_external_hive_partitioned # type: ignore if typing.TYPE_CHECKING: import pytest diff --git a/samples/snippets/create_table_schema_from_json_test.py b/samples/snippets/create_table_schema_from_json_test.py index 39b00cea0..e725d3ccf 100644 --- a/samples/snippets/create_table_schema_from_json_test.py +++ b/samples/snippets/create_table_schema_from_json_test.py @@ -14,7 +14,7 @@ import typing -import create_table_schema_from_json +import create_table_schema_from_json # type: ignore if typing.TYPE_CHECKING: import pytest diff --git a/samples/snippets/create_table_snapshot_test.py b/samples/snippets/create_table_snapshot_test.py index 784dc3ddd..17ef24d26 100644 --- a/samples/snippets/create_table_snapshot_test.py +++ b/samples/snippets/create_table_snapshot_test.py @@ -14,7 +14,7 @@ import typing -import create_table_snapshot +import create_table_snapshot # type: ignore if typing.TYPE_CHECKING: import pytest diff --git a/samples/snippets/dataset_access_test.py b/samples/snippets/dataset_access_test.py index cc6a9af61..e3a53b084 100644 --- a/samples/snippets/dataset_access_test.py +++ b/samples/snippets/dataset_access_test.py @@ -14,8 +14,8 @@ import typing -import revoke_dataset_access -import update_dataset_access +import revoke_dataset_access # type: ignore +import update_dataset_access # type: ignore if typing.TYPE_CHECKING: from google.cloud import bigquery diff --git a/samples/snippets/delete_job_test.py b/samples/snippets/delete_job_test.py index ac9d52dcf..88eeae1ed 100644 --- a/samples/snippets/delete_job_test.py +++ b/samples/snippets/delete_job_test.py @@ -16,7 +16,7 @@ from google.cloud import bigquery -import delete_job +import delete_job # type: ignore if typing.TYPE_CHECKING: import pytest diff --git a/samples/snippets/delete_label_table_test.py b/samples/snippets/delete_label_table_test.py index 80fcbb695..01e538ae3 100644 --- a/samples/snippets/delete_label_table_test.py +++ b/samples/snippets/delete_label_table_test.py @@ -14,7 +14,7 @@ import typing -import delete_label_table +import delete_label_table # type: ignore if typing.TYPE_CHECKING: import pytest diff --git a/samples/snippets/get_table_labels_test.py b/samples/snippets/get_table_labels_test.py index 95a95b60f..e910d6a65 100644 --- a/samples/snippets/get_table_labels_test.py +++ b/samples/snippets/get_table_labels_test.py @@ -16,7 +16,7 @@ from google.cloud import bigquery -import get_table_labels +import get_table_labels # type: ignore if typing.TYPE_CHECKING: import pytest diff --git a/samples/snippets/get_table_make_schema_test.py b/samples/snippets/get_table_make_schema_test.py index 424f16e39..b1a1623bb 100644 --- a/samples/snippets/get_table_make_schema_test.py +++ b/samples/snippets/get_table_make_schema_test.py @@ -14,7 +14,7 @@ import typing -import get_table_make_schema +import get_table_make_schema # type: ignore if typing.TYPE_CHECKING: import pathlib diff --git a/samples/snippets/label_table_test.py b/samples/snippets/label_table_test.py index 98f3b3cc7..49f5406ab 100644 --- a/samples/snippets/label_table_test.py +++ b/samples/snippets/label_table_test.py @@ -14,7 +14,7 @@ import typing -import label_table +import label_table # type: ignore if typing.TYPE_CHECKING: import pytest diff --git a/samples/snippets/load_table_schema_from_json_test.py b/samples/snippets/load_table_schema_from_json_test.py index c28875b0e..745793cd7 100644 --- a/samples/snippets/load_table_schema_from_json_test.py +++ b/samples/snippets/load_table_schema_from_json_test.py @@ -14,7 +14,7 @@ import typing -import load_table_schema_from_json +import load_table_schema_from_json # type: ignore if typing.TYPE_CHECKING: import pytest diff --git a/samples/snippets/load_table_uri_firestore_test.py b/samples/snippets/load_table_uri_firestore_test.py index 552fa2e35..e19378a04 100644 --- a/samples/snippets/load_table_uri_firestore_test.py +++ b/samples/snippets/load_table_uri_firestore_test.py @@ -14,7 +14,7 @@ import typing -import load_table_uri_firestore +import load_table_uri_firestore # type: ignore if typing.TYPE_CHECKING: import pytest diff --git a/samples/snippets/manage_job_test.py b/samples/snippets/manage_job_test.py index 630be365b..2ef4be2e0 100644 --- a/samples/snippets/manage_job_test.py +++ b/samples/snippets/manage_job_test.py @@ -15,8 +15,8 @@ from google.cloud import bigquery import pytest -import manage_job_cancel -import manage_job_get +import manage_job_cancel # type: ignore +import manage_job_get # type: ignore def test_manage_job(capsys: pytest.CaptureFixture[str]) -> None: diff --git a/samples/snippets/materialized_view_test.py b/samples/snippets/materialized_view_test.py index 70869346f..59e08131e 100644 --- a/samples/snippets/materialized_view_test.py +++ b/samples/snippets/materialized_view_test.py @@ -20,7 +20,7 @@ from google.cloud import bigquery import pytest -import materialized_view +import materialized_view # type: ignore def temp_suffix() -> str: diff --git a/samples/snippets/natality_tutorial_test.py b/samples/snippets/natality_tutorial_test.py index f56738528..7f24ca5cb 100644 --- a/samples/snippets/natality_tutorial_test.py +++ b/samples/snippets/natality_tutorial_test.py @@ -18,7 +18,7 @@ from google.cloud import bigquery import pytest -import natality_tutorial +import natality_tutorial # type: ignore @pytest.fixture(scope="module") diff --git a/samples/snippets/nested_repeated_schema_test.py b/samples/snippets/nested_repeated_schema_test.py index 8bb8bda6a..67815dcf6 100644 --- a/samples/snippets/nested_repeated_schema_test.py +++ b/samples/snippets/nested_repeated_schema_test.py @@ -14,7 +14,7 @@ import typing -import nested_repeated_schema +import nested_repeated_schema # type: ignore if typing.TYPE_CHECKING: import pytest diff --git a/samples/snippets/quickstart_test.py b/samples/snippets/quickstart_test.py index 98a5fdd4e..88a24618d 100644 --- a/samples/snippets/quickstart_test.py +++ b/samples/snippets/quickstart_test.py @@ -18,7 +18,7 @@ from google.cloud import bigquery import pytest -import quickstart +import quickstart # type: ignore # Must match the dataset listed in quickstart.py (there's no easy way to # extract this). diff --git a/samples/snippets/relax_column_test.py b/samples/snippets/relax_column_test.py index b40b13fa1..ede1c3ab7 100644 --- a/samples/snippets/relax_column_test.py +++ b/samples/snippets/relax_column_test.py @@ -16,7 +16,7 @@ from google.cloud import bigquery -import relax_column +import relax_column # type: ignore if typing.TYPE_CHECKING: import pytest diff --git a/samples/snippets/simple_app_test.py b/samples/snippets/simple_app_test.py index de4e1ce34..4bf0bb49c 100644 --- a/samples/snippets/simple_app_test.py +++ b/samples/snippets/simple_app_test.py @@ -14,7 +14,7 @@ import typing -import simple_app +import simple_app # type: ignore if typing.TYPE_CHECKING: import pytest diff --git a/samples/snippets/test_update_with_dml.py b/samples/snippets/test_update_with_dml.py index ef5ec196a..d03114a36 100644 --- a/samples/snippets/test_update_with_dml.py +++ b/samples/snippets/test_update_with_dml.py @@ -17,8 +17,8 @@ from google.cloud import bigquery import pytest -from conftest import prefixer -import update_with_dml +from conftest import prefixer # type: ignore +import update_with_dml # type: ignore @pytest.fixture diff --git a/samples/snippets/update_table_expiration_test.py b/samples/snippets/update_table_expiration_test.py index 1566c7763..ed68a8c2c 100644 --- a/samples/snippets/update_table_expiration_test.py +++ b/samples/snippets/update_table_expiration_test.py @@ -15,7 +15,7 @@ import datetime import typing -import update_table_expiration +import update_table_expiration # type: ignore if typing.TYPE_CHECKING: import pathlib diff --git a/samples/snippets/user_credentials_test.py b/samples/snippets/user_credentials_test.py index df8a6354d..8448187de 100644 --- a/samples/snippets/user_credentials_test.py +++ b/samples/snippets/user_credentials_test.py @@ -19,7 +19,7 @@ import mock import pytest -from user_credentials import main +from user_credentials import main # type: ignore PROJECT = os.environ["GOOGLE_CLOUD_PROJECT"] diff --git a/samples/snippets/view_test.py b/samples/snippets/view_test.py index 4d0d43b77..1e615db47 100644 --- a/samples/snippets/view_test.py +++ b/samples/snippets/view_test.py @@ -19,7 +19,7 @@ from google.cloud import bigquery import pytest -import view +import view # type: ignore def temp_suffix() -> str: