{"payload":{"feedbackUrl":"https://github.com/orgs/community/discussions/53140","repo":{"id":717562845,"defaultBranch":"master","name":"mypy","ownerLogin":"edpaget","currentUserCanPush":false,"isFork":true,"isEmpty":false,"createdAt":"2023-11-11T21:05:15.000Z","ownerAvatar":"https://avatars.githubusercontent.com/u/108177?v=4","public":true,"private":false,"isOrgOwned":false},"refInfo":{"name":"","listCacheKey":"v0:1712361015.0","currentOid":""},"activityList":{"items":[{"before":"7a25c34bd16f2731335514eed6be7efc1d803848","after":"8454267e1f84be3e3b2a9c95cf9c6dd810769b93","ref":"refs/heads/edpaget/fix-narrowing-on-tuple-patterns","pushedAt":"2024-04-09T16:13:40.000Z","pushType":"force_push","commitsCount":0,"pusher":{"login":"edpaget","name":"Edward Paget","path":"/edpaget","primaryAvatarUrl":"https://avatars.githubusercontent.com/u/108177?s=80&v=4"},"commit":{"message":"Fix narrowing unions in tuple pattern matches\n\nAllows sequence pattern matching of tuple types with union members to\nuse an unmatched pattern to narrow the possible type of union member to\nthe type that was not matched in the sequence pattern.\n\nFor example given a type of `tuple[int, int | None]` a pattern match\nlike:\n\n```\nmatch tuple_type:\n case a, None:\n return\n case t:\n reveal_type(t) # narrows tuple type to tuple[int, int]\n return\n```\n\nThe case ..., None sequence pattern match can now narrow the type in\nfurther match statements to rule out the None side of the union.\n\nThis is implemented by moving the original implementation of tuple\nnarrowing in sequence pattern matching since its functionality should be\nto the special case where a tuple only has length of one. This\nimplementation does not hold for tuples of length greater than one since\nit does not account all combinations of alternative types.\n\nThis replace that implementation with a new one that builds the rest\ntype by iterating over the potential rest type members preserving\nnarrowed types if they are available and replacing any uninhabited types\nwith the original type of tuple member since these matches are only\nexhaustive if all members of the tuple are matched.\n\nFixes #14731","shortMessageHtmlLink":"Fix narrowing unions in tuple pattern matches"}},{"before":"83542e52bf3409e532b916d7b60530aefed40176","after":"7a25c34bd16f2731335514eed6be7efc1d803848","ref":"refs/heads/edpaget/fix-narrowing-on-tuple-patterns","pushedAt":"2024-04-06T00:30:56.000Z","pushType":"force_push","commitsCount":0,"pusher":{"login":"edpaget","name":"Edward Paget","path":"/edpaget","primaryAvatarUrl":"https://avatars.githubusercontent.com/u/108177?s=80&v=4"},"commit":{"message":"Fix narrowing unions in tuple pattern matches\n\nAllows sequence pattern matching of tuple types with union members to\nuse an unmatched pattern to narrow the possible type of union member to\nthe type that was not matched in the sequence pattern.\n\nFor example given a type of `tuple[int, int | None]` a pattern match\nlike:\n\n```\nmatch tuple_type:\n case a, None:\n return\n case t:\n reveal_type(t) # narrows tuple type to tuple[int, int]\n return\n```\n\nThe case ..., None sequence pattern match can now narrow the type in\nfurther match statements to rule out the None side of the union.\n\nThis is implemented by removing the original implementation of tuple\nnarrowing in sequence pattern matching since its functionality should be\nidentical to the matched_type/rest_type built by visiting the individual\npatterns within the sequence pattern. Then this builds the rest type by\niterating over the potential rest type members preserving narrowed types\nif they are available and replacing any uninhabited types with the\noriginal type of tuple member since these matches are only exhaustive if\nall members of the tuple are matched.","shortMessageHtmlLink":"Fix narrowing unions in tuple pattern matches"}},{"before":"0ec500e85a69ec804c66e38bdcfb6805c12856b8","after":"83542e52bf3409e532b916d7b60530aefed40176","ref":"refs/heads/edpaget/fix-narrowing-on-tuple-patterns","pushedAt":"2024-04-06T00:27:52.000Z","pushType":"force_push","commitsCount":0,"pusher":{"login":"edpaget","name":"Edward Paget","path":"/edpaget","primaryAvatarUrl":"https://avatars.githubusercontent.com/u/108177?s=80&v=4"},"commit":{"message":"Fix narrowing unions in tuple pattern matches\n\nAllows sequence pattern matching of tuple types with union members to\nuse an unmatched pattern to narrow the possible type of union member to\nthe type that was not matched in the sequence pattern.\n\nFor example given a type of `tuple[int, int | None]` a pattern match\nlike:\n\n```\nmatch tuple_type:\n case a, None:\n return\n case t:\n reveal_type(t) # narrows tuple type to tuple[int, int]\n return\n```\n\nThe case ..., None sequence pattern match can now narrow the type in\nfurther match statements to rule out the None side of the union.\n\nThis is implemented by removing the original implementation of tuple\nnarrowing in sequence pattern matching since its functionality should be\nidentical to the matched_type/rest_type built by visiting the individual\npatterns within the sequence pattern. Then this builds the rest type by\niterating over the potential rest type members preserving narrowed types\nif they are available and replacing any uninhabited types with the\noriginal type of tuple member since these matches are only exhaustive if\nall members of the tuple are matched.","shortMessageHtmlLink":"Fix narrowing unions in tuple pattern matches"}},{"before":"f1f515f33ad6b369b04ef8a0beb0de338f927c7a","after":"0ec500e85a69ec804c66e38bdcfb6805c12856b8","ref":"refs/heads/edpaget/fix-narrowing-on-tuple-patterns","pushedAt":"2024-04-06T00:23:26.000Z","pushType":"force_push","commitsCount":0,"pusher":{"login":"edpaget","name":"Edward Paget","path":"/edpaget","primaryAvatarUrl":"https://avatars.githubusercontent.com/u/108177?s=80&v=4"},"commit":{"message":"Fix narrowing unions in tuple pattern matches\n\nAllows sequence pattern matching of tuple types with union members to\nuse an unmatched pattern to narrow the possible type of union member to\nthe type that was not matched in the sequence pattern.\n\nFor example given a type of `tuple[int, int | None]` a pattern match\nlike:\n\n```\nmatch tuple_type:\n case a, None:\n return\n case t:\n reveal_type(t) # narrows tuple type to tuple[int, int]\n return\n```\n\nThe case ..., None sequence pattern match can now narrow the type in\nfurther match statements to rule out the None side of the union.\n\nThis is implemented by removing the original implementation of tuple\nnarrowing in sequence pattern matching since its functionality should be\nidentical to the matched_type/rest_type built by visiting the individual\npatterns within the sequence pattern. Then this builds the rest type by\niterating over the potential rest type members preserving narrowed types\nif they are available and replacing any uninhabited types with the\noriginal type of tuple member since these matches are only exhaustive if\nall members of the tuple are matched.","shortMessageHtmlLink":"Fix narrowing unions in tuple pattern matches"}},{"before":null,"after":"f1f515f33ad6b369b04ef8a0beb0de338f927c7a","ref":"refs/heads/edpaget/fix-narrowing-on-tuple-patterns","pushedAt":"2024-04-05T23:50:15.000Z","pushType":"branch_creation","commitsCount":0,"pusher":{"login":"edpaget","name":"Edward Paget","path":"/edpaget","primaryAvatarUrl":"https://avatars.githubusercontent.com/u/108177?s=80&v=4"},"commit":{"message":"Fix narrowing unions in tuple pattern matches","shortMessageHtmlLink":"Fix narrowing unions in tuple pattern matches"}},{"before":"e4c43cb68b742f0f51759565d1d3c4a722d16f55","after":"80190101f68b52e960c22572ed6cc814de078b9c","ref":"refs/heads/master","pushedAt":"2024-04-05T18:56:18.000Z","pushType":"push","commitsCount":168,"pusher":{"login":"edpaget","name":"Edward Paget","path":"/edpaget","primaryAvatarUrl":"https://avatars.githubusercontent.com/u/108177?s=80&v=4"},"commit":{"message":"Narrow individual items when matching a tuple to a sequence pattern (#16905)\n\nFixes #12364\r\n\r\nWhen matching a tuple to a sequence pattern, this change narrows the\r\ntype of tuple items inside the matched case:\r\n\r\n```py\r\ndef test(a: bool, b: bool) -> None:\r\n match a, b:\r\n case True, True:\r\n reveal_type(a) # before: \"builtins.bool\", after: \"Literal[True]\"\r\n```\r\n\r\nThis also works with nested tuples, recursively:\r\n\r\n```py\r\ndef test(a: bool, b: bool, c: bool) -> None:\r\n match a, (b, c):\r\n case _, [True, False]:\r\n reveal_type(c) # before: \"builtins.bool\", after: \"Literal[False]\"\r\n```\r\n\r\nThis only partially fixes issue #12364; see [my comment\r\nthere](https://github.com/python/mypy/issues/12364#issuecomment-1937375271)\r\nfor more context.\r\n\r\n---\r\n\r\nThis is my first contribution to mypy, so I may miss some context or\r\nconventions; I'm eager for any feedback!\r\n\r\n---------\r\n\r\nCo-authored-by: Loïc Simon ","shortMessageHtmlLink":"Narrow individual items when matching a tuple to a sequence pattern (p…"}},{"before":"b44c9aa910f3410c219202a2cc18a66bd02b0cd6","after":null,"ref":"refs/heads/edpaget/fix-match-type-narrowing","pushedAt":"2024-02-18T22:18:08.000Z","pushType":"branch_deletion","commitsCount":0,"pusher":{"login":"edpaget","name":"Edward Paget","path":"/edpaget","primaryAvatarUrl":"https://avatars.githubusercontent.com/u/108177?s=80&v=4"}},{"before":"e392514d01846b53685e37aab476cde9bd8cdfcf","after":"b44c9aa910f3410c219202a2cc18a66bd02b0cd6","ref":"refs/heads/edpaget/fix-match-type-narrowing","pushedAt":"2024-02-11T10:18:42.000Z","pushType":"push","commitsCount":1,"pusher":{"login":"hauntsaninja","name":"Shantanu","path":"/hauntsaninja","primaryAvatarUrl":"https://avatars.githubusercontent.com/u/12621235?s=80&v=4"},"commit":{"message":".","shortMessageHtmlLink":"."}},{"before":"1081f316103bb50e0d63aa05eb21cd29056f9121","after":"e392514d01846b53685e37aab476cde9bd8cdfcf","ref":"refs/heads/edpaget/fix-match-type-narrowing","pushedAt":"2024-02-11T10:14:17.000Z","pushType":"push","commitsCount":1,"pusher":{"login":"hauntsaninja","name":"Shantanu","path":"/hauntsaninja","primaryAvatarUrl":"https://avatars.githubusercontent.com/u/12621235?s=80&v=4"},"commit":{"message":".","shortMessageHtmlLink":"."}},{"before":"5c659a0a48194a2a870ea53b6b34b43ce7c2331b","after":"1081f316103bb50e0d63aa05eb21cd29056f9121","ref":"refs/heads/edpaget/fix-match-type-narrowing","pushedAt":"2024-02-11T10:13:33.000Z","pushType":"push","commitsCount":1,"pusher":{"login":"hauntsaninja","name":"Shantanu","path":"/hauntsaninja","primaryAvatarUrl":"https://avatars.githubusercontent.com/u/12621235?s=80&v=4"},"commit":{"message":"set a node to prevent incorrect narrowing, add test","shortMessageHtmlLink":"set a node to prevent incorrect narrowing, add test"}},{"before":"5806bc77a5711e25bfbcac9673ca31064fec01ad","after":"5c659a0a48194a2a870ea53b6b34b43ce7c2331b","ref":"refs/heads/edpaget/fix-match-type-narrowing","pushedAt":"2023-12-25T07:44:33.000Z","pushType":"push","commitsCount":1,"pusher":{"login":"hauntsaninja","name":"Shantanu","path":"/hauntsaninja","primaryAvatarUrl":"https://avatars.githubusercontent.com/u/12621235?s=80&v=4"},"commit":{"message":".","shortMessageHtmlLink":"."}},{"before":"2d04f054c0d7f9a6b8d7dc6c3a8a9b9a082cd3fa","after":"5806bc77a5711e25bfbcac9673ca31064fec01ad","ref":"refs/heads/edpaget/fix-match-type-narrowing","pushedAt":"2023-11-16T00:29:44.000Z","pushType":"force_push","commitsCount":0,"pusher":{"login":"edpaget","name":"Edward Paget","path":"/edpaget","primaryAvatarUrl":"https://avatars.githubusercontent.com/u/108177?s=80&v=4"},"commit":{"message":"Fix narrowing on match with function subject\n\nFixes #12998\n\nmypy can't narrow match statements with functions subjects because the\ncallexpr node is not a literal node. This adds a 'dummy' literal node\nthat the match statement visitor can use to do the type narrowing.\n\nThe python grammar describes the the match subject as a named expression\nso this uses that nameexpr node as it's literal.","shortMessageHtmlLink":"Fix narrowing on match with function subject"}},{"before":"e333ec2999a0d91371515e69e60553b40b28ce18","after":"2d04f054c0d7f9a6b8d7dc6c3a8a9b9a082cd3fa","ref":"refs/heads/edpaget/fix-match-type-narrowing","pushedAt":"2023-11-16T00:06:18.000Z","pushType":"force_push","commitsCount":0,"pusher":{"login":"edpaget","name":"Edward Paget","path":"/edpaget","primaryAvatarUrl":"https://avatars.githubusercontent.com/u/108177?s=80&v=4"},"commit":{"message":"Fix narrowing on match with function subject\n\nFixes #12998\n\nmypy can't narrow match statements with functions subjects because the\ncallexpr node is not a literal node. This adds a 'dummy' literal node\nthat the match statement visitor can use to do the type narrowing.\n\nThe python grammar describes the the match subject as a named expression\nso this uses that nameexpr node as it's literal.","shortMessageHtmlLink":"Fix narrowing on match with function subject"}},{"before":null,"after":"e333ec2999a0d91371515e69e60553b40b28ce18","ref":"refs/heads/edpaget/fix-match-type-narrowing","pushedAt":"2023-11-14T22:16:03.000Z","pushType":"branch_creation","commitsCount":0,"pusher":{"login":"edpaget","name":"Edward Paget","path":"/edpaget","primaryAvatarUrl":"https://avatars.githubusercontent.com/u/108177?s=80&v=4"},"commit":{"message":"wip","shortMessageHtmlLink":"wip"}}],"hasNextPage":false,"hasPreviousPage":false,"activityType":"all","actor":null,"timePeriod":"all","sort":"DESC","perPage":30,"cursor":"djE6ks8AAAAELDLcFwA","startCursor":null,"endCursor":null}},"title":"Activity · edpaget/mypy"}