Skip to content
Merged
18 changes: 15 additions & 3 deletions Pylint-line-too-long.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,21 @@ Pattern: Line too long
Issue: -

## Description
Your source code should not contain very long lines. If you have very long lines you should break it up into multiple lines. When code is not easily visible it's difficult to understand what it does. Use the `\` character at the end of a line to tell the Python interpreter that the statement continues on the next line. Here is an example of how to break up a long boolean expression into three lines.
```python
if ( ((blah < 0 ) and (grr > 234)) \
or ((foo == 3456) and (grr <= 4444)) \
or ((blah > 10) and (grr == 3333)) \
):
print "this crazy condition is true"
print "and my code is really easy to read because"
print "I didn't wrap lines!"

Used when a line is longer than a given number of characters.
else:
print "this crazy condition is false"
```
By default PEP 8 recommends 79 - 99 characters per line, but we are very liberal so we made it 159 characters per line just for you.
You can set `max-line-length` in Pylint configuration file depending on your needs.

## Further Reading

* [Pylint - C0301](http://pylint-messages.wikidot.com/messages:c0301)
* [Pylint - C0301](http://pylint-messages.wikidot.com/messages:c0301)
15 changes: 8 additions & 7 deletions Pylint-unused-variable.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,19 @@ Issue: -

## Description

Variables that are declared and not used in the code are most likely an error due to incomplete refactoring. Such variables take up space in the code and can lead to confusion by readers. Use or remove them to resolve this issue.
Variables that are declared and not used anywhere in the code are most likely an error resulting from incomplete refactoring. Such variables take up space in the code and can lead to confusion by readers. Use or remove them to resolve this issue.


Example of **incorrect** code:
```python
def some_method(firstArg):
test = "123" # [unused-variable]
return firstArg*2
number = 100

print "Program contains unused variable"
```

Example of **correct** code:
```python
def some_method(firstArg):
return firstArg*2
```
number = 100

print number;
```