#DailyPythonista

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.

Borutzkiborutzki
2024-11-14

Didn’t have time to write a whole article on why readability matters, so just reduced it to a low-quality meme.

(now going back to continue refactoring some production code to at least barely understand how the new feature I develop can be implemented)

Borutzkiborutzki
2024-11-12

Today I started reading „Tidy First?” by Kent Beck. Short book with quick overview of possible non-breaking code cleanups (as opposed to Martin Fowler’s refactoring, I guess). I’m at about ~50% of its length now and can recommend this as something worth the time (given that it may take about 2 hours to read if you don't compulsively take notes during reading as I do).

Borutzkiborutzki
2024-10-31

Reading a book about was the right decision. Not only I’ve re-learned basic stuff. I’ve also learned possibilities I didn’t know were there.

Let’s take filesystem layers for example. Basically, each new instruction in Dockerfile adds a layer to image’s filesystem. And once layer is there, next instructions won’t delete it. They can only add.

Hence, you have to do a cleanup action immediately - or it doesn’t make sense.

Cool. And that’s only a tip of an iceberg 🐳

Borutzkiborutzki
2024-10-29

that can make doing JSON-heavy stuff in much more approachable and comprehensible. Stuff like data validation, modeling and overall handling - I wish I had the time to learn that way earlier.

Someday I want to learn how to connect that with data model. But first, I probably need to learn Django.

But not everything at once. Life is not university, no need to cram everything in one week.

Borutzkiborutzki
2024-10-28

I see that there are generally two ends of the spectrum:

1. Damn that, it works!
2. Damn that it works.

My take on this dichotomy? It’s better to focus on writing a code that can be easily understood than only to make it work. Computer will do what it’s asked for, but it won’t modify or fix the code itself (unless AI can do that, which I heard recently, may be the case). But it’s nice to understand as a human what is the computer asked for.

Borutzkiborutzki
2024-10-24

Increasing code coverage (with unit tests) is not only about writing unit tests. Removal of dead code can also be used to achieve it! 🚮

Borutzkiborutzki
2024-09-20

that if you use the reader function in your browser ( in my case), you can copy and paste the simplified version of the page to with formatting kept.

Not sure if it works for every page, but for one probably written in , even stuff like code snippets is properly formatted when pasted.

BTW, the article I wanted to save is this one about code greppability: morizbuesing.com/blog/greppabi

Borutzkiborutzki
2024-07-19

Something more basic today for .

From time to time, I have to remind myself what was the `sys.argv` content.

So, basically it's a list of strings. It can be accessed e.g. via iteration, like `for arg in sys.argv: print(arg)`

The first argument is always the name of the file applied.

Other arguments are given as strings on indexes matching their position - no off-by-one error in this case!

On the snippet: the loop proposed above, executed.

Client Info

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