You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: python/ql/src/Functions/NonSelf.qhelp
+4-8Lines changed: 4 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -6,22 +6,18 @@
6
6
7
7
<overview>
8
8
<p> Normal methods should have at least one parameter and the first parameter should be called <code>self</code>.
9
-
This makes the purpose of the parameter clear to other developers.
10
9
</p>
11
10
</overview>
12
11
13
12
<recommendation>
14
-
<p>If there is at least one parameter, then change the name of the first parameter to <code>self</code> as recommended by the style guidelines
13
+
<p>Ensure that the first parameterof a normal method is named <code>self</code>, as recommended by the style guidelines
15
14
in PEP 8.</p>
16
-
<p>If there are no parameters, then it cannot be a normal method. It may need to be marked as a <code>staticmethod</code>
17
-
or it could be moved out of the class as a normal function.
15
+
<p>If a <code>self</code> parameter is unneeded, the method should be decorated with <code>staticmethod</code>, or moved out of the class as a regular function.
18
16
</p>
19
17
</recommendation>
20
18
21
19
<example>
22
-
<p>The following methods can both be used to assign values to variables in a <code>point</code>
23
-
object. The second method makes the association clearer because the <code>self</code> parameter is
24
-
used.</p>
20
+
<p>In the following cases, the first argument of <code>Point.__init__</code> is named <code>val</code> instead; whereas in <code>Point2.__init__</code> it is correctly named <code>self</code>.</p>
25
21
<samplesrc="NonSelf.py" />
26
22
27
23
@@ -31,7 +27,7 @@ used.</p>
31
27
<li>Python PEP 8: <ahref="http://www.python.org/dev/peps/pep-0008/#function-and-method-arguments">Function and
0 commit comments