▲ 333 ▼ Why make it complicated? (lemmy.ml) submitted 1 year ago* by HiddenLayer555@lemmy.ml to c/programmer_humor@programming.dev 123 comments fedilink hide all child comments Made with KolourPaint and screenshots from Kate (with the GitHub theme).
[+] iarigby@lemmy.world 7 points 1 year ago* (last edited 1 year ago) (6 children) [deleted] permalink fedilink source parent hideshow 6 child comments replies: [–] _stranger_@lemmy.world 7 points 1 year ago* (5 children) Dude, even just a "FY,I, you sure about this?" would be nice. I gladly embrace python's by-all-means-shotgun-your-leg-off philosophy, but the noobs could use the help. permalink fedilink source parent hideshow 5 child comments replies: [–] lime@feddit.nu 1 point 1 year ago (4 children) the problem is that the language doesn't and can't support one single way to use type annotations without changing fundamental functionality. you can absolutely hook up mypy to your editor for newbies, but once you get on the intermediate level, fighting with mypy takes more code than actually solving the problem. also there was that proposed update to mypy that was put on held when it turned out that the maintainers didn't know how annotations are used in the wild. permalink fedilink source parent hideshow 4 child comments replies: [–] _stranger_@lemmy.world 1 point 1 year ago (3 children) Oh I'm well aware. Took me a solid year to appreciate type annotations for what they are and yeah I'm happy using what we have in stdlib now and not messing with mypy tyvm. The problem is that history is lost to newcomers who have very different expectations. Modern IDE's mostly solve it though, so for all my Java peeps dipping their toes into the snake waters, listen to your ide permalink fedilink source parent hideshow 3 child comments replies: [–] lime@feddit.nu 1 point 1 year ago (2 children) i mean, i'm all for rejiggering the internals. i've personally written at least two libraries that uses type annotations in reverse to force arguments into the correct type, and i feel like that should probably be a separate mechanism to "just call the annotation" permalink fedilink source parent hideshow 2 child comments replies: [–] _stranger_@lemmy.world 1 point 1 year ago (1 child) dataclasses do this for you at the class level. They enforce type annotations at instantiation. https://docs.python.org/3/library/dataclasses.html permalink fedilink source parent hideshow 1 child comment replies: [–] lime@feddit.nu 1 point 1 year ago* (last edited 1 year ago) i think we're talking about different things. you use enforce to mean "validate", i used it to mean "coerce". one of the cases was a command line argument parser that consisted of a single decorator, so you could write @command def foo(bar: int, baz: float): print(baz * 2 + bar * 3) and call it with $ myfile.py foo --bar 3 --baz 2.2 and it would print 13.4 another was about creating working protocol buffers from an excel sheet, nested types and enums and oneofs and everything. we used it to parameterize tests of our bluetooth protocol. permalink fedilink source parent
[–] _stranger_@lemmy.world 7 points 1 year ago* (5 children) Dude, even just a "FY,I, you sure about this?" would be nice. I gladly embrace python's by-all-means-shotgun-your-leg-off philosophy, but the noobs could use the help. permalink fedilink source parent hideshow 5 child comments replies: [–] lime@feddit.nu 1 point 1 year ago (4 children) the problem is that the language doesn't and can't support one single way to use type annotations without changing fundamental functionality. you can absolutely hook up mypy to your editor for newbies, but once you get on the intermediate level, fighting with mypy takes more code than actually solving the problem. also there was that proposed update to mypy that was put on held when it turned out that the maintainers didn't know how annotations are used in the wild. permalink fedilink source parent hideshow 4 child comments replies: [–] _stranger_@lemmy.world 1 point 1 year ago (3 children) Oh I'm well aware. Took me a solid year to appreciate type annotations for what they are and yeah I'm happy using what we have in stdlib now and not messing with mypy tyvm. The problem is that history is lost to newcomers who have very different expectations. Modern IDE's mostly solve it though, so for all my Java peeps dipping their toes into the snake waters, listen to your ide permalink fedilink source parent hideshow 3 child comments replies: [–] lime@feddit.nu 1 point 1 year ago (2 children) i mean, i'm all for rejiggering the internals. i've personally written at least two libraries that uses type annotations in reverse to force arguments into the correct type, and i feel like that should probably be a separate mechanism to "just call the annotation" permalink fedilink source parent hideshow 2 child comments replies: [–] _stranger_@lemmy.world 1 point 1 year ago (1 child) dataclasses do this for you at the class level. They enforce type annotations at instantiation. https://docs.python.org/3/library/dataclasses.html permalink fedilink source parent hideshow 1 child comment replies: [–] lime@feddit.nu 1 point 1 year ago* (last edited 1 year ago) i think we're talking about different things. you use enforce to mean "validate", i used it to mean "coerce". one of the cases was a command line argument parser that consisted of a single decorator, so you could write @command def foo(bar: int, baz: float): print(baz * 2 + bar * 3) and call it with $ myfile.py foo --bar 3 --baz 2.2 and it would print 13.4 another was about creating working protocol buffers from an excel sheet, nested types and enums and oneofs and everything. we used it to parameterize tests of our bluetooth protocol. permalink fedilink source parent
[–] lime@feddit.nu 1 point 1 year ago (4 children) the problem is that the language doesn't and can't support one single way to use type annotations without changing fundamental functionality. you can absolutely hook up mypy to your editor for newbies, but once you get on the intermediate level, fighting with mypy takes more code than actually solving the problem. also there was that proposed update to mypy that was put on held when it turned out that the maintainers didn't know how annotations are used in the wild. permalink fedilink source parent hideshow 4 child comments replies: [–] _stranger_@lemmy.world 1 point 1 year ago (3 children) Oh I'm well aware. Took me a solid year to appreciate type annotations for what they are and yeah I'm happy using what we have in stdlib now and not messing with mypy tyvm. The problem is that history is lost to newcomers who have very different expectations. Modern IDE's mostly solve it though, so for all my Java peeps dipping their toes into the snake waters, listen to your ide permalink fedilink source parent hideshow 3 child comments replies: [–] lime@feddit.nu 1 point 1 year ago (2 children) i mean, i'm all for rejiggering the internals. i've personally written at least two libraries that uses type annotations in reverse to force arguments into the correct type, and i feel like that should probably be a separate mechanism to "just call the annotation" permalink fedilink source parent hideshow 2 child comments replies: [–] _stranger_@lemmy.world 1 point 1 year ago (1 child) dataclasses do this for you at the class level. They enforce type annotations at instantiation. https://docs.python.org/3/library/dataclasses.html permalink fedilink source parent hideshow 1 child comment replies: [–] lime@feddit.nu 1 point 1 year ago* (last edited 1 year ago) i think we're talking about different things. you use enforce to mean "validate", i used it to mean "coerce". one of the cases was a command line argument parser that consisted of a single decorator, so you could write @command def foo(bar: int, baz: float): print(baz * 2 + bar * 3) and call it with $ myfile.py foo --bar 3 --baz 2.2 and it would print 13.4 another was about creating working protocol buffers from an excel sheet, nested types and enums and oneofs and everything. we used it to parameterize tests of our bluetooth protocol. permalink fedilink source parent
[–] _stranger_@lemmy.world 1 point 1 year ago (3 children) Oh I'm well aware. Took me a solid year to appreciate type annotations for what they are and yeah I'm happy using what we have in stdlib now and not messing with mypy tyvm. The problem is that history is lost to newcomers who have very different expectations. Modern IDE's mostly solve it though, so for all my Java peeps dipping their toes into the snake waters, listen to your ide permalink fedilink source parent hideshow 3 child comments replies: [–] lime@feddit.nu 1 point 1 year ago (2 children) i mean, i'm all for rejiggering the internals. i've personally written at least two libraries that uses type annotations in reverse to force arguments into the correct type, and i feel like that should probably be a separate mechanism to "just call the annotation" permalink fedilink source parent hideshow 2 child comments replies: [–] _stranger_@lemmy.world 1 point 1 year ago (1 child) dataclasses do this for you at the class level. They enforce type annotations at instantiation. https://docs.python.org/3/library/dataclasses.html permalink fedilink source parent hideshow 1 child comment replies: [–] lime@feddit.nu 1 point 1 year ago* (last edited 1 year ago) i think we're talking about different things. you use enforce to mean "validate", i used it to mean "coerce". one of the cases was a command line argument parser that consisted of a single decorator, so you could write @command def foo(bar: int, baz: float): print(baz * 2 + bar * 3) and call it with $ myfile.py foo --bar 3 --baz 2.2 and it would print 13.4 another was about creating working protocol buffers from an excel sheet, nested types and enums and oneofs and everything. we used it to parameterize tests of our bluetooth protocol. permalink fedilink source parent
[–] lime@feddit.nu 1 point 1 year ago (2 children) i mean, i'm all for rejiggering the internals. i've personally written at least two libraries that uses type annotations in reverse to force arguments into the correct type, and i feel like that should probably be a separate mechanism to "just call the annotation" permalink fedilink source parent hideshow 2 child comments replies: [–] _stranger_@lemmy.world 1 point 1 year ago (1 child) dataclasses do this for you at the class level. They enforce type annotations at instantiation. https://docs.python.org/3/library/dataclasses.html permalink fedilink source parent hideshow 1 child comment replies: [–] lime@feddit.nu 1 point 1 year ago* (last edited 1 year ago) i think we're talking about different things. you use enforce to mean "validate", i used it to mean "coerce". one of the cases was a command line argument parser that consisted of a single decorator, so you could write @command def foo(bar: int, baz: float): print(baz * 2 + bar * 3) and call it with $ myfile.py foo --bar 3 --baz 2.2 and it would print 13.4 another was about creating working protocol buffers from an excel sheet, nested types and enums and oneofs and everything. we used it to parameterize tests of our bluetooth protocol. permalink fedilink source parent
[–] _stranger_@lemmy.world 1 point 1 year ago (1 child) dataclasses do this for you at the class level. They enforce type annotations at instantiation. https://docs.python.org/3/library/dataclasses.html permalink fedilink source parent hideshow 1 child comment replies: [–] lime@feddit.nu 1 point 1 year ago* (last edited 1 year ago) i think we're talking about different things. you use enforce to mean "validate", i used it to mean "coerce". one of the cases was a command line argument parser that consisted of a single decorator, so you could write @command def foo(bar: int, baz: float): print(baz * 2 + bar * 3) and call it with $ myfile.py foo --bar 3 --baz 2.2 and it would print 13.4 another was about creating working protocol buffers from an excel sheet, nested types and enums and oneofs and everything. we used it to parameterize tests of our bluetooth protocol. permalink fedilink source parent
[–] lime@feddit.nu 1 point 1 year ago* (last edited 1 year ago) i think we're talking about different things. you use enforce to mean "validate", i used it to mean "coerce". one of the cases was a command line argument parser that consisted of a single decorator, so you could write @command def foo(bar: int, baz: float): print(baz * 2 + bar * 3) and call it with $ myfile.py foo --bar 3 --baz 2.2 and it would print 13.4 another was about creating working protocol buffers from an excel sheet, nested types and enums and oneofs and everything. we used it to parameterize tests of our bluetooth protocol. permalink fedilink source parent