From 3f707821eccb2e8fda1b6cccab9de32e1f822eed Mon Sep 17 00:00:00 2001 From: Matus Valo Date: Sun, 15 May 2022 23:39:48 +0200 Subject: Added logging-not-lazy message example (#6619) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Pierre Sassoulas Co-authored-by: Daniƫl van Noord <13665637+DanielNoord@users.noreply.github.com> --- doc/data/messages/l/logging-not-lazy/bad.py | 7 +++++++ doc/data/messages/l/logging-not-lazy/details.rst | 2 ++ doc/data/messages/l/logging-not-lazy/good.py | 7 +++++++ doc/data/messages/l/logging-not-lazy/related.rst | 2 ++ 4 files changed, 18 insertions(+) create mode 100644 doc/data/messages/l/logging-not-lazy/bad.py create mode 100644 doc/data/messages/l/logging-not-lazy/details.rst create mode 100644 doc/data/messages/l/logging-not-lazy/good.py create mode 100644 doc/data/messages/l/logging-not-lazy/related.rst diff --git a/doc/data/messages/l/logging-not-lazy/bad.py b/doc/data/messages/l/logging-not-lazy/bad.py new file mode 100644 index 000000000..be6b98cb6 --- /dev/null +++ b/doc/data/messages/l/logging-not-lazy/bad.py @@ -0,0 +1,7 @@ +import logging + +try: + function() +except Exception as e: + logging.error('Error occured: %s' % e) # [logging-not-lazy] + raise diff --git a/doc/data/messages/l/logging-not-lazy/details.rst b/doc/data/messages/l/logging-not-lazy/details.rst new file mode 100644 index 000000000..138c423c8 --- /dev/null +++ b/doc/data/messages/l/logging-not-lazy/details.rst @@ -0,0 +1,2 @@ +Another reasonable option is to use f-strings. If you want to do that, you need to enable +``logging-not-lazy`` and disable ``logging-fstring-interpolation``. diff --git a/doc/data/messages/l/logging-not-lazy/good.py b/doc/data/messages/l/logging-not-lazy/good.py new file mode 100644 index 000000000..ac8503ec9 --- /dev/null +++ b/doc/data/messages/l/logging-not-lazy/good.py @@ -0,0 +1,7 @@ +import logging + +try: + function() +except Exception as e: + logging.error('Error occured: %s', e) + raise diff --git a/doc/data/messages/l/logging-not-lazy/related.rst b/doc/data/messages/l/logging-not-lazy/related.rst new file mode 100644 index 000000000..e6faa3870 --- /dev/null +++ b/doc/data/messages/l/logging-not-lazy/related.rst @@ -0,0 +1,2 @@ +- `Logging variable data `_ +- `Rationale `_ -- cgit v1.2.1