News for hackers. Stuff that matters.
Re:Our journey to type checking 4M lines of Python by dbcurtis on Saturday September 07, 2019 @11:48PM (#20908497)
Most of what you say I agree with. But it is actually very easy to construct a __init__ that handles a very flexible parameter list. That style is well represented in the standard library. And I find that writing a beefy constructor simplifies parameter validation in methods.

But certainly, it doesn’t remove the need for good test coverage. Now, if you want to argue for less testing, that is a different pitch.

Re:Our journey to type checking 4M lines of Python by joshuamorton on Sunday September 08, 2019 @12:23AM (#20908586)
Possible, yes. Easy and straightforward, no. Casework and duck-type checks over args and *kwargs are not easy to maintain going forward, especially for a non-expert in Python.

Factory methods are usually better, and I believe what the more modern parts of the standard library have tried to use, but they don't work as well for this specific case.

Re:Our journey to type checking 4M lines of Python by musingsole on Sunday September 08, 2019 @01:26PM (#20911904)
> Casework and duck-type checks over args and *kwargs

Once you start doing this in python -- beyond any low complexity usage -- you're better off capturing your arguments in their own object and passing this to the function as a single argument. This object can then enforce whatever you want, and your function can now be a class method.

And then you can build a factory for this object that accepts a few args, maybe some keyword parameters. But, once that gets reasonably complex, just rinse and repeat. It's objects, methods and factories all the way down. And unlimited billable hours.