mirror of https://github.com/astral-sh/ruff
remove underscore fallback
This commit is contained in:
parent
5de62caff6
commit
aa03af22af
|
|
@ -2151,10 +2151,10 @@ def function():
|
||||||
// TODO: This should just be `**AB@Alias2 (<variance>)`
|
// TODO: This should just be `**AB@Alias2 (<variance>)`
|
||||||
// https://github.com/astral-sh/ty/issues/1581
|
// https://github.com/astral-sh/ty/issues/1581
|
||||||
assert_snapshot!(test.hover(), @r"
|
assert_snapshot!(test.hover(), @r"
|
||||||
def _(**AB@Alias2) -> tuple[AB@Alias2]
|
(**AB@Alias2) -> tuple[AB@Alias2]
|
||||||
---------------------------------------------
|
---------------------------------------------
|
||||||
```python
|
```python
|
||||||
def _(**AB@Alias2) -> tuple[AB@Alias2]
|
(**AB@Alias2) -> tuple[AB@Alias2]
|
||||||
```
|
```
|
||||||
---------------------------------------------
|
---------------------------------------------
|
||||||
info[hover]: Hovered content is
|
info[hover]: Hovered content is
|
||||||
|
|
|
||||||
|
|
@ -1676,15 +1676,13 @@ impl<'db> FmtDetailed<'db> for DisplaySignature<'_, 'db> {
|
||||||
|
|
||||||
// If we're multiline printing and a name hasn't been emitted, try to
|
// If we're multiline printing and a name hasn't been emitted, try to
|
||||||
// make one up to make things more pretty
|
// make one up to make things more pretty
|
||||||
if self.settings.multiline && !self.settings.disallow_signature_name {
|
if self.settings.multiline
|
||||||
f.write_str("def ")?;
|
&& !self.settings.disallow_signature_name
|
||||||
if let Some(definition) = self.definition
|
&& let Some(definition) = self.definition
|
||||||
&& let Some(name) = definition.name(self.db)
|
&& let Some(name) = definition.name(self.db)
|
||||||
{
|
{
|
||||||
|
f.write_str("def ")?;
|
||||||
f.write_str(&name)?;
|
f.write_str(&name)?;
|
||||||
} else {
|
|
||||||
f.write_str("_")?;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parameters
|
// Parameters
|
||||||
|
|
@ -2721,12 +2719,12 @@ mod tests {
|
||||||
let db = setup_db();
|
let db = setup_db();
|
||||||
|
|
||||||
// Empty parameters with no return type.
|
// Empty parameters with no return type.
|
||||||
assert_snapshot!(display_signature_multiline(&db, [], None), @"def _() -> Unknown");
|
assert_snapshot!(display_signature_multiline(&db, [], None), @"() -> Unknown");
|
||||||
|
|
||||||
// Empty parameters with a return type.
|
// Empty parameters with a return type.
|
||||||
assert_snapshot!(
|
assert_snapshot!(
|
||||||
display_signature_multiline(&db, [], Some(Type::none(&db))),
|
display_signature_multiline(&db, [], Some(Type::none(&db))),
|
||||||
@"def _() -> None"
|
@"() -> None"
|
||||||
);
|
);
|
||||||
|
|
||||||
// Single parameter type (no name) with a return type.
|
// Single parameter type (no name) with a return type.
|
||||||
|
|
@ -2736,7 +2734,7 @@ mod tests {
|
||||||
[Parameter::positional_only(None).with_annotated_type(Type::none(&db))],
|
[Parameter::positional_only(None).with_annotated_type(Type::none(&db))],
|
||||||
Some(Type::none(&db))
|
Some(Type::none(&db))
|
||||||
),
|
),
|
||||||
@"def _(None, /) -> None"
|
@"(None, /) -> None"
|
||||||
);
|
);
|
||||||
|
|
||||||
// Two parameters where one has annotation and the other doesn't.
|
// Two parameters where one has annotation and the other doesn't.
|
||||||
|
|
@ -2753,7 +2751,7 @@ mod tests {
|
||||||
Some(Type::none(&db))
|
Some(Type::none(&db))
|
||||||
),
|
),
|
||||||
@r"
|
@r"
|
||||||
def _(
|
(
|
||||||
x=int,
|
x=int,
|
||||||
y: str = str
|
y: str = str
|
||||||
) -> None
|
) -> None
|
||||||
|
|
@ -2771,7 +2769,7 @@ mod tests {
|
||||||
Some(Type::none(&db))
|
Some(Type::none(&db))
|
||||||
),
|
),
|
||||||
@r"
|
@r"
|
||||||
def _(
|
(
|
||||||
x,
|
x,
|
||||||
y,
|
y,
|
||||||
/
|
/
|
||||||
|
|
@ -2790,7 +2788,7 @@ mod tests {
|
||||||
Some(Type::none(&db))
|
Some(Type::none(&db))
|
||||||
),
|
),
|
||||||
@r"
|
@r"
|
||||||
def _(
|
(
|
||||||
x,
|
x,
|
||||||
/,
|
/,
|
||||||
y
|
y
|
||||||
|
|
@ -2809,7 +2807,7 @@ mod tests {
|
||||||
Some(Type::none(&db))
|
Some(Type::none(&db))
|
||||||
),
|
),
|
||||||
@r"
|
@r"
|
||||||
def _(
|
(
|
||||||
*,
|
*,
|
||||||
x,
|
x,
|
||||||
y
|
y
|
||||||
|
|
@ -2828,7 +2826,7 @@ mod tests {
|
||||||
Some(Type::none(&db))
|
Some(Type::none(&db))
|
||||||
),
|
),
|
||||||
@r"
|
@r"
|
||||||
def _(
|
(
|
||||||
x,
|
x,
|
||||||
*,
|
*,
|
||||||
y
|
y
|
||||||
|
|
@ -2867,7 +2865,7 @@ mod tests {
|
||||||
Some(KnownClass::Bytes.to_instance(&db))
|
Some(KnownClass::Bytes.to_instance(&db))
|
||||||
),
|
),
|
||||||
@r"
|
@r"
|
||||||
def _(
|
(
|
||||||
a,
|
a,
|
||||||
b: int,
|
b: int,
|
||||||
c=Literal[1],
|
c=Literal[1],
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue