« first day (4949 days earlier)   

6:07 PM
Is there somewhere decent to direct youngsters to get the help the help-desk kind of feedback they think SO is for? I just came across another question where they said they were a GCSE student, which would put them ~15/16 years old. That info got edited out (which it should be) but it then pulls at my cold, dead heartstrings a bit when it then goes through the usual SO treatment
I don't know how to delineate the treatment properly. I don't think it's reasonable to expect someone at that age to necessarily understand the systems; all it does it discourage them from programming. Obviously the system could be gamed but I really don't like the idea of a kid getting shut down
"the help the help-desk" err, just "the help-desk". Too late to edit now
 
I guess the r/learnpython subreddit fits that description well enough
 
 
3 hours later…
9:02 PM
Pyright oddity of the day:
def needs_a_type(t: type): ...

type AnAliasForUnion[A, B] = A | B

needs_a_type(int | str)  # error
needs_a_type(AnAliasForUnion[int, str])  # ok
 
 
1 hour later…
10:30 PM
@Aran-Fey Callable and Protocol have interesting differences in Pyright too. (You can infer typevars with Callable but not Protocol)
Kinda wish the typing system had a few basic core types which are built on top of, rather than jank everywhere
 
11:00 PM
Is it possible to define a generic type that accepts varargs and is semantically equivalent to a Union but is also treated as a class? I need it to be usable as a type annotation, but I also want to pass it as an argument to a parse function
I can't get it to work even with the aliasing trick because
# Error: Union cannot include an unpacked TypeVarTuple
type AnAliasForUnion[*Ts] = Union[*Ts]
 
@Aran-Fey I don't think you can. (I've not read and abused all the latest types, but nothing springs to mind which could be abusable)
Something I did to bypass the Callable <-> Protocol difference is add a property _ which has an abusable type. I'm not a fan of ._ being littered all over my code, but could such an approach work for you?
 
11:16 PM
Not sure what you mean, can you explain in more detail?
 
11:33 PM
Basically I had a bunch of classes which act like functions. However the type system doesn't infer types properly with Generic/Protocols. If you chain classes like callables the typevars aren't inferred. So I added a property _ which converts the type to a Callable which correctly gets inferred by the type system. (Albeit I lose the class typing information) In other words, adding a property to the class to return a type which works correctly with the type system.
 
I still don't get it, but it's late and I'm tired. I'll try to make sense of it again tomorrow
 
Good idea, I'll see if I can create a MVCE to explain tomorrow. I'm reluctant to as last time making one took a couple hours. And I've forgot everything now.
 

« first day (4949 days earlier)