[{"data":1,"prerenderedAt":156},["ShallowReactive",2],{"project-30471395":3},{"id":4,"name":5,"line":6,"line_source":7,"title":8,"url":9,"domain":10,"maker":11,"posted_at":12,"year":13,"points":14,"comments":15,"rank_in_year":16,"shown_in_year":17,"top":18,"tier":19,"category":20,"subcategory":21,"format":22,"keywords":23,"reception":28,"sentiment":29,"stance_mix":30,"scored_comments":33,"aspects":34,"strip":37,"post_text":29,"what":39,"said":62,"maker_in_thread":95,"shape":101,"grid":105,"attempts":117,"same_week":118,"maker_shows":148,"maker_hidden":149,"reader_version":150,"card":151},"30471395","Dirty-equals","Doing dirty (but useful) things with equals","title","Show HN: Dirty-equals – Doing dirty (but useful) things with equals","https:\u002F\u002Fgithub.com\u002Fsamuelcolvin\u002Fdirty-equals","github.com","scolvin",1645818136,2022,25,6,1352,2570,53,"shown","languages","testing library","library",[24,25,26,27],"python","equality","pytest","assertions","quiet",null,{"positive":31,"neutral":32,"mixed":32,"critical":31},1,0,2,{"design":35,"idea":36},{"positive":32,"critical":31},{"positive":31,"critical":32},[32,32,31,32,32,38],5,{"problem":40,"audience":29,"pricing":29,"motivation":29,"time_to_build":29,"stack":51,"openness":61,"stage":61,"team_size":61},{"value":41,"source":42,"evidence":43},"Comparing structures with fuzzy or partial matches, such as types and regex, in assertions","inferred",[44,48],{"id":45,"by":46,"text":47},"30473331","quietbritishjim","``` assert user_data == { 'id': IsPositiveInt, 'avatar_file': IsStr(regex=r'\u002F[a-z0-9\\-] {10}\u002Fexample\\.png'), ``` > Without dirty-equals, you'd have to compare individual fields…",{"id":49,"by":11,"text":50},"30473513","I disagree, this is much less clear. It also don't work well with pytest's error output.",[52,57],{"value":53,"source":42,"evidence":54},"Python",[55,56],{"id":45,"by":46,"text":47},{"id":49,"by":11,"text":50},{"value":26,"source":58,"evidence":59},"commenter",[60],{"id":49,"by":11,"text":50},"unknown",{"praise":63,"objections":72,"requests":77,"questions":78,"alternatives":83},[64],{"value":65,"source":58,"evidence":66},"Useful functionality for flexible comparisons",[67,68],{"id":45,"by":46,"text":47},{"id":69,"by":70,"text":71},"30499862","high_byte","this is pretty neat!",[73],{"value":74,"source":58,"evidence":75},"Overloading the equals operator is a gimmick and less clear",[76],{"id":45,"by":46,"text":47},[],[79],{"value":80,"source":58,"evidence":81},"Why not use a separate dirty_check function instead of ==",[82],{"id":45,"by":46,"text":47},[84],{"value":85,"source":58,"evidence":86},"Raku smart-match operator",[87,91],{"id":88,"by":89,"text":90},"30473037","pie_flavor","Raku has this feature by design. While there technically is a general equality operator `eqv`, you rarely see it used. Instead, you use the matching operator, `~~`, which can…",{"id":92,"by":93,"text":94},"30476641","lizmat","The operator is called \"smart-match\". When you do: ``` $a ~~ $b ``` You are in fact doing: ``` $b.ACCEPTS($a) ``` So any object can determine how it will interpret any other…",{"comments":33,"answered":32,"key":96},[97,98],{"id":49,"text":50},{"id":99,"text":100},"30473522","And it would be much more complex to implement, particularly with recursively nested types.",{"commenters":38,"max_depth":102,"maker_replies":33,"first_comment_mins":103,"lifespan_hours":104},3,156,66,[106,108,109,111,113,115],[88,32,32,107,89,32],"other\u002Fneutral\u002Fnone",[92,32,32,107,93,32],[45,31,31,110,46,32],"project\u002Fcritical\u002Fdesign",[49,31,32,112,11,31],"maker\u002Fpositive\u002Fdesign",[99,31,32,114,11,31],"maker\u002Fpositive\u002Fexecution",[69,33,38,116,70,32],"project\u002Fpositive\u002Fidea",[],[119,124,129,134,138,143],{"id":120,"name":121,"points":122,"category":123},"30517626","Almost Pong",1135,"games",{"id":125,"name":126,"points":127,"category":128},"30503197","booqsi.com",478,"consumer_social",{"id":130,"name":131,"points":132,"category":133},"30529262","Huemint",335,"creative",{"id":135,"name":136,"points":137,"category":128},"30489003","Messages for Macintosh",211,{"id":139,"name":140,"points":141,"category":142},"30457900","Programming Time",203,"learning_science",{"id":144,"name":145,"points":146,"category":147},"30531621","WAPM",186,"dev_tools",4,false,"v2",{"id":152,"name":5,"line":6,"ai":149,"cat":20,"year":13,"points":14,"comments":15,"rec":28,"s":29,"top":18,"kw":153,"maker":11,"domain":10,"tier":19,"attempts":32,"strip":154,"url":9,"mix":155,"praise":65,"objection":74,"sub":21},30471395,[24,25,26,27],"001005",[31,32,32,31],1793991041790]