Skip to content

Commit 457794e

Browse files
committed
Python: Consistenly use parameter instead of argument in docs
The Python 3 FAQ states that this is the right thing [0] It sadly doesn't align 100% with PEP8, which calls them for "arguments" [1], but after discussion with Taus, we decided to go with "parameter" everywhere to be consistent. [0] https://docs.python.org/3/faq/programming.html#faq-argument-vs-parameter [1] https://www.python.org/dev/peps/pep-0008/#function-and-method-arguments
1 parent 546405a commit 457794e

File tree

7 files changed

+23
-23
lines changed

7 files changed

+23
-23
lines changed

python/ql/src/Functions/NonCls.qhelp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55

66

77
<overview>
8-
<p> The first argument of a class method, a new method or any metaclass method
9-
should be called <code>cls</code>. This makes the purpose of the argument clear to other developers.
8+
<p> The first parameter of a class method, a new method or any metaclass method
9+
should be called <code>cls</code>. This makes the purpose of the parameter clear to other developers.
1010
</p>
1111

1212
</overview>
1313
<recommendation>
1414

15-
<p>Change the name of the first argument to <code>cls</code> as recommended by the style guidelines
15+
<p>Change the name of the first parameter to <code>cls</code> as recommended by the style guidelines
1616
in PEP 8.</p>
1717

1818
</recommendation>

python/ql/src/Functions/NonCls.ql

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @name First parameter of a class method is not named 'cls'
3-
* @description Using an alternative name for the first argument of a class method makes code more
4-
* difficult to read; PEP8 states that the first argument to class methods should be 'cls'.
3+
* @description Using an alternative name for the first parameter of a class method makes code more
4+
* difficult to read; PEP8 states that the first parameter to class methods should be 'cls'.
55
* @kind problem
66
* @tags maintainability
77
* readability
@@ -38,10 +38,10 @@ not first_arg_cls(f) and classmethod_decorators_only(f) and
3838
not f.getName() = "__new__" and
3939
(
4040
if exists(f.getArgName(0)) then
41-
message = "Class methods or methods of a type deriving from type should have 'cls', rather than '" +
42-
f.getArgName(0) + "', as their first argument."
41+
message = "Class methods or methods of a type deriving from type should have 'cls', rather than '" +
42+
f.getArgName(0) + "', as their first parameter."
4343
else
44-
message = "Class methods or methods of a type deriving from type should have 'cls' as their first argument."
44+
message = "Class methods or methods of a type deriving from type should have 'cls' as their first parameter."
4545
)
4646

4747
select f, message

python/ql/src/Functions/NonSelf.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
class Point:
2-
def __init__(val, x, y): # first argument is mis-named 'val'
2+
def __init__(val, x, y): # first parameter is mis-named 'val'
33
val._x = x
44
val._y = y
5-
5+
66
class Point2:
7-
def __init__(self, x, y): # first argument is correctly named 'self'
7+
def __init__(self, x, y): # first parameter is correctly named 'self'
88
self._x = x
99
self._y = y

python/ql/src/Functions/NonSelf.ql

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
2-
* @name First argument of a method is not named 'self'
3-
* @description Using an alternative name for the first argument of an instance method makes
4-
* code more difficult to read; PEP8 states that the first argument to instance
2+
* @name First parameter of a method is not named 'self'
3+
* @description Using an alternative name for the first parameter of an instance method makes
4+
* code more difficult to read; PEP8 states that the first parameter to instance
55
* methods should be 'self'.
66
* @kind problem
77
* @tags maintainability
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
| argument_names.py:17:5:17:24 | Function n_cmethod | Class methods or methods of a type deriving from type should have 'cls', rather than 'self', as their first argument. |
2-
| argument_names.py:22:5:22:21 | Function n_cmethod2 | Class methods or methods of a type deriving from type should have 'cls' as their first argument. |
3-
| argument_names.py:37:5:37:20 | Function c_method | Class methods or methods of a type deriving from type should have 'cls', rather than 'y', as their first argument. |
1+
| parameter_names.py:17:5:17:24 | Function n_cmethod | Class methods or methods of a type deriving from type should have 'cls', rather than 'self', as their first parameter. |
2+
| parameter_names.py:22:5:22:21 | Function n_cmethod2 | Class methods or methods of a type deriving from type should have 'cls' as their first parameter. |
3+
| parameter_names.py:37:5:37:20 | Function c_method | Class methods or methods of a type deriving from type should have 'cls', rather than 'y', as their first parameter. |
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
| argument_names.py:50:5:50:20 | Function __init__ | Normal methods should have 'self', rather than 'x', as their first parameter. |
2-
| argument_names.py:53:5:53:20 | Function s_method | Normal methods should have 'self', rather than 'y', as their first parameter. |
3-
| argument_names.py:56:5:56:20 | Function s_method2 | Normal methods should have at least one parameter (the first of which should be 'self'). |
41
| om_test.py:71:5:71:19 | Function __repr__ | Normal methods should have at least one parameter (the first of which should be 'self'). |
2+
| parameter_names.py:50:5:50:20 | Function __init__ | Normal methods should have 'self', rather than 'x', as their first parameter. |
3+
| parameter_names.py:53:5:53:20 | Function s_method | Normal methods should have 'self', rather than 'y', as their first parameter. |
4+
| parameter_names.py:56:5:56:20 | Function s_method2 | Normal methods should have at least one parameter (the first of which should be 'self'). |

python/ql/test/query-tests/Functions/general/argument_names.py renamed to python/ql/test/query-tests/Functions/general/parameter_names.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# Using name other than 'self' for first argument in methods.
2-
# This shouldn't apply to classmethods (first argument should be 'cls' or similar)
3-
# or static methods (first argument can be anything)
1+
# Using name other than 'self' for first parameter in methods.
2+
# This shouldn't apply to classmethods (first parameter should be 'cls' or similar)
3+
# or static methods (first parameter can be anything)
44

55

66
class Normal(object):

0 commit comments

Comments
 (0)