#DailyPythonista

Borutzkiborutzki
2025-12-22

Out of nowhere I decided to describe briefly my approach to reuse model_validator (and any other validator) across multiple models.

Code snippet from image should do the job, full context is in the linked blog post.

borutzki.github.io/2025/12/22/

Code snippet showcasing reuse of model_validator across two Pydantic models.
Borutzkiborutzki
2025-10-16

Ever needed to check for root / admin privileges to make sure your Python script can work correctly?

In my last blog post, I provide you with approach for Linux, macOS and Windows to get this stuff done.

Happy hacking 🐍


borutzki.github.io/2025/10/16/

Borutzkiborutzki
2025-10-13

Writing a technical article - even very subjective one - is quite a lot of work, if one wants to cover the topic well and at the same point not write a book on it in one go.

Just wanted to say that after a writing session.

Used a bunch of guard clauses (refactoring.guru/pl/replace-ne) in text to state what the article is NOT about, to not waste my readers' computing power on reading something they're not interested in 😅

Still, it's work in progress. Until next time!

Borutzkiborutzki
2025-10-03

Finally, started working on a separate blog dedicated to technical stuff like , , , , , and so on.

In this first post I introduce myself and the purpose of the blog, then proceed to a bunch of quick examples of printing "hello world" in Python.

Even if you're not interested - come and see how to add padding to printed string in Python 🐍

borutzki.github.io/2025/10/03/

Borutzkiborutzki
2025-09-20

Finished reading "Working Effectively with Legacy Code" by Michael Feathers.

Even though some information from the book was useful, I feel like techniques proposed there don't stand up to current test frameworks with mocking systems.

Hence, most of the tips are not relevant in world.

I liked though was the angle author took on encapsulation and component boundaries, though.

Have you read the book? What did you like (or not) about it?

Borutzkiborutzki
2025-08-28

If you want to hear me talking about bad practices and how to mitigate their outcomes, sign up for conference happening October 23rd 🤖

Image below comes from the official announcement from LinkedIn, hopefully no one will get angry for posting it here 😬

Conference web page: wrobocon.eu/
LinkedIn announcement: linkedin.com/posts/wrobocon202

Borutzkiborutzki
2025-06-21

During my „side-project” I noticed that Gherkin style is great not only for describing behaviour of software. It’s also great for describing any kind of behaviour 🤖

Let’s make fun of my consistency of posting Python stuff here on mastodon:

Given I have an idea for new Python-related toot
And I don't write it down
When I want to write the toot
Then I don't remember what was the idea

Note that this also enables possibilities to "debug" and "explore" that behaviour further.

Borutzkiborutzki
2025-06-06

in Python, combination of `cache` and `staticmethod` decorators might cause bug in some cases.

It is caused by the fact that `cache` overrides `staticmethod` which no longer is a static method. Hence, it fails when called from class instance because it sees `self` as an unexpected argument - and TypeError is thrown.

See thiss StackOverflow thread for further reference.
stackoverflow.com/questions/76

Borutzkiborutzki
2025-06-03

Meanwhile, in universe, a new tool emerges that allows for setting up test dependencies.

So, for example if test X fails, then test Y does not make sense, hence is not executed.

It might be actually useful in many end-to-end scenarios, where the rule of keeping tests independent causes either a lot of repetition of costly operations.


pypi.org/project/robotframewor

Borutzkiborutzki
2025-06-02

If you ever ask why it’s worth updating dependencies from time to time, serves as a nice example with the performance boost introduced. I actually could see it, given the complexity of models I deal with on a daily basis.

> Recent memory usage optimizations are most relevant for projects with lots of models, particularly those with nested/reused models. In these cases, you can expect a 2-5x reduction in memory usage.


pydantic.dev/articles/pydantic

Borutzkiborutzki
2025-03-18

if you have to deal with lengthy tests in , you can split them to sub-tests.

There's a library `pytest-subtests` specifically for that. It basically introduces `subTest` functionality from `unittest` built-in to PyTest, so it is becomes possible to neatly structure complicated tests.

Especially useful for end-to-end-like tests that have to perform a bunch of operations in a sequence and validate output of each. 🐍


pypi.org/project/pytest-subtes

Borutzkiborutzki
2025-03-13

Ever heard of ? Hopefully you've never worked in one (but chances are, you have).

> Enter frupidity, or stupid frugality – the obsessive drive to save money in ways that ultimately cost far more in lost productivity, morale, and sanity. It’s the engineering equivalent of “optimizing” a car by removing the brakes to improve gas mileage.

Great read from @selix 👌

selix.net/notes/dont-be-frupid

Borutzkiborutzki
2025-03-10

Looks like now you can become "Robot Framework Certified Professional" for €240 🤖

Even if you don't plan to do the whole examination, it's worth taking a look on the syllabus. For me, it looks like a singular document that I would point to whenever asked by someone about "how to learn Robot Framework".

What do you think about such certification? Is it worth the price?


cert.robotframework.org/certif

Borutzkiborutzki
2025-03-07

What got me thinking today at work was how to test one massive set of transactions in with support of . One test is like 400 lines of code (multiple objects created and outputs created, “by design”).

Sounds like a neat challenge to tackle Monday morning.

Maybe anyone here tackled something like this? Tried splitting big test into smaller chunks and testing steps but with shared scope of variables and test database state?

Borutzkiborutzki
2025-03-04

@hynek thanks for the article on subclassing!

You had nice prediction - it was on my reading list for many months. Took me 1 big coffee to finish, but was worth it. I feel like I should take one more look to protocols in Python (which I used to use but different project and forgot the thing a bit) 🐍

Definitely one of the best takes on the topic of inheritance in Python.

hynek.me/articles/python-subcl

Borutzkiborutzki
2025-01-15

If you use and have a problem with not working, take a look on this incident update:
docker.com/blog/incident-updat

Borutzkiborutzki
2025-01-03

Cool thing I found on StackOverflow recently.

I tended to forget how to rename branch. Hence, this alias for the operation came in handy:

git config --global alias.rename 'branch -m'

Now, to change the name of a branch, the following can be used (no `<old_name>` needed when renaming current branch):

git rename <old_name> <new_name>

Will have to find something as clean for `git push origin -u <newname>` afterwards, though.

Borutzkiborutzki
2024-12-18

For some reason, I support newcomers at work recently.

What I tend to suggest as first tasks to do:
- code cleanups
- adding documentation / type hints
- writing unit tests

Why?
1. It requires reading code and getting familiar with it.
2. When something is unclear for a newcomer, it's a great feedback for more matured devs.
3. Onboarding without getting to the codebase is a nonsense.
4. It introduces newcomer to code delivery process.
5. It's useful.

Borutzkiborutzki
2024-12-17

Today I learned that class attributes are not resetted between unit tests in , so when I change some class attribute in test A, then test B will use such overwritten class attribute.

Seems like "fix" for that is to initialize the class first and then change class attribute on this instance, instead of doing this directly on the class definition.

Client Info

Server: https://mastodon.social
Version: 2025.07
Repository: https://github.com/cyevgeniy/lmst