• sugar_in_your_tea@sh.itjust.works
    link
    fedilink
    arrow-up
    1
    arrow-down
    1
    ·
    1 day ago

    That’s why there’s type hinting, unit tests, and doc strings. I don’t need to guess what the type is intended to be, I can see it.

      • sugar_in_your_tea@sh.itjust.works
        link
        fedilink
        arrow-up
        1
        ·
        19 hours ago

        What’s the extra logic?

        if x:
        

        This always evaluates to True if it’s non-empty. There’s no extra logic.

        If you have to keep 12 things in your head, your code is poorly structured/documented. A given function should be simple, making it plainly obvious what it’s intended to do. Use type hints to specify what a variable should be, and use static analysis to catch most deviations. The more you trust your tools, the more assumptions you can safely make.