mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PY-87998 PyStringConversionWithoutDunderMethodInspection: fix str/tuple and report list label
(cherry picked from commit ab32f336558da96ee037edc727d4a06681820817) GitOrigin-RevId: 5d2a9e914b53f2764b9b6dfa2d2bd7b662be1eba
This commit is contained in:
committed by
intellij-monorepo-bot
parent
cbe872c85a
commit
f901605192
+4
-4
@@ -35,9 +35,9 @@ class PyStringConversionWithoutDunderMethodInspection : PyInspection() {
|
||||
@JvmField
|
||||
val ignoredTypes: MutableList<String> = mutableListOf(
|
||||
"types.NoneType", "_io.TextIOWrapper",
|
||||
// the definitions for these types don't include their `__str__~, so we have to explicitly ignore them
|
||||
"int", "float", "complex", "set", "frozenset", "bytes", "bytearray", "memoryview",
|
||||
"slice", "list", "dict", "bool", "range"
|
||||
// the definitions for these types don't include their `__str__`/`__repr__`, so we have to explicitly ignore them
|
||||
"str", "int", "float", "complex", "set", "frozenset", "bytes", "bytearray", "memoryview",
|
||||
"slice", "list", "dict", "bool", "range", "tuple",
|
||||
)
|
||||
|
||||
@JvmField
|
||||
@@ -48,7 +48,7 @@ class PyStringConversionWithoutDunderMethodInspection : PyInspection() {
|
||||
override fun getOptionsPane(): OptPane {
|
||||
return OptPane.pane(
|
||||
OptPane.stringList("ignoredTypes", PyPsiBundle.message("INSP.string.conversion.ignored.types")),
|
||||
OptPane.stringList("reportedTypes", PyPsiBundle.message("INSP.string.conversion.ignored.types"))
|
||||
OptPane.stringList("reportedTypes", PyPsiBundle.message("INSP.string.conversion.reported.types"))
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
+8
-9
@@ -90,15 +90,14 @@ class PyStringConversionWithoutDunderMethodInspectionTest : PyInspectionTestCase
|
||||
""".trimIndent())
|
||||
|
||||
fun `test should not warn for builtin types`() = doTestByText("""
|
||||
# Should not warn for builtin types
|
||||
str(42)
|
||||
str([1, 2, 3])
|
||||
str({"key": "value"})
|
||||
str(None)
|
||||
str(True)
|
||||
|
||||
format(42)
|
||||
format("hello")
|
||||
# see default ignore list for explanation
|
||||
repr(42)
|
||||
repr((1, 2, 3))
|
||||
repr([1, 2, 3])
|
||||
repr({"key": "value"})
|
||||
repr(None)
|
||||
repr(True)
|
||||
repr("asdf")
|
||||
""".trimIndent())
|
||||
|
||||
fun `test should warn for type`() = doTestByText("""
|
||||
|
||||
Reference in New Issue
Block a user