dedent input

This commit is contained in:
Aria Desires 2025-12-15 09:51:05 -05:00
parent 4be2b38ab7
commit 9cf8f70e3d
1 changed files with 190 additions and 207 deletions

View File

@ -83,6 +83,7 @@ mod tests {
system::{DbWithWritableSystem, SystemPathBuf},
};
use ruff_diagnostics::Fix;
use ruff_python_trivia::textwrap::dedent;
use ruff_text_size::{TextRange, TextSize};
use ty_project::ProjectMetadata;
use ty_python_semantic::{
@ -148,7 +149,7 @@ mod tests {
assert_snapshot!(test.code_actions(&UNRESOLVED_REFERENCE), @r"
info[code-action]: Ignore 'unresolved-reference' for this line
--> main.py:2:17
--> main.py:2:5
|
2 | b = a / 0 # ty:ignore[division-by-zero]
| ^
@ -156,7 +157,6 @@ mod tests {
1 |
- b = a / 0 # ty:ignore[division-by-zero]
2 + b = a / 0 # ty:ignore[division-by-zero, unresolved-reference]
3 |
");
}
@ -170,7 +170,7 @@ mod tests {
assert_snapshot!(test.code_actions(&UNRESOLVED_REFERENCE), @r"
info[code-action]: Ignore 'unresolved-reference' for this line
--> main.py:2:17
--> main.py:2:5
|
2 | b = a / 0 # ty:ignore[division-by-zero,]
| ^
@ -178,7 +178,6 @@ mod tests {
1 |
- b = a / 0 # ty:ignore[division-by-zero,]
2 + b = a / 0 # ty:ignore[division-by-zero, unresolved-reference]
3 |
");
}
@ -192,7 +191,7 @@ mod tests {
assert_snapshot!(test.code_actions(&UNRESOLVED_REFERENCE), @r"
info[code-action]: Ignore 'unresolved-reference' for this line
--> main.py:2:17
--> main.py:2:5
|
2 | b = a / 0 # ty:ignore[division-by-zero ]
| ^
@ -200,7 +199,6 @@ mod tests {
1 |
- b = a / 0 # ty:ignore[division-by-zero ]
2 + b = a / 0 # ty:ignore[division-by-zero, unresolved-reference ]
3 |
");
}
@ -214,7 +212,7 @@ mod tests {
assert_snapshot!(test.code_actions(&UNRESOLVED_REFERENCE), @r"
info[code-action]: Ignore 'unresolved-reference' for this line
--> main.py:2:17
--> main.py:2:5
|
2 | b = a / 0 # ty:ignore[division-by-zero] some explanation
| ^
@ -222,7 +220,6 @@ mod tests {
1 |
- b = a / 0 # ty:ignore[division-by-zero] some explanation
2 + b = a / 0 # ty:ignore[division-by-zero] some explanation # ty:ignore[unresolved-reference]
3 |
");
}
@ -240,13 +237,13 @@ mod tests {
assert_snapshot!(test.code_actions(&UNRESOLVED_REFERENCE), @r"
info[code-action]: Ignore 'unresolved-reference' for this line
--> main.py:3:21
--> main.py:3:9
|
2 | b = (
3 | / a # ty:ignore[division-by-zero]
4 | | /
5 | | 0
| |_____________________^
| |_________^
6 | )
|
1 |
@ -273,13 +270,13 @@ mod tests {
assert_snapshot!(test.code_actions(&UNRESOLVED_REFERENCE), @r"
info[code-action]: Ignore 'unresolved-reference' for this line
--> main.py:3:21
--> main.py:3:9
|
2 | b = (
3 | / a
4 | | /
5 | | 0 # ty:ignore[division-by-zero]
| |_____________________^
| |_________^
6 | )
|
2 | b = (
@ -288,7 +285,6 @@ mod tests {
- 0 # ty:ignore[division-by-zero]
5 + 0 # ty:ignore[division-by-zero, unresolved-reference]
6 | )
7 |
");
}
@ -306,13 +302,13 @@ mod tests {
assert_snapshot!(test.code_actions(&UNRESOLVED_REFERENCE), @r"
info[code-action]: Ignore 'unresolved-reference' for this line
--> main.py:3:21
--> main.py:3:9
|
2 | b = (
3 | / a # ty:ignore[division-by-zero]
4 | | /
5 | | 0 # ty:ignore[division-by-zero]
| |_____________________^
| |_________^
6 | )
|
1 |
@ -338,7 +334,7 @@ mod tests {
assert_snapshot!(test.code_actions(&UNRESOLVED_REFERENCE), @r#"
info[code-action]: Ignore 'unresolved-reference' for this line
--> main.py:3:18
--> main.py:3:6
|
2 | b = f"""
3 | {a}
@ -351,7 +347,6 @@ mod tests {
4 | more text
- """
5 + """ # ty:ignore[unresolved-reference]
6 |
"#);
}
@ -370,7 +365,7 @@ mod tests {
assert_snapshot!(test.code_actions(&UNRESOLVED_REFERENCE), @r#"
info[code-action]: Ignore 'unresolved-reference' for this line
--> main.py:4:17
--> main.py:4:5
|
2 | b = f"""
3 | {
@ -402,7 +397,7 @@ mod tests {
assert_snapshot!(test.code_actions(&UNRESOLVED_REFERENCE), @r#"
info[code-action]: Ignore 'unresolved-reference' for this line
--> main.py:2:17
--> main.py:2:5
|
2 | b = a + """
| ^
@ -414,7 +409,6 @@ mod tests {
3 | more text
- """
4 + """ # ty:ignore[unresolved-reference]
5 |
"#);
}
@ -429,7 +423,7 @@ mod tests {
assert_snapshot!(test.code_actions(&UNRESOLVED_REFERENCE), @r#"
info[code-action]: Ignore 'unresolved-reference' for this line
--> main.py:2:17
--> main.py:2:5
|
2 | b = a \
| ^
@ -439,7 +433,6 @@ mod tests {
2 | b = a \
- + "test"
3 + + "test" # ty:ignore[unresolved-reference]
4 |
"#);
}
@ -453,7 +446,7 @@ mod tests {
assert_snapshot!(test.code_actions(&UNDEFINED_REVEAL), @r"
info[code-action]: import typing.reveal_type
--> main.py:2:13
--> main.py:2:1
|
2 | reveal_type(1)
| ^^^^^^^^^^^
@ -462,10 +455,9 @@ mod tests {
1 + from typing import reveal_type
2 |
3 | reveal_type(1)
4 |
info[code-action]: Ignore 'undefined-reveal' for this line
--> main.py:2:13
--> main.py:2:1
|
2 | reveal_type(1)
| ^^^^^^^^^^^
@ -473,7 +465,6 @@ mod tests {
1 |
- reveal_type(1)
2 + reveal_type(1) # ty:ignore[undefined-reveal]
3 |
");
}
@ -488,7 +479,7 @@ mod tests {
assert_snapshot!(test.code_actions(&UNRESOLVED_REFERENCE), @r#"
info[code-action]: import warnings.deprecated
--> main.py:2:14
--> main.py:2:2
|
2 | @deprecated("do not use")
| ^^^^^^^^^^
@ -501,7 +492,7 @@ mod tests {
4 | def my_func(): ...
info[code-action]: Ignore 'unresolved-reference' for this line
--> main.py:2:14
--> main.py:2:2
|
2 | @deprecated("do not use")
| ^^^^^^^^^^
@ -511,7 +502,6 @@ mod tests {
- @deprecated("do not use")
2 + @deprecated("do not use") # ty:ignore[unresolved-reference]
3 | def my_func(): ...
4 |
"#);
}
@ -528,7 +518,7 @@ mod tests {
assert_snapshot!(test.code_actions(&UNRESOLVED_REFERENCE), @r#"
info[code-action]: import warnings.deprecated
--> main.py:4:14
--> main.py:4:2
|
2 | import warnings
3 |
@ -543,7 +533,7 @@ mod tests {
4 |
info[code-action]: qualify warnings.deprecated
--> main.py:4:14
--> main.py:4:2
|
2 | import warnings
3 |
@ -558,10 +548,9 @@ mod tests {
- @deprecated("do not use")
4 + @warnings.deprecated("do not use")
5 | def my_func(): ...
6 |
info[code-action]: Ignore 'unresolved-reference' for this line
--> main.py:4:14
--> main.py:4:2
|
2 | import warnings
3 |
@ -575,7 +564,6 @@ mod tests {
- @deprecated("do not use")
4 + @deprecated("do not use") # ty:ignore[unresolved-reference]
5 | def my_func(): ...
6 |
"#);
}
@ -590,7 +578,7 @@ mod tests {
assert_snapshot!(test.code_actions(&UNRESOLVED_REFERENCE), @r"
info[code-action]: import importlib.abc.ExecutionLoader
--> main.py:2:13
--> main.py:2:1
|
2 | ExecutionLoader
| ^^^^^^^^^^^^^^^
@ -599,10 +587,9 @@ mod tests {
1 + from importlib.abc import ExecutionLoader
2 |
3 | ExecutionLoader
4 |
info[code-action]: Ignore 'unresolved-reference' for this line
--> main.py:2:13
--> main.py:2:1
|
2 | ExecutionLoader
| ^^^^^^^^^^^^^^^
@ -610,7 +597,6 @@ mod tests {
1 |
- ExecutionLoader
2 + ExecutionLoader # ty:ignore[unresolved-reference]
3 |
");
}
@ -629,7 +615,7 @@ mod tests {
assert_snapshot!(test.code_actions(&UNRESOLVED_REFERENCE), @r"
info[code-action]: import importlib.abc.ExecutionLoader
--> main.py:3:13
--> main.py:3:1
|
2 | import importlib
3 | ExecutionLoader
@ -642,7 +628,7 @@ mod tests {
4 | ExecutionLoader
info[code-action]: Ignore 'unresolved-reference' for this line
--> main.py:3:13
--> main.py:3:1
|
2 | import importlib
3 | ExecutionLoader
@ -652,7 +638,6 @@ mod tests {
2 | import importlib
- ExecutionLoader
3 + ExecutionLoader # ty:ignore[unresolved-reference]
4 |
");
}
@ -668,7 +653,7 @@ mod tests {
assert_snapshot!(test.code_actions(&UNRESOLVED_REFERENCE), @r"
info[code-action]: import importlib.abc.ExecutionLoader
--> main.py:3:13
--> main.py:3:1
|
2 | import importlib.abc
3 | ExecutionLoader
@ -681,7 +666,7 @@ mod tests {
4 | ExecutionLoader
info[code-action]: qualify importlib.abc.ExecutionLoader
--> main.py:3:13
--> main.py:3:1
|
2 | import importlib.abc
3 | ExecutionLoader
@ -692,10 +677,9 @@ mod tests {
2 | import importlib.abc
- ExecutionLoader
3 + importlib.abc.ExecutionLoader
4 |
info[code-action]: Ignore 'unresolved-reference' for this line
--> main.py:3:13
--> main.py:3:1
|
2 | import importlib.abc
3 | ExecutionLoader
@ -705,7 +689,6 @@ mod tests {
2 | import importlib.abc
- ExecutionLoader
3 + ExecutionLoader # ty:ignore[unresolved-reference]
4 |
");
}
@ -724,7 +707,7 @@ mod tests {
db.init_program().unwrap();
let mut cleansed = source.to_string();
let mut cleansed = dedent(source).to_string();
let start = cleansed
.find("<START>")