Readit News logoReadit News
hynek commented on Litestar is worth a look   b-list.org/weblog/2025/au... · Posted by u/todsacerdoti
whilenot-dev · 20 days ago
If you're referring to this[0] GitHub project I'd highly disagree. I will never understand the minds of people that structure their apps like this:

  app
  ├── controllers
  │   ├── task.py
  │   └── user.py
  ├── models
  │   ├── task.py
  │   └── user.py
  ├── repositories
  │   ├── task.py
  │   └── user.py
  └── schemas
      ├── extras
      │   ├── current_user.py
      │   ├── health.py
      │   └── token.py
      ├── requests
      │   ├── tasks.py
      │   └── users.py
      └── responses
          ├── tasks.py
          └── users.py
A structure around mini apps always turns out to be more beneficial for keeping boundaries intact in the long run:

  apps
  ├── tasks
  │   ├── controller.py
  │   ├── models.py
  │   ├── repository.py
  │   ├── schemas.py
  │   └── service.py
  └── users
      ├── controller.py
      ├── models.py
      ├── repository.py
      ├── schemas.py
      └── service.py
[0]: https://github.com/iam-abbas/FastAPI-Production-Boilerplate

hynek · 20 days ago
The fancy word for that is Vertical Slice Architecture btw and it's the only way for complex apps that doesn't end in chaos.
hynek commented on “Don’t mock what you don't own” in 5 minutes (2022)   hynek.me/articles/what-to... · Posted by u/JNRowe
molf · 2 months ago
But ultimately it suggests this test; which only tests an empty loop?

  def test_empty_drc():
      drc = Mock(
          spec_set=DockerRegistryClient,
          get_repos=lambda: []
      )

      assert {} == get_repos_w_tags_drc(drc)
Maybe it's just a poor example to make the point. I personally think it's the wrong point to make. I would argue: don't mock anything _at all_ – unless you absolutely have to. And if you have to mock, by all means mock code you don't own, as far _down_ the stack as possible. And only mock your own code if it significantly reduces the amount of test code you have to write and maintain.

I would not write the test from the article in the way presented. I would capture the actual HTTP responses and replay those in my tests. It is a completely different approach.

hynek · 2 months ago
Yes, because it's showing how the simplest-possible mock already gets ugly if you don't follow the advice. Making the example more complicated would dilute the point it's making.

The question of "when to mock" is very interesting and dear to my heart, but it's not the question this article is trying to answer.

hynek commented on “Don’t mock what you don't own” in 5 minutes (2022)   hynek.me/articles/what-to... · Posted by u/JNRowe
molf · 2 months ago
I’m not sure this is good advice. I prefer to test as much of the stack as possible. The most common mistake I see these days is people testing too much in isolation, which leads to a false sense of safety.

If you care about being alerted when your dependencies break, writing only the kind of tests described in the article is risky. You’ve removed those dependencies from your test suite. If a minor library update changes `.json()` to `.parse(format="json")`, and you assumed they followed semver but they didn’t: you’ll find out after deployment.

Ah, but you use static typing? Great! That’ll catch some API changes. But if you discover an API changed without warning (because you thought nobody would ever do that) you’re on your own again. I suggest using a nice HTTP recording/replay library for your tests so you can adapt easily (without making live HTTP calls in your tests, which would be way too flaky, even if feasible).

I stopped worrying long ago about what is or isn’t “real” unit testing. I test as much of the software stack as I can. If a test covers too many abstraction layers at once, I split it into lower- and higher-level cases. These days, I prefer fewer “poorly” factored tests that cover many real layers of the code over countless razor-thin unit tests that only check whether a loop was implemented correctly. While risking that the whole system doesn’t work together. Because by the time you get to write your system/integration/whatever tests, you’re already exhausted from writing and refactoring all those near-pointless micro-tests.

hynek · 2 months ago
> I’m not sure this is good advice. I prefer to test as much of the stack as possible. The most common mistake I see these days is people testing too much in isolation, which leads to a false sense of safety.

You make it sounds as if the article would argue for test isolation which it emphatically doesn't. It in fact even links out to the Mock Hell talk.

Every mock makes the test suite less meaningful and the question the article is trying to answer is how to minimize the damage the mocks do to your software if you actually need them.

hynek commented on Design Pressure: The Invisible Hand That Shapes Your Code   hynek.me/talks/design-pre... · Posted by u/NeutralForest
moozilla · 3 months ago
Here's an attempt at cleaning it up with Gemini 2.5 Pro: https://rentry.org/nyznvoy5

I just pasted the YouTube link into AI Studio and gave it this prompt if you want to replicate:

reformat this talk as an article. remove ums/ahs, but do not summarize, the context should be substantively the same. include content from the slides as well if possible.

hynek · 3 months ago
Pretty good, except it’s not Bismarck but Fontane. ;) Also, I’m comparing myself to CGP Grey, not whatever it’s transcribed. :D
hynek commented on Design Pressure: The Invisible Hand That Shapes Your Code   hynek.me/talks/design-pre... · Posted by u/NeutralForest
vinipolicena · 3 months ago
Parts of the talk remind me of https://www.amundsens-maxim.com/
hynek · 3 months ago
ha, I wish I saw that while working on that talk! adding it to the resources!
hynek commented on Design Pressure: The Invisible Hand That Shapes Your Code   hynek.me/talks/design-pre... · Posted by u/NeutralForest
HappMacDonald · 3 months ago
There are certainly times I would love to see a presentation like this reformatted as an article.

I tried pulling out the Youtube transcript, but it was very uncomfortable to read with asides and jokes and "ums" that are all native artifacts of speaking in front of a crowd but that only represent noise in when converted to long written form.

hynek · 3 months ago
Shouldn't some AI be able to clean that up for you? This seems something LLMs should be well-suited for.

---

FWIW, I'm the speaker and let me be honest with you: I'm super unmotivated to write nowadays.

In the past, my usual MO was writing a bunch of blog posts and submit the ones that resonated to CfPs (e.g. <https://hynek.me/articles/python-subclassing-redux/> → <https://hynek.me/talks/subclassing/>).

However, nowadays thanks to the recent-ish changes in Twitter and Google, my only chance to have my stuff read by a nontrivial amount of people is hitting HN frontage which is a lottery. It's so bad I even got into YouTubing to get a roll at the algorithm wheel.

It takes (me) a lot of work to crystallize and compress my thoughts like this. Giving it as a talk at a big conference, at least opens the door to interesting IRL interactions which are important (to me), because I'm an introvert.

I can't stress enough how we're currently eating the seed corn by killing the public web.

hynek commented on Design Pressure: The Invisible Hand That Shapes Your Code   hynek.me/talks/design-pre... · Posted by u/NeutralForest
wilkystyle · 3 months ago
> I'm not sure I'd take design advice from someone who thought attr.ib and attr.s were a good idea

Can you elaborate?

hynek · 3 months ago
that's a reference to my attrs library which is what data classes are based on. It originally used

    @attr.s
    class C:
        x = attr.ib()
as its main api (with `attr.attrs` and `attr.attrib` as serious business aliases so you didn't have to use it).

That API was always polarizing, some loved it, some hated it.

I will point out though, that it predates type hints and it was an effective way to declare classes with little "syntax noise" which made it easy to write but also easy to read, because you used the import name as part of the APIs.

Here is more context: https://www.attrs.org/en/stable/names.html

I REGRET NOTHING

hynek commented on Production-ready Docker Containers with uv   hynek.me/articles/docker-... · Posted by u/tosh
greener_grass · a year ago
Why was UV created when we already have PDM and Poetry?

Genuine question, we are drowning in options here!

hynek · a year ago
Both PDM and Poetry are a) 90% solutions that only cover what their respective authors need (and this is indeed what Python is drowning in) and b) written in Python which makes them slow and somewhat janky since Python installations and virtualenvs tend to break (lol Homebrew).

I personally love PDM, and PDM is in the process of adopting uv’s lower-leveln functionality to install/resolve packages, but I can see how having a single binary for bootstrapping a whole dev environment is really nice.

In the end, uv’s biggest upside is that it has several people work 8h / day on it and one would be surprised how much can be achieved in such amount of time.

hynek commented on Production-ready Docker Containers with uv   hynek.me/articles/docker-... · Posted by u/tosh
timeon · a year ago
That is what Rye is for.
hynek · a year ago
That is inaccurate. Both Rye and uv have the same goals and support virtualenvs.

uv is meant to supplant Rye eventually (it mostly already has: see also this post by the creator of Rye: <https://lucumr.pocoo.org/2024/8/21/harvest-season/>). But you can’t put a virtualenv into a Kubernetes, so Docker containers are still interesting if that’s something you want to do.

hynek commented on Production-ready Docker Containers with uv   hynek.me/articles/docker-... · Posted by u/tosh
ssahoo · a year ago
What is the benefit of using uv over pip if it's inside a container? Pythons virtual environment is not enough?
hynek · a year ago
It’s much, much faster both in creating virtualenvs and installing the dependencies. And if you use lock/sync, you get a cross-platform lockfile that you only got with PDM and Poetry before – no more requirements.txt (but it supports it too).

u/hynek

KarmaCake day819March 26, 2009
About
I’m a software engineer at an ISP and spend too much time on FOSS.

aspe:keyoxide.org:5KLULPTEPFVHZUBX2QRS4XM2M4

View Original