summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatus Valo <matusvalo@users.noreply.github.com>2022-05-15 23:39:48 +0200
committerGitHub <noreply@github.com>2022-05-15 23:39:48 +0200
commit3f707821eccb2e8fda1b6cccab9de32e1f822eed (patch)
tree4487d6c07d459c39d2ea678bd97f45269e42196f
parent0007c3247e8a71d71f94f3332d7eb45360e445ee (diff)
downloadpylint-git-3f707821eccb2e8fda1b6cccab9de32e1f822eed.tar.gz
Added logging-not-lazy message example (#6619)
Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com> Co-authored-by: Daniƫl van Noord <13665637+DanielNoord@users.noreply.github.com>
-rw-r--r--doc/data/messages/l/logging-not-lazy/bad.py7
-rw-r--r--doc/data/messages/l/logging-not-lazy/details.rst2
-rw-r--r--doc/data/messages/l/logging-not-lazy/good.py7
-rw-r--r--doc/data/messages/l/logging-not-lazy/related.rst2
4 files changed, 18 insertions, 0 deletions
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 <https://docs.python.org/3/howto/logging.html#logging-variable-data>`_
+- `Rationale <https://stackoverflow.com/questions/34619790>`_