pep8 is not enough
TRANSCRIPT
ealthy practices for happy and successful codebase
Misha Behersky KyivPy, September, 2016
Code style
2
Same code
3
Bearsharktopus
4
pep8 is not enough
Grid, vertical, hanging indent, vertical hanging indent, hanging grid...
5
isort
standard library modules
third-party modules
user-defined modules
6
pycodestyle, pyflakes, pylint, pychecker, etc.
● No global found ● Passing the wrong number of parameters● Using format strings that don't match arguments● Using a variable before setting it● self is not the first parameter defined for a method● Unused function/method arguments (can ignore self)● No doc strings in modules, classes, functions● ...
7
tick with strict rules
8
Managing requirements
9
pgrade fast
pypiup pip-tools
10
Dependency hell
11
Environments
● Develop in env that is as close as possible to production one
● Test in all possible envs that your app might run● Select your favourite IDE and use it)
12
Testing
● Test what's likely to break● Test negative cases and edge cases● If writing tests is hard, that might be a bug● Aggressively make your test suite fast and reliable● Run it automatically
13
Flaky???
● If it’s flaky it’s not a test*● Stop calling your build flaky*
*If I was in my office I would bite my tongue14
o not write tests
15
rief is not better
16
self-descriptive speaks for itself
17
Overcommunicate
18
Naming
19
utomate routine
20
Put your two cents in
21
ail early
22
ail early
23
ail early
24
Dream within a dream
25
elete code as soon as you know you don't need it any more, no questions asked
26
vulture
27
Are you ready?
28
ime is the only resource you truly need
29
easure everything
30
Wakatime
31
cloc
32
Toggl
33
Other toolshttps://github.com/madisonmay/BlackWidow
34
https://github.com/mschwager/cohesion
https://github.com/Yelp/undebt
ecap
● Play stupid● If you don’t try, you’ll never know● Save your energy for something better than
programming work● Consider and reason● …● ???● PROFIT!
35
esources
https://github.com/timothycrosley/isort [6]
http://www.kennethreitz.org/essays/a-better-pip-workflow [10]
https://github.com/ekonstantinidis/pypiup [10]
http://semver.org [11]
https://tox.readthedocs.io/en/latest/ [12]
http://holger-peters.de/using-pyenv-and-tox.html [12]
https://eev.ee/blog/2016/08/22/testing-for-people-who-hate-testing [13]
https://github.com/box/flaky [14]
http://martinfowler.com/bliki/TwoHardThings.html [19]
https://github.com/myint/vulture [27]
http://bmwlog.pp.ua/post/105 [32]
36
&
37
e are hiring
datarobot.com/careers/38
hanks for your attention
bmwlog.pp.ua
@bmwant
39