summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
Diffstat (limited to 'doc')
-rw-r--r--doc/data/messages/p/prefer-typing-namedtuple/bad.py5
-rw-r--r--doc/data/messages/p/prefer-typing-namedtuple/good.py7
-rw-r--r--doc/data/messages/p/prefer-typing-namedtuple/pylintrc2
-rw-r--r--doc/data/messages/p/prefer-typing-namedtuple/related.rst1
-rw-r--r--doc/whatsnew/fragments/8660.extension7
5 files changed, 22 insertions, 0 deletions
diff --git a/doc/data/messages/p/prefer-typing-namedtuple/bad.py b/doc/data/messages/p/prefer-typing-namedtuple/bad.py
new file mode 100644
index 000000000..d555b0f26
--- /dev/null
+++ b/doc/data/messages/p/prefer-typing-namedtuple/bad.py
@@ -0,0 +1,5 @@
+from collections import namedtuple
+
+Philosophy = namedtuple( # [prefer-typing-namedtuple]
+ "Philosophy", ("goodness", "truth", "beauty")
+)
diff --git a/doc/data/messages/p/prefer-typing-namedtuple/good.py b/doc/data/messages/p/prefer-typing-namedtuple/good.py
new file mode 100644
index 000000000..ef094aacd
--- /dev/null
+++ b/doc/data/messages/p/prefer-typing-namedtuple/good.py
@@ -0,0 +1,7 @@
+from typing import NamedTuple
+
+
+class Philosophy(NamedTuple):
+ goodness: str
+ truth: bool
+ beauty: float
diff --git a/doc/data/messages/p/prefer-typing-namedtuple/pylintrc b/doc/data/messages/p/prefer-typing-namedtuple/pylintrc
new file mode 100644
index 000000000..b001506b6
--- /dev/null
+++ b/doc/data/messages/p/prefer-typing-namedtuple/pylintrc
@@ -0,0 +1,2 @@
+[MAIN]
+load-plugins = pylint.extensions.code_style
diff --git a/doc/data/messages/p/prefer-typing-namedtuple/related.rst b/doc/data/messages/p/prefer-typing-namedtuple/related.rst
new file mode 100644
index 000000000..a8d3da44c
--- /dev/null
+++ b/doc/data/messages/p/prefer-typing-namedtuple/related.rst
@@ -0,0 +1 @@
+- `typing.NamedTuple <https://docs.python.org/3/library/typing.html#typing.NamedTuple>`_
diff --git a/doc/whatsnew/fragments/8660.extension b/doc/whatsnew/fragments/8660.extension
new file mode 100644
index 000000000..2090d03ac
--- /dev/null
+++ b/doc/whatsnew/fragments/8660.extension
@@ -0,0 +1,7 @@
+Add new ``prefer-typing-namedtuple`` message to the ``CodeStyleChecker`` to suggest
+rewriting calls to ``collections.namedtuple`` as classes inheriting from ``typing.NamedTuple``
+on Python 3.6+.
+
+Requires ``load-plugins=pylint.extensions.code_style`` and ``enable=prefer-typing-namedtuple`` to be raised.
+
+Closes #8660