Metaclasses are mentioned among the most advances features of Python. Knowing how to write one is perceived like having a Python black belt. But are they useful at all outside job interviews or conference talks? Let’s find out! This article will show you 5 practical applications of metaclasses. What metaclasses are – quick recap Assuming […]
Category: python
What is Celery beat and how to use it – part 2, patterns and caveats
Celery beat is a nice Celery’s add-on for automatic scheduling periodic tasks (e.g. every hour). For more basic information, see part 1 – What is Celery beat and how to use it. In this part, we’re gonna talk about common applications of Celery beat, reoccurring patterns and pitfalls waiting for you. Ensuring a task is […]
When to use the Clean Architecture?
Enthusiasm, doubt, opposition There are few possible reactions after learning about the Clean Architecture or Hexagonal Architecture (AKA Ports & Adapters) or even merely innocent service layer in Django. Some developers are enthusiastic and try to apply these techniques immediately, some are hesitant, full of doubts. The rest is strongly opposing, declaring openly this is […]
How to mock in Python? – (almost) definitive guide
What is a mock? Mock is a category of so-called test doubles – objects that mimic the behaviour of other objects. They are meant to be used in tests to replace real implementation that for some reason cannot be used (.e.g because they cause side effects, like transferring funds or launching nukes). Mocks are used […]
mypy: how to use it in my project? Part 3: kick-ass tools that leverage type annotations
Type annotations are a formalized way to add some extra information about types to your project. Once you get through adding mypy to your project and annotate your code (remember you can do it automatically, at least to some extent) you will find yourself at the ocean of possibilities. This post will show the most […]
mypy: how to use it in my project? Part 2: automatically annotate code
Even after successful integration of mypy with an existing project (see mypy: how to use it in my project part 1), there are tons of code that does not have type annotations. Adding them manually is an unimaginable amount of work. We may do it gradually (as suggested in part 1) or use tools to […]
mypy: how to use it in my project?
Type annotations are like comments Type annotations are a great addition to Python. Thanks to them, finally our IDEs are able to provide good quality autocompletion. They did not turn Python into statically typed language, though. If you put a wrong annotation (or forget to update it after code change), Python will still happily try […]
Implementing the Clean Architecture with Python – my book is here!
It is my pleasure to announce that my book is finally available to buy. 🙂 https://leanpub.com/implementing-the-clean-architecture Free sample is available there as well. The books focuses on practical aspects and is illustrated with tons of code snippets in Python. Don’t forget to check out a code repository with the project which is illustrating the book: […]
The Clean Architecture in Python. How to write testable and flexible code
(Hey! This article is almost 2 years old 🙂 Look here for something about the Clean Archictecture in 2021) An ideal project? If someone asked about the features of an ideal project, responses would surely mention a few specific things. First of all, an ideal project would have a clean codebase that is simple to […]
Is your test suite wasting your time?
This article has been originally included in a PyconPL 2018 conference book. Abstract Nowadays there is no need for convincing anyone about the enormous advantages of writing automated tests for their code. Many developers had an occasion to feel total confidence in introducing changes to their codebases under the protection of vast test suites. The […]