Repository: googleapis/python-bigquery

Issue:
Allow `DatasetListItem` in `Client.delete_dataset` types
https://app.circleci.com/pipelines/github/tswast/python-bigquery-pandas/217/workflows/38a35d17-9e68-48b3-b17a-b683e4ab5a52/jobs/1308

I expected this code to work:

```python
    @pytest.fixture(scope="session", autouse=True)
    def cleanup_datasets(bigquery_client: bigquery.Client):
        for dataset in bigquery_client.list_datasets():
            if prefixer.should_cleanup(dataset.dataset_id):
                bigquery_client.delete_dataset(
>                   dataset, delete_contents=True, not_found_ok=True
                )
```

But I get

```
if not isinstance(dataset, (Dataset, DatasetReference)):
>           raise TypeError("dataset must be a Dataset or a DatasetReference")
E           TypeError: dataset must be a Dataset or a DatasetReference

/opt/conda/envs/test-environment/lib/python3.7/site-packages/google/cloud/bigquery/client.py:740: TypeError
```

Similarly, we should check `delete_table`. I think it accepts `TableListItem`, but this is not reflected in the type annotations.




Discussion:
@steffnay This might be a good one to take on if you're looking for issues to get warmed up on the Python client.
@tswast could you please clarify for me whether this TypeError was not fixed by #597 or if the issue here is that the type needs to be updated [here](https://github.com/googleapis/python-bigquery/blob/b15b612ee7d642d663341989f0db1d6b9365e6e1/google/cloud/bigquery/client.py#L1528)?
Oops.

https://github.com/googleapis/python-bigquery-pandas/blob/6ae6629db0aec48ecd37a96a75f950fea63405c7/testing/constraints-3.7.txt#L12

This test suite was running with an older version of the google-cloud-bigquery library.

Sorry for the noise.
https://github.com/googleapis/python-bigquery/blob/b15b612ee7d642d663341989f0db1d6b9365e6e1/google/cloud/bigquery/client.py#L1528 does still need to be updated though, yes.

Resolving patch:
diff --git a/google/cloud/bigquery/client.py b/google/cloud/bigquery/client.py
--- a/google/cloud/bigquery/client.py
+++ b/google/cloud/bigquery/client.py
@@ -549,7 +549,7 @@ def _dataset_from_arg(self, dataset):
 
     def create_dataset(
         self,
-        dataset: Union[str, Dataset, DatasetReference],
+        dataset: Union[str, Dataset, DatasetReference, DatasetListItem],
         exists_ok: bool = False,
         retry: retries.Retry = DEFAULT_RETRY,
         timeout: float = DEFAULT_TIMEOUT,
@@ -679,7 +679,7 @@ def create_routine(
 
     def create_table(
         self,
-        table: Union[str, Table, TableReference],
+        table: Union[str, Table, TableReference, TableListItem],
         exists_ok: bool = False,
         retry: retries.Retry = DEFAULT_RETRY,
         timeout: float = DEFAULT_TIMEOUT,
@@ -693,6 +693,7 @@ def create_table(
             table (Union[ \
                 google.cloud.bigquery.table.Table, \
                 google.cloud.bigquery.table.TableReference, \
+                google.cloud.bigquery.table.TableListItem, \
                 str, \
             ]):
                 A :class:`~google.cloud.bigquery.table.Table` to create.
@@ -1295,7 +1296,7 @@ def update_table(
 
     def list_models(
         self,
-        dataset: Union[Dataset, DatasetReference, str],
+        dataset: Union[Dataset, DatasetReference, DatasetListItem, str],
         max_results: int = None,
         page_token: str = None,
         retry: retries.Retry = DEFAULT_RETRY,
@@ -1372,7 +1373,7 @@ def api_request(*args, **kwargs):
 
     def list_routines(
         self,
-        dataset: Union[Dataset, DatasetReference, str],
+        dataset: Union[Dataset, DatasetReference, DatasetListItem, str],
         max_results: int = None,
         page_token: str = None,
         retry: retries.Retry = DEFAULT_RETRY,
@@ -1449,7 +1450,7 @@ def api_request(*args, **kwargs):
 
     def list_tables(
         self,
-        dataset: Union[Dataset, DatasetReference, str],
+        dataset: Union[Dataset, DatasetReference, DatasetListItem, str],
         max_results: int = None,
         page_token: str = None,
         retry: retries.Retry = DEFAULT_RETRY,
@@ -1525,7 +1526,7 @@ def api_request(*args, **kwargs):
 
     def delete_dataset(
         self,
-        dataset: Union[Dataset, DatasetReference, str],
+        dataset: Union[Dataset, DatasetReference, DatasetListItem, str],
         delete_contents: bool = False,
         retry: retries.Retry = DEFAULT_RETRY,
         timeout: float = DEFAULT_TIMEOUT,


Test patch: