Skip to content

Commit 01176c3

Browse files
committed
Added links in invalid-name details and attempted to de-dupe double comments from pylint. Also added _ to explicitly disallowed names.
1 parent 0ce2c11 commit 01176c3

3 files changed

Lines changed: 19 additions & 25 deletions

File tree

‎lib/common/.pylintrc‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ method-naming-style=snake_case
4848
inlinevar-naming-style=snake_case
4949

5050
# Include a hint for the correct naming format with invalid-name.
51-
include-naming-hint=yes
51+
include-naming-hint=no
5252

5353
# Bad variable names which should always be refused, separated by a comma.
5454
bad-names=x,
@@ -59,7 +59,8 @@ bad-names=x,
5959
b,
6060
j,
6161
o,
62-
z
62+
z,
63+
_
6364

6465
# Good variable names which should always be accepted, separated by a comma.
6566
good-names=main,

‎lib/common/pylint_comments.py‎

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -64,21 +64,26 @@ def generate_pylint_comments(in_path, pylint_spec='/opt/analyzer/lib/common/.pyl
6464
continue
6565

6666
if line[2] in {"C0114 missing-module-docstring",
67+
"C0115 missing-class-docstring",
6768
"C0116 missing-function-docstring",
6869
"C0304 missing-final-newline"}:
6970

7071
status_type = status_mapping['informational']
7172
else:
7273
status_type = status_mapping[line[0]]
7374

74-
pylint_comments.append(Comment(type=status_type,
75-
params={'lineno': line[1],
76-
'code': line[2],
77-
'message': ', '.join(line[3:]),
78-
'bad_code': f'Instead of: \n```python\n{bad}```\n\n' if bad else None,
79-
'good_code': f'Try: \n```python\n{good}```\n\n' if good else None,
80-
'related_info': related,
81-
'details': details},
82-
comment=f'python.pylint.{line[0]}'))
75+
new_comment = Comment(type=status_type,
76+
params={'lineno': line[1],
77+
'code': line[2],
78+
'message': ', '.join(line[3:]),
79+
'bad_code': f'Instead of: \n```python\n{bad}```\n\n' if bad else None,
80+
'good_code': f'Try: \n```python\n{good}```\n\n' if good else None,
81+
'related_info': related,
82+
'details': details},
83+
comment=f'python.pylint.{line[0]}')
84+
85+
86+
if new_comment not in pylint_comments:
87+
pylint_comments.append(new_comment)
8388

8489
return pylint_comments
Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,4 @@
1-
By default, Pylint will enforce
1+
By default, Pylint enforces
22
[PEP8](https://peps.python.org/pep-0008)-suggested names.
33

4-
The following naming suggestions are used for Exercism exercises:
5-
6-
- modules (code files): snake_case
7-
- constants: UPPER_CASE
8-
- variables: snake_case (minimum of 3 letters)
9-
- functions: snake_case
10-
- arguments: snake_case
11-
- attributes: snake_case
12-
- classes: PascalCase
13-
- class attributes: any (no specific format)
14-
- class constants: UPPER_CASE
15-
- class methods: snake_case
16-
- inline variables and loop variables: snake_case
4+
For more details on the pitfalls of `_` specifically, see this Stack Overflow [answer](https://stackoverflow.com/a/5893946) and [Underscores in Python](https://shahriar.svbtle.com/underscores-in-python) by Shahriar Tajbakhsh.

0 commit comments

Comments
 (0)