Repository: googleapis/python-bigquery

Issue:
Type annotations missing on bigqueryDatasetReference
Thanks for stopping by to let us know something could be better!

#### Environment details

  - OS type and version: Windows 11
  - Python version: 3.9.6
  - pip version:  23.1.2
  - `google-cloud-bigquery` version:  3.11.3
  - `mypy` version: 1.4.1

#### Steps to reproduce

  1. Create a file `test.py` with the following contents:
```
from google.cloud import bigquery
ref = bigquery.DatasetReference("my-project", "my_dataset")
```

  2. Run `mypy test.py --disallow-untyped-calls`

#### Code example
See above

#### Stack trace
```
test.py:3: error: Call to untyped function "DatasetReference" in typed context  [no-untyped-call]
Found 1 error in 1 file (checked 1 source file)
```
#### Solution
To solve the problem, type annotations need to be added to the constructor of bigquery.DatasetReference



Discussion:
Thank you for sending this in.
We do not currently guarantee that all of our functions, classes, etc are fully typed.

If you wish to submit a PR to provide appropriate typing for that class, I would be happy to review it.

Having said that, at this time, due to workload and priorities, I am going to close this feature request.


Resolving patch:
diff --git a/google/cloud/bigquery/dataset.py b/google/cloud/bigquery/dataset.py
--- a/google/cloud/bigquery/dataset.py
+++ b/google/cloud/bigquery/dataset.py
@@ -92,7 +92,7 @@ class DatasetReference(object):
         ValueError: If either argument is not of type ``str``.
     """
 
-    def __init__(self, project, dataset_id):
+    def __init__(self, project: str, dataset_id: str):
         if not isinstance(project, str):
             raise ValueError("Pass a string for project")
         if not isinstance(dataset_id, str):
@@ -166,22 +166,24 @@ def from_string(
                 standard SQL format.
         """
         output_dataset_id = dataset_id
-        output_project_id = default_project
         parts = _helpers._split_id(dataset_id)
 
-        if len(parts) == 1 and not default_project:
-            raise ValueError(
-                "When default_project is not set, dataset_id must be a "
-                "fully-qualified dataset ID in standard SQL format, "
-                'e.g., "project.dataset_id" got {}'.format(dataset_id)
-            )
+        if len(parts) == 1:
+            if default_project is not None:
+                output_project_id = default_project
+            else:
+                raise ValueError(
+                    "When default_project is not set, dataset_id must be a "
+                    "fully-qualified dataset ID in standard SQL format, "
+                    'e.g., "project.dataset_id" got {}'.format(dataset_id)
+                )
         elif len(parts) == 2:
             output_project_id, output_dataset_id = parts
-        elif len(parts) > 2:
+        else:
             raise ValueError(
                 "Too many parts in dataset_id. Expected a fully-qualified "
-                "dataset ID in standard SQL format. e.g. "
-                '"project.dataset_id", got {}'.format(dataset_id)
+                "dataset ID in standard SQL format, "
+                'e.g. "project.dataset_id", got {}'.format(dataset_id)
             )
 
         return cls(output_project_id, output_dataset_id)


Test patch: