Skip to content
This repository was archived by the owner on May 17, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Annotate constructors which always return None
  • Loading branch information
Sergey Vasilyev committed Jan 8, 2024
commit ce09a5c43bb3ee2264982da5d9ff8b4bfce5cdfa
2 changes: 1 addition & 1 deletion data_diff/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def diff_schemas(table1, table2, schema1, schema2, columns):


class MyHelpFormatter(click.HelpFormatter):
def __init__(self, **kwargs):
def __init__(self, **kwargs) -> None:
super().__init__(self, **kwargs)
self.indent_increment = 6

Expand Down
2 changes: 1 addition & 1 deletion data_diff/abcs/database_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ class Integer(NumericType, IKey):
precision: int = 0
python_type: type = int

def __attrs_post_init__(self):
def __attrs_post_init__(self) -> None:
assert self.precision == 0


Expand Down
2 changes: 1 addition & 1 deletion data_diff/cloud/datafold_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ class DatafoldAPI:
host: str = "https://app.datafold.com"
timeout: int = 30

def __attrs_post_init__(self):
def __attrs_post_init__(self) -> None:
self.host = self.host.rstrip("/")
self.headers = {
"Authorization": f"Key {self.api_key}",
Expand Down
2 changes: 1 addition & 1 deletion data_diff/databases/_connect.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class Connect:
database_by_scheme: Dict[str, Database]
conn_cache: MutableMapping[Hashable, Database]

def __init__(self, database_by_scheme: Dict[str, Database] = DATABASE_BY_SCHEME):
def __init__(self, database_by_scheme: Dict[str, Database] = DATABASE_BY_SCHEME) -> None:
super().__init__()
self.database_by_scheme = database_by_scheme
self.conn_cache = weakref.WeakValueDictionary()
Expand Down
2 changes: 1 addition & 1 deletion data_diff/databases/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1209,7 +1209,7 @@ class ThreadedDatabase(Database):
_queue: Optional[ThreadPoolExecutor] = None
thread_local: threading.local = attrs.field(factory=threading.local)

def __attrs_post_init__(self):
def __attrs_post_init__(self) -> None:
self._queue = ThreadPoolExecutor(self.thread_count, initializer=self.set_conn)
logger.info(f"[{self.name}] Starting a threadpool, size={self.thread_count}.")

Expand Down
2 changes: 1 addition & 1 deletion data_diff/databases/bigquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ class BigQuery(Database):
dataset: str
_client: Any

def __init__(self, project, *, dataset, bigquery_credentials=None, **kw):
def __init__(self, project, *, dataset, bigquery_credentials=None, **kw) -> None:
super().__init__()
credentials = bigquery_credentials
bigquery = import_bigquery()
Expand Down
2 changes: 1 addition & 1 deletion data_diff/databases/clickhouse.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ class Clickhouse(ThreadedDatabase):

_args: Dict[str, Any]

def __init__(self, *, thread_count: int, **kw):
def __init__(self, *, thread_count: int, **kw) -> None:
super().__init__(thread_count=thread_count)

self._args = kw
Expand Down
2 changes: 1 addition & 1 deletion data_diff/databases/databricks.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class Databricks(ThreadedDatabase):
catalog: str
_args: Dict[str, Any]

def __init__(self, *, thread_count, **kw):
def __init__(self, *, thread_count, **kw) -> None:
super().__init__(thread_count=thread_count)
logging.getLogger("databricks.sql").setLevel(logging.WARNING)

Expand Down
2 changes: 1 addition & 1 deletion data_diff/databases/duckdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ class DuckDB(Database):
_args: Dict[str, Any] = attrs.field(init=False)
_conn: Any = attrs.field(init=False)

def __init__(self, **kw):
def __init__(self, **kw) -> None:
super().__init__()
self._args = kw
self._conn = self.create_connection()
Expand Down
2 changes: 1 addition & 1 deletion data_diff/databases/mssql.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ class MsSQL(ThreadedDatabase):
_args: Dict[str, Any]
_mssql: Any

def __init__(self, host, port, user, password, *, database, thread_count, **kw):
def __init__(self, host, port, user, password, *, database, thread_count, **kw) -> None:
super().__init__(thread_count=thread_count)

args = dict(server=host, port=port, database=database, user=user, password=password, **kw)
Expand Down
2 changes: 1 addition & 1 deletion data_diff/databases/mysql.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ class MySQL(ThreadedDatabase):

_args: Dict[str, Any]

def __init__(self, *, thread_count, **kw):
def __init__(self, *, thread_count, **kw) -> None:
super().__init__(thread_count=thread_count)
self._args = kw

Expand Down
2 changes: 1 addition & 1 deletion data_diff/databases/oracle.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ class Oracle(ThreadedDatabase):
kwargs: Dict[str, Any]
_oracle: Any

def __init__(self, *, host, database, thread_count, **kw):
def __init__(self, *, host, database, thread_count, **kw) -> None:
super().__init__(thread_count=thread_count)
self.kwargs = dict(dsn=f"{host}/{database}" if database else host, **kw)
self.default_schema = kw.get("user").upper()
Expand Down
2 changes: 1 addition & 1 deletion data_diff/databases/postgresql.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ class PostgreSQL(ThreadedDatabase):
_args: Dict[str, Any]
_conn: Any

def __init__(self, *, thread_count, **kw):
def __init__(self, *, thread_count, **kw) -> None:
super().__init__(thread_count=thread_count)
self._args = kw
self.default_schema = "public"
Expand Down
2 changes: 1 addition & 1 deletion data_diff/databases/presto.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ class Presto(Database):

_conn: Any

def __init__(self, **kw):
def __init__(self, **kw) -> None:
super().__init__()
self.default_schema = "public"
prestodb = import_presto()
Expand Down
2 changes: 1 addition & 1 deletion data_diff/databases/snowflake.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class Snowflake(Database):

_conn: Any

def __init__(self, *, schema: str, key: Optional[str] = None, key_content: Optional[str] = None, **kw):
def __init__(self, *, schema: str, key: Optional[str] = None, key_content: Optional[str] = None, **kw) -> None:
super().__init__()
snowflake, serialization, default_backend = import_snowflake()
logging.getLogger("snowflake.connector").setLevel(logging.WARNING)
Expand Down
2 changes: 1 addition & 1 deletion data_diff/databases/trino.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class Trino(presto.Presto):

_conn: Any

def __init__(self, **kw):
def __init__(self, **kw) -> None:
super().__init__()
trino = import_trino()

Expand Down
2 changes: 1 addition & 1 deletion data_diff/databases/vertica.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ class Vertica(ThreadedDatabase):

_args: Dict[str, Any]

def __init__(self, *, thread_count, **kw):
def __init__(self, *, thread_count, **kw) -> None:
super().__init__(thread_count=thread_count)
self._args = kw
self._args["AUTOCOMMIT"] = False
Expand Down
2 changes: 1 addition & 1 deletion data_diff/hashdiff_tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class HashDiffer(TableDiffer):

stats: dict = attrs.field(factory=dict)

def __attrs_post_init__(self):
def __attrs_post_init__(self) -> None:
# Validate options
if self.bisection_factor >= self.bisection_threshold:
raise ValueError("Incorrect param values (bisection factor must be lower than threshold)")
Expand Down
4 changes: 2 additions & 2 deletions data_diff/lexicographic_space.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class LexicographicSpace:
All elements must be of the same length as the number of dimensions. (no rpadding)
"""

def __init__(self, dims: Vector):
def __init__(self, dims: Vector) -> None:
super().__init__()
self.dims = dims

Expand Down Expand Up @@ -124,7 +124,7 @@ class BoundedLexicographicSpace:
i.e. a space resticted by a "bounding-box" between two arbitrary points.
"""

def __init__(self, min_bound: Vector, max_bound: Vector):
def __init__(self, min_bound: Vector, max_bound: Vector) -> None:
super().__init__()

dims = tuple(mx - mn for mn, mx in safezip(min_bound, max_bound))
Expand Down
2 changes: 1 addition & 1 deletion data_diff/queries/ast_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ class GroupBy(ExprNode, ITable, Root):
values: Optional[Sequence[Expr]] = None
having_exprs: Optional[Sequence[Expr]] = None

def __attrs_post_init__(self):
def __attrs_post_init__(self) -> None:
assert self.keys or self.values

def having(self, *exprs) -> Self:
Expand Down
2 changes: 1 addition & 1 deletion data_diff/table_segment.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ class TableSegment:
case_sensitive: Optional[bool] = True
_schema: Optional[Schema] = None

def __attrs_post_init__(self):
def __attrs_post_init__(self) -> None:
if not self.update_column and (self.min_update or self.max_update):
raise ValueError("Error: the min_update/max_update feature requires 'update_column' to be set.")

Expand Down
4 changes: 2 additions & 2 deletions data_diff/thread_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class PriorityThreadPoolExecutor(ThreadPoolExecutor):
XXX WARNING: Might break in future versions of Python
"""

def __init__(self, *args):
def __init__(self, *args) -> None:
super().__init__(*args)
self._work_queue = AutoPriorityQueue()

Expand All @@ -58,7 +58,7 @@ class ThreadedYielder(Iterable):
_exception: Optional[None]
yield_list: bool

def __init__(self, max_workers: Optional[int] = None, yield_list: bool = False):
def __init__(self, max_workers: Optional[int] = None, yield_list: bool = False) -> None:
super().__init__()
self._pool = PriorityThreadPoolExecutor(max_workers)
self._futures = deque()
Expand Down
6 changes: 3 additions & 3 deletions data_diff/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def new(self, initial=()) -> Self:


class CaseInsensitiveDict(CaseAwareMapping):
def __init__(self, initial):
def __init__(self, initial) -> None:
super().__init__()
self._dict = {k.lower(): (k, v) for k, v in dict(initial).items()}

Expand Down Expand Up @@ -241,7 +241,7 @@ class ArithAlphanumeric(ArithString):
_str: str
_max_len: Optional[int] = None

def __attrs_post_init__(self):
def __attrs_post_init__(self) -> None:
if self._str is None:
raise ValueError("Alphanum string cannot be None")
if self._max_len and len(self._str) > self._max_len:
Expand Down Expand Up @@ -540,7 +540,7 @@ class LogStatusHandler(logging.Handler):
This log handler can be used to update a rich.status every time a log is emitted.
"""

def __init__(self):
def __init__(self) -> None:
super().__init__()
self.status = Status("")
self.prefix = ""
Expand Down
14 changes: 7 additions & 7 deletions tests/test_database_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ class PaginatedTable:
# much memory.
RECORDS_PER_BATCH = 1000000

def __init__(self, table_path, conn):
def __init__(self, table_path, conn) -> None:
super().__init__()
self.table_path = table_path
self.conn = conn
Expand Down Expand Up @@ -398,7 +398,7 @@ class DateTimeFaker:
datetime.fromisoformat("2022-06-01 15:10:05.009900"),
]

def __init__(self, max):
def __init__(self, max) -> None:
super().__init__()
self.max = max

Expand All @@ -414,7 +414,7 @@ def __len__(self):
class IntFaker:
MANUAL_FAKES = [127, -3, -9, 37, 15, 0]

def __init__(self, max):
def __init__(self, max) -> None:
super().__init__()
self.max = max

Expand All @@ -430,7 +430,7 @@ def __len__(self):
class BooleanFaker:
MANUAL_FAKES = [False, True, True, False]

def __init__(self, max):
def __init__(self, max) -> None:
super().__init__()
self.max = max

Expand Down Expand Up @@ -461,7 +461,7 @@ class FloatFaker:
3.141592653589793,
]

def __init__(self, max):
def __init__(self, max) -> None:
super().__init__()
self.max = max

Expand All @@ -475,7 +475,7 @@ def __len__(self):


class UUID_Faker:
def __init__(self, max):
def __init__(self, max) -> None:
super().__init__()
self.max = max

Expand All @@ -491,7 +491,7 @@ class JsonFaker:
'{"keyText": "text", "keyInt": 3, "keyFloat": 5.4445, "keyBoolean": true}',
]

def __init__(self, max):
def __init__(self, max) -> None:
super().__init__()
self.max = max

Expand Down