FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Get pytype to pass · google/python-spanner-orm@0be29e9 · GitHub

Commit 0be29e9

Browse files
committed
Get pytype to pass
1 parent 039f7c3 commit 0be29e9

6 files changed

Lines changed: 13 additions & 11 deletions

File tree

‎spanner_orm/admin/migration_manager.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def _migration_from_file(self, filename: str) -> migration.Migration:
7474
path = os.path.join(self.basedir, filename)
7575
spec = importlib.util.spec_from_file_location(module_name, path)
7676
module = importlib.util.module_from_spec(spec)
77-
spec.loader.exec_module(module)
77+
spec.loader.exec_module(module) # type: ignore
7878
try:
7979
result = migration.Migration(module.migration_id,
8080
module.prev_migration_id,

‎spanner_orm/model.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ def where_equal(cls,
307307
def _results_to_models(cls,
308308
results: Iterable[Iterable[Any]]) -> List['ModelObject']:
309309
items = [dict(zip(cls.columns, result)) for result in results]
310-
return [cls(item, persisted=True) for item in items]
310+
return [cls(item, persisted=True) for item in items] # type: ignore
311311

312312
@classmethod
313313
def _execute_read(cls, db_api: Callable[..., CallableReturn],

‎spanner_orm/query.py‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"""Helps build SQL for complex Spanner queries."""
1616

1717
import abc
18-
from typing import Any, Dict, Iterable, List, Tuple, Type
18+
from typing import Any, Dict, Iterable, List, Sequence, Tuple, Type
1919

2020
from spanner_orm import condition
2121
from spanner_orm import error
@@ -47,7 +47,7 @@ def types(self) -> Dict[str, Any]:
4747
return self._types
4848

4949
@abc.abstractmethod
50-
def process_results(self, results: List[List[Any]]) -> None:
50+
def process_results(self, results: List[Sequence[Any]]) -> None:
5151
pass
5252

5353
def _segments(self,
@@ -148,7 +148,7 @@ def __init__(self, model: Type[Any],
148148
def _select(self) -> Tuple[str, Dict[str, Any], Dict[str, Any]]:
149149
return ('SELECT COUNT(*)', {}, {})
150150

151-
def process_results(self, results: List[List[Any]]) -> int:
151+
def process_results(self, results: List[Sequence[Any]]) -> int:
152152
return int(results[0][0])
153153

154154

@@ -186,7 +186,7 @@ def _select(self) -> Tuple[str, Dict[str, Any], Dict[str, Any]]:
186186
prefix=self._select_prefix(),
187187
columns=', '.join(columns)), parameters, types)
188188

189-
def process_results(self, results: List[List[Any]]) -> List[Type[Any]]:
189+
def process_results(self, results: List[Sequence[Any]]) -> List[Type[Any]]:
190190
return [self._process_row(result) for result in results]
191191

192192
def _process_row(self, row: List[Any]) -> Type[Any]:

‎spanner_orm/relationship.py‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,8 @@ def _parse_constraints(self) -> List[RelationshipConstraint]:
8888
raise error.ValidationError(
8989
'Destination column must be present in destination model')
9090

91-
# TODO(dbrandao): remove when pytype #234 is fixed
9291
constraints.append(
9392
RelationshipConstraint(self.destination, destination_column,
94-
self.origin, origin_column)) # type: ignore
93+
self.origin, origin_column))
9594

9695
return constraints

‎spanner_orm/table_apis.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"""Table-level API lambdas for Spanner transactions."""
1616

1717
import logging
18-
from typing import Any, Dict, Iterable, List
18+
from typing import Any, Dict, Iterable, List, Sequence
1919

2020
from google.cloud import spanner
2121
from google.cloud.spanner_v1 import transaction as spanner_transaction
@@ -26,7 +26,7 @@
2626

2727
# Read methods
2828
def find(transaction: spanner_transaction.Transaction, table_name: str,
29-
columns: Iterable[str], keyset: spanner.KeySet) -> List[Iterable[Any]]:
29+
columns: Iterable[str], keyset: spanner.KeySet) -> List[Sequence[Any]]:
3030
"""Retrieves rows from the given table based on the provided KeySet.
3131
3232
Args:
@@ -51,7 +51,7 @@ def find(transaction: spanner_transaction.Transaction, table_name: str,
5151

5252
def sql_query(transaction: spanner_transaction.Transaction, query: str,
5353
parameters: Dict[str, Any],
54-
parameter_types: Dict[str, type_pb2.Type]) -> List[Iterable[Any]]:
54+
parameter_types: Dict[str, type_pb2.Type]) -> List[Sequence[Any]]:
5555
"""Executes a given SQL query against the Spanner database.
5656
5757
This isn't technically read-only, but it's necessary to implement the read-

‎spanner_orm/tests/metadata_test.py‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
15+
16+
# type: ignore
17+
1518
import logging
1619
import unittest
1720

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL