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
This commit is contained in:
Rasmus Wriedt Larsen
2019-09-26 13:03:52 +02:00
parent 546405a379
commit 457794e030
7 changed files with 23 additions and 23 deletions

View File

@@ -5,14 +5,14 @@
<overview>
<p> The first argument of a class method, a new method or any metaclass method
should be called <code>cls</code>. This makes the purpose of the argument clear to other developers.
<p> The first parameter of a class method, a new method or any metaclass method
should be called <code>cls</code>. This makes the purpose of the parameter clear to other developers.
</p>
</overview>
<recommendation>
<p>Change the name of the first argument to <code>cls</code> as recommended by the style guidelines
<p>Change the name of the first parameter to <code>cls</code> as recommended by the style guidelines
in PEP 8.</p>
</recommendation>

View File

@@ -1,7 +1,7 @@
/**
* @name First parameter of a class method is not named 'cls'
* @description Using an alternative name for the first argument of a class method makes code more
* difficult to read; PEP8 states that the first argument to class methods should be 'cls'.
* @description Using an alternative name for the first parameter of a class method makes code more
* difficult to read; PEP8 states that the first parameter to class methods should be 'cls'.
* @kind problem
* @tags maintainability
* readability
@@ -38,10 +38,10 @@ not first_arg_cls(f) and classmethod_decorators_only(f) and
not f.getName() = "__new__" and
(
if exists(f.getArgName(0)) then
message = "Class methods or methods of a type deriving from type should have 'cls', rather than '" +
f.getArgName(0) + "', as their first argument."
message = "Class methods or methods of a type deriving from type should have 'cls', rather than '" +
f.getArgName(0) + "', as their first parameter."
else
message = "Class methods or methods of a type deriving from type should have 'cls' as their first argument."
message = "Class methods or methods of a type deriving from type should have 'cls' as their first parameter."
)
select f, message

View File

@@ -1,9 +1,9 @@
class Point:
def __init__(val, x, y): # first argument is mis-named 'val'
def __init__(val, x, y): # first parameter is mis-named 'val'
val._x = x
val._y = y
class Point2:
def __init__(self, x, y): # first argument is correctly named 'self'
def __init__(self, x, y): # first parameter is correctly named 'self'
self._x = x
self._y = y

View File

@@ -1,7 +1,7 @@
/**
* @name First argument of a method is not named 'self'
* @description Using an alternative name for the first argument of an instance method makes
* code more difficult to read; PEP8 states that the first argument to instance
* @name First parameter of a method is not named 'self'
* @description Using an alternative name for the first parameter of an instance method makes
* code more difficult to read; PEP8 states that the first parameter to instance
* methods should be 'self'.
* @kind problem
* @tags maintainability