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

Commit 9bd8357

Browse files
author
Sergey Vasilyev
committed
Restore MRO calls to inherited constructors
Always, always, always call the inherited constructor — even if it does nothing. If not called, it breaks the MRO chain of inheritance and complicates the mixin/class building. This must be a linting rule.
1 parent c36ff0a commit 9bd8357

17 files changed

+29
-10
lines changed

data_diff/databases/_connect.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ class Connect:
9898
conn_cache: MutableMapping[Hashable, Database]
9999

100100
def __init__(self, database_by_scheme: Dict[str, Database] = DATABASE_BY_SCHEME):
101+
super().__init__()
101102
self.database_by_scheme = database_by_scheme
102103
self.match_uri_path = {name: MatchUriPath(cls) for name, cls in database_by_scheme.items()}
103104
self.conn_cache = weakref.WeakValueDictionary()

data_diff/databases/base.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ class ThreadLocalInterpreter:
180180
"""
181181

182182
def __init__(self, compiler: Compiler, gen: Generator):
183+
super().__init__()
183184
self.gen = gen
184185
self.compiler = compiler
185186

@@ -1109,6 +1110,7 @@ class ThreadedDatabase(Database):
11091110
"""
11101111

11111112
def __init__(self, thread_count=1):
1113+
super().__init__()
11121114
self._init_error = None
11131115
self._queue = ThreadPoolExecutor(thread_count, initializer=self.set_conn)
11141116
self.thread_local = threading.local()

data_diff/databases/bigquery.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@ class BigQuery(Database):
224224
dialect = Dialect()
225225

226226
def __init__(self, project, *, dataset, bigquery_credentials=None, **kw):
227+
super().__init__()
227228
credentials = bigquery_credentials
228229
bigquery = import_bigquery()
229230

data_diff/databases/databricks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,12 +104,12 @@ class Databricks(ThreadedDatabase):
104104
CONNECT_URI_PARAMS = ["catalog", "schema"]
105105

106106
def __init__(self, *, thread_count, **kw):
107+
super().__init__(thread_count=thread_count)
107108
logging.getLogger("databricks.sql").setLevel(logging.WARNING)
108109

109110
self._args = kw
110111
self.default_schema = kw.get("schema", "default")
111112
self.catalog = self._args.get("catalog", "hive_metastore")
112-
super().__init__(thread_count=thread_count)
113113

114114
def create_connection(self):
115115
databricks = import_databricks()

data_diff/databases/duckdb.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ class DuckDB(Database):
139139
CONNECT_URI_PARAMS = ["database", "dbpath"]
140140

141141
def __init__(self, **kw):
142+
super().__init__()
142143
self._args = kw
143144
self._conn = self.create_connection()
144145

data_diff/databases/mysql.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,8 @@ class MySQL(ThreadedDatabase):
138138
CONNECT_URI_PARAMS = ["database?"]
139139

140140
def __init__(self, *, thread_count, **kw):
141-
self._args = kw
142-
143141
super().__init__(thread_count=thread_count)
142+
self._args = kw
144143

145144
# In MySQL schema and database are synonymous
146145
try:

data_diff/databases/oracle.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,12 +182,10 @@ class Oracle(ThreadedDatabase):
182182
CONNECT_URI_PARAMS = ["database?"]
183183

184184
def __init__(self, *, host, database, thread_count, **kw):
185+
super().__init__(thread_count=thread_count)
185186
self.kwargs = dict(dsn=f"{host}/{database}" if database else host, **kw)
186-
187187
self.default_schema = kw.get("user").upper()
188188

189-
super().__init__(thread_count=thread_count)
190-
191189
def create_connection(self):
192190
self._oracle = import_oracle()
193191
try:

data_diff/databases/postgresql.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,8 @@ class PostgreSQL(ThreadedDatabase):
128128
default_schema = "public"
129129

130130
def __init__(self, *, thread_count, **kw):
131-
self._args = kw
132-
133131
super().__init__(thread_count=thread_count)
132+
self._args = kw
134133

135134
def create_connection(self):
136135
if not self._args:

data_diff/databases/presto.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ class Presto(Database):
161161
default_schema = "public"
162162

163163
def __init__(self, **kw):
164+
super().__init__()
164165
prestodb = import_presto()
165166

166167
if kw.get("schema"):

data_diff/databases/snowflake.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ class Snowflake(Database):
155155
CONNECT_URI_KWPARAMS = ["warehouse"]
156156

157157
def __init__(self, *, schema: str, **kw):
158+
super().__init__()
158159
snowflake, serialization, default_backend = import_snowflake()
159160
logging.getLogger("snowflake.connector").setLevel(logging.WARNING)
160161

0 commit comments

Comments
 (0)