Skip to content

Commit 2fe357a

Browse files
committed
remove untested code
1 parent a1f35e0 commit 2fe357a

File tree

2 files changed

+9
-32
lines changed

2 files changed

+9
-32
lines changed

crates/ty_python_semantic/resources/mdtest/call/function.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -702,8 +702,7 @@ A union of heterogeneous tuples provided to a variadic parameter:
702702
# - <https://github.com/pydata/xarray/blob/3572f4e70f2b12ef9935c1f8c3c1b74045d2a092/xarray/tests/test_groupby.py#L3058-L3059>
703703

704704
def f2(a: str, b: bool): ...
705-
def f3(a=None, b=None, c=None, d=None, e=None): ...
706-
def f4(coinflip: bool):
705+
def f3(coinflip: bool):
707706
if coinflip:
708707
args = "foo", True
709708
else:
@@ -723,19 +722,21 @@ def f4(coinflip: bool):
723722
# error: [invalid-argument-type] "Argument to function `f2` is incorrect: Expected `bool`, found `Literal[True] | tuple[Literal[True]]`"
724723
f2(*other_args)
725724

725+
def f4(a=None, b=None, c=None, d=None, e=None): ...
726+
726727
my_args = (("a", "b"), ("c", "d"), ("e", "f"))
727728

728729
for tup in my_args:
729-
f3(*tup, e=None) # fine
730+
f4(*tup, e=None) # fine
730731

731732
my_other_args = (
732733
("a", "b", "c", "d", "e"),
733734
("f", "g", "h", "i", "k"),
734735
)
735736

736737
for tup in my_other_args:
737-
# error: [parameter-already-assigned] "Multiple values provided for parameter `e` of function `f3`"
738-
f3(*tup, e=None)
738+
# error: [parameter-already-assigned] "Multiple values provided for parameter `e` of function `f4`"
739+
f4(*tup, e=None)
739740
```
740741

741742
### Mixed argument and parameter containing variadic

crates/ty_python_semantic/src/types/tuple.rs

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1586,33 +1586,9 @@ impl<'db> TupleSpecBuilder<'db> {
15861586
self
15871587
}
15881588

1589-
(
1590-
TupleSpecBuilder::Variable {
1591-
prefix: prefix1,
1592-
variable: variable1,
1593-
suffix: suffix1,
1594-
},
1595-
Tuple::Variable(VariableLengthTuple {
1596-
prefix: prefix2,
1597-
variable: variable2,
1598-
suffix: suffix2,
1599-
}),
1600-
) if prefix1.len() == prefix2.len() && suffix1.len() == suffix2.len() => {
1601-
TupleSpecBuilder::Variable {
1602-
prefix: prefix1
1603-
.iter()
1604-
.zip(prefix2)
1605-
.map(|(elem1, elem2)| UnionType::from_elements(db, [elem1, elem2]))
1606-
.collect(),
1607-
variable: UnionType::from_elements(db, [variable1, variable2]),
1608-
suffix: suffix1
1609-
.iter()
1610-
.zip(suffix2)
1611-
.map(|(elem1, elem2)| UnionType::from_elements(db, [elem1, elem2]))
1612-
.collect(),
1613-
}
1614-
}
1615-
1589+
// We *could* have a branch here where both `self` and `other` are mixed tuples
1590+
// with same-length prefixes and same-length suffixes. But it's hard to think of
1591+
// a test where this would actually lead to more precise inference.
16161592
_ => {
16171593
let unioned =
16181594
UnionType::from_elements(db, self.all_elements().chain(other.all_elements()));

0 commit comments

Comments
 (0)