Skip to content

Commit d72bd4c

Browse files
committed
Ruff ANN202: fixed private function return value type annotations
1 parent ad82673 commit d72bd4c

File tree

7 files changed

+11
-16
lines changed

7 files changed

+11
-16
lines changed

duckdb/experimental/spark/sql/dataframe.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -698,7 +698,7 @@ def join(
698698
on = str(on)
699699
assert isinstance(how, str), "how should be a string"
700700

701-
def map_to_recognized_jointype(how: str):
701+
def map_to_recognized_jointype(how: str) -> str:
702702
known_aliases = {
703703
"inner": [],
704704
"outer": ["full", "fullouter", "full_outer"],
@@ -707,15 +707,10 @@ def map_to_recognized_jointype(how: str):
707707
"anti": ["leftanti", "left_anti"],
708708
"semi": ["leftsemi", "left_semi"],
709709
}
710-
mapped_type = None
711710
for type, aliases in known_aliases.items():
712711
if how == type or how in aliases:
713-
mapped_type = type
714-
break
715-
716-
if not mapped_type:
717-
mapped_type = how
718-
return mapped_type
712+
return type
713+
return how
719714

720715
how = map_to_recognized_jointype(how)
721716
result = self.relation.join(other.relation, on, how)

duckdb/experimental/spark/sql/functions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ def lit(col: Any) -> Column: # noqa: D103
147147
return col if isinstance(col, Column) else Column(ConstantExpression(col))
148148

149149

150-
def _invoke_function(function: str, *arguments):
150+
def _invoke_function(function: str, *arguments) -> Column:
151151
return Column(FunctionExpression(function, *arguments))
152152

153153

duckdb/experimental/spark/sql/session.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232
# data is a List of rows
3333
# every value in each row needs to be turned into a Value
34-
def _combine_data_and_schema(data: Iterable[Any], schema: StructType):
34+
def _combine_data_and_schema(data: Iterable[Any], schema: StructType) -> list['duckdb.Value']:
3535
from duckdb import Value
3636

3737
new_data = []
@@ -82,7 +82,7 @@ def verify_tuple_integrity(tuples: list[tuple]) -> None:
8282
verify_tuple_integrity(data)
8383

8484
def construct_query(tuples: Iterable) -> str:
85-
def construct_values_list(row: Sized, start_param_idx: int):
85+
def construct_values_list(row: Sized, start_param_idx: int) -> str:
8686
parameter_count = len(row)
8787
parameters = [f"${x + start_param_idx}" for x in range(parameter_count)]
8888
parameters = "(" + ", ".join(parameters) + ")"
@@ -99,7 +99,7 @@ def construct_values_list(row: Sized, start_param_idx: int):
9999

100100
query = construct_query(data)
101101

102-
def construct_parameters(tuples: Iterable):
102+
def construct_parameters(tuples: Iterable) -> list[list]:
103103
parameters = []
104104
for row in tuples:
105105
parameters.extend(list(row))

duckdb_packaging/setuptools_scm_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
OVERRIDE_GIT_DESCRIBE_ENV_VAR = "OVERRIDE_GIT_DESCRIBE"
2020

2121

22-
def _main_branch_versioning():
22+
def _main_branch_versioning() -> bool:
2323
from_env = os.getenv("MAIN_BRANCH_VERSIONING")
2424
return from_env == "1" if from_env is not None else MAIN_BRANCH_VERSIONING
2525

scripts/generate_connection_methods.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def generate():
6767
"FunctionNullHandling.DEFAULT": "FunctionNullHandling::DEFAULT_NULL_HANDLING",
6868
}
6969

70-
def map_default(val):
70+
def map_default(val) -> str:
7171
if val in DEFAULT_ARGUMENT_MAP:
7272
return DEFAULT_ARGUMENT_MAP[val]
7373
return val

scripts/generate_connection_wrapper_methods.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ def generate():
124124
"FunctionNullHandling.DEFAULT": "FunctionNullHandling::DEFAULT_NULL_HANDLING",
125125
}
126126

127-
def map_default(val):
127+
def map_default(val) -> str:
128128
if val in DEFAULT_ARGUMENT_MAP:
129129
return DEFAULT_ARGUMENT_MAP[val]
130130
return val

tests/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ def __getattr__(self, name: str) -> Any:
189189

190190
@pytest.fixture(scope="function")
191191
def require():
192-
def _require(extension_name, db_name=""):
192+
def _require(extension_name, db_name="") -> duckdb.DuckDBPyConnection | None:
193193
# Paths to search for extensions
194194

195195
build = normpath(join(dirname(__file__), "../../../build/"))

0 commit comments

Comments
 (0)