Hacker News new | ask | show | jobs
by b3orn 950 days ago
Nope, don't like it. It's also a little disingenuous to switch the example halfway through. Anyway, I fixed your code, with exceptions

    def get_user(user_id: str) -> User:
        rows = users.find(user_id=user_id)
        if not rows:
            raise Exception("user not found")
        return rows[0]

    def rename_user(user_id: str, name: str) -> User:
        user = get_user(user_id)
        user.name = name
        return user, None