mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-09 08:09:39 +07:00
PY-20460 Fixed: typechecker false positive with slice
Update parameter type in str.__getitem__, bytes.__getitem__ (Py3) and unicode.__getitem__ (Py2) skeletons to receive slices
This commit is contained in:
@@ -1269,9 +1269,9 @@ class str(basestring):
|
||||
return b''
|
||||
|
||||
def __getitem__(self, y):
|
||||
"""y-th item of x, origin 0.
|
||||
"""y-th item of x or substring, origin 0.
|
||||
|
||||
:type y: numbers.Integral
|
||||
:type y: numbers.Integral | slice
|
||||
:rtype: str
|
||||
"""
|
||||
return b''
|
||||
@@ -1659,9 +1659,9 @@ class unicode(basestring):
|
||||
return ''
|
||||
|
||||
def __getitem__(self, y):
|
||||
"""y-th item of x, origin 0.
|
||||
"""y-th item of x or substring, origin 0.
|
||||
|
||||
:type y: numbers.Integral
|
||||
:type y: numbers.Integral | slice
|
||||
:rtype: unicode
|
||||
"""
|
||||
return ''
|
||||
|
||||
@@ -985,9 +985,9 @@ class bytes(object):
|
||||
return b''
|
||||
|
||||
def __getitem__(self, y):
|
||||
"""y-th item of x, origin 0.
|
||||
"""y-th item of x or substring, origin 0.
|
||||
|
||||
:type y: numbers.Integral
|
||||
:type y: numbers.Integral | slice
|
||||
:rtype: int | bytes
|
||||
"""
|
||||
return 0
|
||||
@@ -1359,9 +1359,9 @@ class str(object):
|
||||
return ''
|
||||
|
||||
def __getitem__(self, y):
|
||||
"""y-th item of x, origin 0.
|
||||
"""y-th item of x or substring, origin 0.
|
||||
|
||||
:type y: numbers.Integral
|
||||
:type y: numbers.Integral | slice
|
||||
:rtype: str
|
||||
"""
|
||||
return ''
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
sl = slice(0, 2)
|
||||
st = b"abcdef"
|
||||
|
||||
print(st[sl])
|
||||
@@ -0,0 +1,4 @@
|
||||
sl = slice(0, 2)
|
||||
st = "abcdef"
|
||||
|
||||
print(st[sl])
|
||||
@@ -0,0 +1,4 @@
|
||||
sl = slice(0, 2)
|
||||
st = u"abcdef"
|
||||
|
||||
print(st[sl])
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -109,6 +109,16 @@ public class Py3TypeCheckerInspectionTest extends PyTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
// PY-20460
|
||||
public void testStringGetItemWithSlice() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
// PY-20460
|
||||
public void testBytesGetItemWithSlice() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
// PY-19796
|
||||
public void testOrd() {
|
||||
doTest();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -297,6 +297,16 @@ public class PyTypeCheckerInspectionTest extends PyTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
// PY-20460
|
||||
public void testStringGetItemWithSlice() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
// PY-20460
|
||||
public void testUnicodeGetItemWithSlice() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
// PY-19884
|
||||
public void testAbsSetAndMutableSet() {
|
||||
doTest();
|
||||
|
||||
Reference in New Issue
Block a user