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
This message indicates that line 117 either won't work or that the code has not been used at all.
54
49
55
50
#### Coding style
56
51
57
-
:::text
58
52
C: 32,0: Line too long (88/80)
59
53
C:134,16:Renumerator.get_identifiers_list: Operator not preceded by a space
60
54
61
55
Style issues regarding spaces, indentation and line lengths raised by pylint affect readability and are generally easy to fix.
62
56
63
57
#### Docstrings
64
58
65
-
:::text
66
59
C: 1,0: Missing docstring
67
60
68
61
Functions and classes without docstrings are more difficult to understand. If you get a lot of docstring warnings your code may be hard to understand for someone else.
69
62
70
63
#### Variable names
71
64
72
-
:::text
73
65
C:114,8:Renumerator.prepare_identifiers: Invalid name "fn" (should match [a-z_][a-z0-9_]{2,30}$)
74
66
75
67
Descriptive variable names are a big plus for code readability. Of course, it does not help much to replace **l** by **data_list** in order to satisfy pylint. But the name **fragment** tells you a lot more than **fn**.
@@ -78,7 +70,6 @@ Descriptive variable names are a big plus for code readability. Of course, it do
78
70
79
71
Pylint helps to analyze modularization by printing warning messages:
80
72
81
-
:::text
82
73
R: 19,0:Renumerator: Too many public methods (30/20)
83
74
R: 32,4:Renumerator.letter_generator: Method could be a function
84
75
R: 45,0:RNAResidue: Too many instance attributes (11/7)
@@ -94,7 +85,6 @@ To assess modularization of a program as a whole, pylint is not the right tool.
94
85
95
86
At the end of the pylint output you find a score of up to 10 points:
96
87
97
-
:::text
98
88
Your code has been rated at 8.18/10
99
89
100
90
When you have fixed some of the issues, re-run pylint and see your score improve. The score directly measures your success and makes working with pylint very rewarding.
@@ -109,7 +99,6 @@ A good practice is to disable some types of warnings (those you and your team ag
109
99
110
100
To ignore PEP8 warnings, create a file `.pylintrc` in your project directory. `pylint` finds it automatically. There you can list the types of warnings you would like to disable:
Copy file name to clipboardExpand all lines: folders.md
-6Lines changed: 0 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,7 +12,6 @@ A **Python package** is simply a folder that contains `.py` files.
12
12
Create a folder `snake` inside your repository.
13
13
On the bash terminal, you would use
14
14
15
-
:::bash
16
15
mkdir snake
17
16
18
17
If your git repository is also called `snake`, you may want to rename your project folder to something else like `snake_project`, `snake_repo` or similar.
@@ -26,7 +25,6 @@ You will also want to have a place where you add test code later.
26
25
Name that folder `tests/`.
27
26
We will leave it empty for now.
28
27
29
-
:::bash
30
28
mkdir tests
31
29
32
30
----
@@ -37,7 +35,6 @@ You may want to create a Python module (a `.py` file) to make sure everything is
37
35
Create a file `game.py` inside the `snake/` folder.
38
36
Add a placeholder function to it:
39
37
40
-
:::python3
41
38
def play_snake():
42
39
print('this is a snake game')
43
40
@@ -59,14 +56,12 @@ Importing the `play_snake()` function to play the game is a bit inconvenient.
59
56
Let's create a shortcut.
60
57
Create a file named `__main__.py` (with double underscores on both ends) in the package folder that contains the following code:
61
58
62
-
:::python3
63
59
from game import play_snake
64
60
65
61
play_snake()
66
62
67
63
Now it should be possible to start the game by typing:
68
64
69
-
:::text
70
65
python snake
71
66
72
67
----
@@ -75,7 +70,6 @@ Now it should be possible to start the game by typing:
75
70
76
71
At this point, your project folder should contain:
Copy file name to clipboardExpand all lines: good_software.md
-2Lines changed: 0 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -35,8 +35,6 @@ When you use a program, you need to be 100% sure that it does exactly what you t
35
35
36
36
Each scientific program should include at least one set of sample data. There should be an instruction how to use the sample data and exactly what output it produces. Sometimes, this approach is broken down into small steps: a cookbook explaining small actions and their effect. Eventually, you will find an automatic test suite. This is a script that automatically checks whether different parts of the program work correctly. When you see a message like
37
37
38
-
39
-
:::text
40
38
110 of 110 tests OK.
41
39
42
40
you know that at least everything the developers felt important to check works.
Copy file name to clipboardExpand all lines: loc.md
-2Lines changed: 0 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,12 +9,10 @@ More code means more work. The amount of code gives you a ballpark figure of how
9
9
10
10
You can count the total number of files on Unix:
11
11
12
-
:::bash
13
12
find . -name "*.py" | wc -l
14
13
15
14
A common metric is the number of **lines of code (LOC)**. The following command gives you the total number of LOC for all Python files in a Python directory tree:
16
15
17
-
:::bash
18
16
find . -name "*.py" | xargs wc -l
19
17
20
18
Empty lines, docstrings and comments are counted, too, as they are part of the source code.
0 commit comments