mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-10-06 06:21:16 +07:00
PY-17828 Fixed: Wrong signature inspection false positive for __prepare__ method of metaclasses
Add __prepare__ to type's skeletons
This commit is contained in:
@@ -361,6 +361,14 @@ class type(object):
|
||||
"""
|
||||
return False
|
||||
|
||||
@staticmethod
|
||||
def __prepare__(metacls, name, bases):
|
||||
"""Used to create the namespace for the class statement.
|
||||
|
||||
:rtype: dict[str, unknown]
|
||||
"""
|
||||
return {}
|
||||
|
||||
|
||||
class enumerate(object):
|
||||
"""enumerate object."""
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
class MyType1(type):
|
||||
@staticmethod
|
||||
def __prepare__<warning descr="Signature of method 'MyType1.__prepare__()' does not match signature of base method in class 'type'">(metacls, name)</warning>:
|
||||
return {}
|
||||
|
||||
|
||||
class MyType2(type):
|
||||
@staticmethod
|
||||
def __prepare__(metacls, name, bases):
|
||||
return {}
|
||||
|
||||
|
||||
class MyType3(type):
|
||||
@staticmethod
|
||||
def __prepare__(metacls, name, bases, **kwargs):
|
||||
return {}
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.jetbrains.python;
|
||||
|
||||
import com.intellij.testFramework.LightProjectDescriptor;
|
||||
import com.jetbrains.python.fixtures.PyTestCase;
|
||||
import com.jetbrains.python.inspections.PyMethodOverridingInspection;
|
||||
import com.jetbrains.python.psi.LanguageLevel;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class Py3MethodOverridingInspectionTest extends PyTestCase {
|
||||
private static final String TEST_DIRECTORY = "inspections/PyMethodOverridingInspection/";
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
protected LightProjectDescriptor getProjectDescriptor() {
|
||||
return ourPy3Descriptor;
|
||||
}
|
||||
|
||||
// PY-17828
|
||||
public void testDunderPrepare() {
|
||||
runWithLanguageLevel(LanguageLevel.PYTHON30, this::doTest);
|
||||
}
|
||||
|
||||
private void doTest() {
|
||||
myFixture.configureByFile(TEST_DIRECTORY + getTestName(false) + ".py");
|
||||
myFixture.enableInspections(PyMethodOverridingInspection.class);
|
||||
myFixture.checkHighlighting(true, false, false);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user