- 2022-07-11 –, Wicklow Hall 1
- 2022-07-11 –, Wicklow Hall 1
All times in Europe/Dublin
Despite a ton of wonderful linters out there, it pays off to scratch your itch and learn how to write one yourself. Anytime a pet peeve starts bothering you in code reviews, you’ll have all the tools at your disposal.
Developers are opinionated, and it reflects in their programming style — not just the way code looks, but how it feels: its organization and readability. In such cases, maintaining consistency across a project helps everyone involved. One aspect of this is ensuring that there are (at least partial) automated tests to enforce this style.
This training aims to enable the audience to write such tests by giving them a tour of code analysis and the vast array of tools it makes available to us. First, we dissect the code using Python's ast
and tokenize
modules and object internals like __dict__
. From there and on, we visit some real-world examples:
- A test to detect unnecessary use of double-quotes. They are such a terrible waste of pixels, after all.
- Flagging the use of list() instead of []. The former is slower – as it requires an extra lookup in "globals" – and might result in a bug if the name is rebound to another object.
- Find if statements are nested for more than four levels. It can lead to hard-to-understand, ugly-looking code.
- Look for unused imports. Shred the extra loading time and memory amounting from these unused lines of code.
some
Expected audience expertise: Python:some
Abstract as a tweet:There's some comments you find yourself make more and more often when reviewing Pull Requests. Let's automate it.
I'm a senior software engineer at https://deepsource.io, where I work on developing tools to improve code health and quality.
I'm the maintainer of Vulture, and it will have your dead Python. Thank you!