Skip to content
This repository was archived by the owner on May 17, 2024. It is now read-only.

Commit 70edcb0

Browse files
author
Sergey Vasilyev
committed
Annotate regular methods with clear result types
1 parent 3111f8d commit 70edcb0

File tree

10 files changed

+16
-16
lines changed

10 files changed

+16
-16
lines changed

data_diff/databases/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ def dialect(self) -> "BaseDialect":
131131
def compile(self, elem, params=None) -> str:
132132
return self.dialect.compile(self, elem, params)
133133

134-
def new_unique_name(self, prefix="tmp"):
134+
def new_unique_name(self, prefix="tmp") -> str:
135135
self._counter[0] += 1
136136
return f"{prefix}{self._counter[0]}"
137137

data_diff/databases/bigquery.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,10 @@ class Dialect(BaseDialect):
8080
def random(self) -> str:
8181
return "RAND()"
8282

83-
def quote(self, s: str):
83+
def quote(self, s: str) -> str:
8484
return f"`{s}`"
8585

86-
def to_string(self, s: str):
86+
def to_string(self, s: str) -> str:
8787
return f"cast({s} as string)"
8888

8989
def type_repr(self, t) -> str:

data_diff/databases/databricks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def type_repr(self, t) -> str:
6565
except KeyError:
6666
return super().type_repr(t)
6767

68-
def quote(self, s: str):
68+
def quote(self, s: str) -> str:
6969
return f"`{s}`"
7070

7171
def to_string(self, s: str) -> str:

data_diff/databases/mssql.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ class Dialect(BaseDialect):
7676
"json": JSON,
7777
}
7878

79-
def quote(self, s: str):
79+
def quote(self, s: str) -> str:
8080
return f"[{s}]"
8181

8282
def set_timezone_to_utc(self) -> str:
@@ -93,7 +93,7 @@ def current_schema(self) -> str:
9393
FROM sys.database_principals
9494
WHERE name = CURRENT_USER"""
9595

96-
def to_string(self, s: str):
96+
def to_string(self, s: str) -> str:
9797
# Both convert(varchar(max), …) and convert(text, …) do work.
9898
return f"CONVERT(VARCHAR(MAX), {s})"
9999

data_diff/databases/mysql.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,10 @@ class Dialect(BaseDialect):
7070
"boolean": Boolean,
7171
}
7272

73-
def quote(self, s: str):
73+
def quote(self, s: str) -> str:
7474
return f"`{s}`"
7575

76-
def to_string(self, s: str):
76+
def to_string(self, s: str) -> str:
7777
return f"cast({s} as char)"
7878

7979
def is_distinct_from(self, a: str, b: str) -> str:

data_diff/databases/oracle.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@ class Dialect(
5959
ROUNDS_ON_PREC_LOSS = True
6060
PLACEHOLDER_TABLE = "DUAL"
6161

62-
def quote(self, s: str):
62+
def quote(self, s: str) -> str:
6363
return f'"{s}"'
6464

65-
def to_string(self, s: str):
65+
def to_string(self, s: str) -> str:
6666
return f"cast({s} as varchar(1024))"
6767

6868
def limit_select(

data_diff/databases/vertica.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class Dialect(BaseDialect):
5757
"boolean": Boolean,
5858
}
5959

60-
def quote(self, s: str):
60+
def quote(self, s: str) -> str:
6161
return f'"{s}"'
6262

6363
def concat(self, items: List[str]) -> str:

data_diff/parse_time.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def parse_time_atom(count, unit):
5353
return count, unit
5454

5555

56-
def parse_time_delta(t: str):
56+
def parse_time_delta(t: str) -> timedelta:
5757
time_dict = {}
5858
while t:
5959
m = TIME_RE.match(t)
@@ -70,5 +70,5 @@ def parse_time_delta(t: str):
7070
return timedelta(**time_dict)
7171

7272

73-
def parse_time_before(time: datetime, delta: str):
73+
def parse_time_before(time: datetime, delta: str) -> datetime:
7474
return time - parse_time_delta(delta)

data_diff/table_segment.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ def __attrs_post_init__(self) -> None:
138138
f"Error: min_update expected to be smaller than max_update! ({self.min_update} >= {self.max_update})"
139139
)
140140

141-
def _where(self):
141+
def _where(self) -> Optional[str]:
142142
return f"({self.where})" if self.where else None
143143

144144
def _with_raw_schema(self, raw_schema: Dict[str, RawColumnInfo]) -> Self:

data_diff/tracking.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def disable_tracking() -> None:
8585
g_tracking_enabled = False
8686

8787

88-
def is_tracking_enabled():
88+
def is_tracking_enabled() -> bool:
8989
return g_tracking_enabled
9090

9191

@@ -114,7 +114,7 @@ def set_dbt_project_id(s) -> None:
114114
dbt_project_id = s
115115

116116

117-
def get_anonymous_id():
117+
def get_anonymous_id() -> str:
118118
global g_anonymous_id
119119
if g_anonymous_id is None:
120120
profile = _load_profile()

0 commit comments

Comments
 (0)