mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 06:05:01 +07:00
Fix call type for open functions (PY-16893, PY-16894, PY-26313)
This commit is contained in:
+9
@@ -0,0 +1,9 @@
|
||||
from foo import calcT, calcB
|
||||
|
||||
with open('1.txt') as file1:
|
||||
calcT(<warning descr="Expected type 'TextIO', got 'BinaryIO' instead">file1</warning>)
|
||||
calcB(file1)
|
||||
|
||||
with open('1.txt', 'rb') as file2:
|
||||
calcT(<warning descr="Expected type 'TextIO', got 'BinaryIO' instead">file2</warning>)
|
||||
calcB(file2)
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
def calcT(a): pass
|
||||
def calcB(a): pass
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
from typing import BinaryIO, TextIO
|
||||
|
||||
|
||||
def calcT(a: TextIO) -> int: ...
|
||||
def calcB(a: BinaryIO) -> int: ...
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
from foo import calcT, calcB
|
||||
|
||||
with open('1.txt') as file1:
|
||||
calcT(file1)
|
||||
calcB(<warning descr="Expected type 'BinaryIO', got 'TextIO' instead">file1</warning>)
|
||||
|
||||
with open('1.txt', 'rb') as file2:
|
||||
calcT(<warning descr="Expected type 'TextIO', got 'BinaryIO' instead">file2</warning>)
|
||||
calcB(file2)
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
def calcT(a): pass
|
||||
def calcB(a): pass
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
from typing import BinaryIO, TextIO
|
||||
|
||||
|
||||
def calcT(a: TextIO) -> int: ...
|
||||
def calcB(a: BinaryIO) -> int: ...
|
||||
@@ -2,4 +2,4 @@ with open('foo', 'wb') as fd:
|
||||
fd.write(b'bar')
|
||||
|
||||
with open('foo', 'wb') as fd:
|
||||
fd.write(<warning descr="Expected type 'Union[bytes, bytearray]', got 'str' instead">'bar'</warning>)
|
||||
fd.write(<warning descr="Unexpected type(s):(str)Possible types:(bytes)(bytearray)">'bar'</warning>)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
f = open("file.txt")
|
||||
f.writelines("a") # OK
|
||||
f.<warning descr="Unresolved attribute reference 'writeliness' for class 'file'">writeliness</warning>("a")
|
||||
f.<warning descr="Unresolved attribute reference 'writeliness' for class 'BinaryIO'">writeliness</warning>("a")
|
||||
|
||||
f = open("file.txt", "rb")
|
||||
f.writelines("a") # OK
|
||||
f.<warning descr="Unresolved attribute reference 'writeliness' for class 'file'">writeliness</warning>("a")
|
||||
f.<warning descr="Unresolved attribute reference 'writeliness' for class 'BinaryIO'">writeliness</warning>("a")
|
||||
Reference in New Issue
Block a user