mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Correctly handle __new__'s first param, staticmethod or not.
This commit is contained in:
@@ -111,18 +111,8 @@ public class PyMethodParametersInspection extends PyInspection {
|
||||
return;
|
||||
}
|
||||
}
|
||||
// TODO: check for style settings
|
||||
String CLS = "cls";
|
||||
if (flags.contains(CLASSMETHOD) || isSpecialMetaclassMethod) {
|
||||
if (!CLS.equals(pname)) {
|
||||
registerProblem(
|
||||
PyUtil.sure(params[0].getNode()).getPsi(),
|
||||
PyBundle.message("INSP.usually.named.$0", CLS),
|
||||
new RenameParameterQuickFix(CLS)
|
||||
);
|
||||
}
|
||||
}
|
||||
else if (isMetaclassMethod && PyNames.NEW.equals(method_name)) {
|
||||
String CLS = "cls"; // TODO: move to style settings
|
||||
if (isMetaclassMethod && PyNames.NEW.equals(method_name)) {
|
||||
final String[] POSSIBLE_PARAM_NAMES = {"typ", "meta"}; // TODO: move to style settings
|
||||
if (!among(pname, POSSIBLE_PARAM_NAMES)) {
|
||||
registerProblem(
|
||||
@@ -132,6 +122,15 @@ public class PyMethodParametersInspection extends PyInspection {
|
||||
);
|
||||
}
|
||||
}
|
||||
else if (flags.contains(CLASSMETHOD) || isSpecialMetaclassMethod || PyNames.NEW.equals(method_name)) {
|
||||
if (!CLS.equals(pname)) {
|
||||
registerProblem(
|
||||
PyUtil.sure(params[0].getNode()).getPsi(),
|
||||
PyBundle.message("INSP.usually.named.$0", CLS),
|
||||
new RenameParameterQuickFix(CLS)
|
||||
);
|
||||
}
|
||||
}
|
||||
else if (!is_staticmethod && !first_param.isPositionalContainer() && !PyNames.CANONICAL_SELF.equals(pname)) {
|
||||
if (isMetaclassMethod && CLS.equals(pname)) {
|
||||
return; // accept either 'self' or 'cls' for all methods in metaclass
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
<problem>
|
||||
<file>first_arg.py</file>
|
||||
<line>65</line>
|
||||
<description>Usually first parameter of such methods is named 'cls'</description>
|
||||
<description>Usually first parameter of such methods is named 'typ'</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>first_arg.py</file>
|
||||
|
||||
Reference in New Issue
Block a user