From cab35e3dfd2fa2d41a045b79e9c247ddcd84cf52 Mon Sep 17 00:00:00 2001 From: Martin Fischer Date: Fri, 25 Feb 2022 08:02:46 +0100 Subject: move control flow puzzles before typing puzzles --- puzzles/20_literal_eval_expr.py | 3 --- puzzles/20_try_except_finally.py | 8 ++++++++ puzzles/21_literal_enum_name.py | 8 -------- puzzles/22_protocol_missing_member.py | 7 ------- puzzles/30_literal_eval_expr.py | 3 +++ puzzles/30_try_except_finally.py | 8 -------- puzzles/31_literal_enum_name.py | 8 ++++++++ puzzles/32_protocol_missing_member.py | 7 +++++++ 8 files changed, 26 insertions(+), 26 deletions(-) delete mode 100644 puzzles/20_literal_eval_expr.py create mode 100644 puzzles/20_try_except_finally.py delete mode 100644 puzzles/21_literal_enum_name.py delete mode 100644 puzzles/22_protocol_missing_member.py create mode 100644 puzzles/30_literal_eval_expr.py delete mode 100644 puzzles/30_try_except_finally.py create mode 100644 puzzles/31_literal_enum_name.py create mode 100644 puzzles/32_protocol_missing_member.py diff --git a/puzzles/20_literal_eval_expr.py b/puzzles/20_literal_eval_expr.py deleted file mode 100644 index dce14aa..0000000 --- a/puzzles/20_literal_eval_expr.py +++ /dev/null @@ -1,3 +0,0 @@ -from typing import Literal - -x: Literal[3] = 1 + 2 diff --git a/puzzles/20_try_except_finally.py b/puzzles/20_try_except_finally.py new file mode 100644 index 0000000..d63ab10 --- /dev/null +++ b/puzzles/20_try_except_finally.py @@ -0,0 +1,8 @@ +def foo() -> None: + file = None + try: + file = open('test.json') + except Exception: + return None + finally: + file.name # error diff --git a/puzzles/21_literal_enum_name.py b/puzzles/21_literal_enum_name.py deleted file mode 100644 index a743168..0000000 --- a/puzzles/21_literal_enum_name.py +++ /dev/null @@ -1,8 +0,0 @@ -import enum -from typing import Literal - -class Color(enum.Enum): - Red = enum.auto() - Blue = enum.auto() - -c: Literal[Color.Red] = Color.Blue # error diff --git a/puzzles/22_protocol_missing_member.py b/puzzles/22_protocol_missing_member.py deleted file mode 100644 index 79bd70e..0000000 --- a/puzzles/22_protocol_missing_member.py +++ /dev/null @@ -1,7 +0,0 @@ -from typing import Protocol - -class P(Protocol): - x: int - -class B(P): # error - pass diff --git a/puzzles/30_literal_eval_expr.py b/puzzles/30_literal_eval_expr.py new file mode 100644 index 0000000..dce14aa --- /dev/null +++ b/puzzles/30_literal_eval_expr.py @@ -0,0 +1,3 @@ +from typing import Literal + +x: Literal[3] = 1 + 2 diff --git a/puzzles/30_try_except_finally.py b/puzzles/30_try_except_finally.py deleted file mode 100644 index d63ab10..0000000 --- a/puzzles/30_try_except_finally.py +++ /dev/null @@ -1,8 +0,0 @@ -def foo() -> None: - file = None - try: - file = open('test.json') - except Exception: - return None - finally: - file.name # error diff --git a/puzzles/31_literal_enum_name.py b/puzzles/31_literal_enum_name.py new file mode 100644 index 0000000..a743168 --- /dev/null +++ b/puzzles/31_literal_enum_name.py @@ -0,0 +1,8 @@ +import enum +from typing import Literal + +class Color(enum.Enum): + Red = enum.auto() + Blue = enum.auto() + +c: Literal[Color.Red] = Color.Blue # error diff --git a/puzzles/32_protocol_missing_member.py b/puzzles/32_protocol_missing_member.py new file mode 100644 index 0000000..79bd70e --- /dev/null +++ b/puzzles/32_protocol_missing_member.py @@ -0,0 +1,7 @@ +from typing import Protocol + +class P(Protocol): + x: int + +class B(P): # error + pass -- cgit v1.2.3