From 4405e13488c130c842db9006261e71cf2f578c8a Mon Sep 17 00:00:00 2001 From: Mark Byrne <31762852+mbyrnepr2@users.noreply.github.com> Date: Tue, 17 May 2022 11:08:00 +0200 Subject: Add documentation examples for `consider-using-get`. (#6630) Co-authored-by: Pierre Sassoulas Co-authored-by: Matus Valo --- doc/data/messages/c/consider-using-get/bad.py | 6 ++++++ doc/data/messages/c/consider-using-get/good.py | 3 +++ 2 files changed, 9 insertions(+) create mode 100644 doc/data/messages/c/consider-using-get/bad.py create mode 100644 doc/data/messages/c/consider-using-get/good.py diff --git a/doc/data/messages/c/consider-using-get/bad.py b/doc/data/messages/c/consider-using-get/bad.py new file mode 100644 index 000000000..b820c5698 --- /dev/null +++ b/doc/data/messages/c/consider-using-get/bad.py @@ -0,0 +1,6 @@ +knights = {"Gallahad": "the pure", "Robin": "the brave"} + +if "Gallahad" in knights: # [consider-using-get] + DESCRIPTION = knights["Gallahad"] +else: + DESCRIPTION = "" diff --git a/doc/data/messages/c/consider-using-get/good.py b/doc/data/messages/c/consider-using-get/good.py new file mode 100644 index 000000000..eba9976af --- /dev/null +++ b/doc/data/messages/c/consider-using-get/good.py @@ -0,0 +1,3 @@ +knights = {"Gallahad": "the pure", "Robin": "the brave"} + +description = knights.get("Gallahad", "") -- cgit v1.2.1