summaryrefslogtreecommitdiff
path: root/pylint/extensions/_check_docs_utils.py
diff options
context:
space:
mode:
authorDaniƫl van Noord <13665637+DanielNoord@users.noreply.github.com>2022-04-14 11:07:21 +0200
committerGitHub <noreply@github.com>2022-04-14 11:07:21 +0200
commit47e168cf607e2069b103fc466edfe1c6522e2fb2 (patch)
tree97d7b67b673d1147f4b8c9321b6247c117195060 /pylint/extensions/_check_docs_utils.py
parent99ef057978e2ddd332bdd436fd5fd884deebdc53 (diff)
downloadpylint-git-47e168cf607e2069b103fc466edfe1c6522e2fb2.tar.gz
Use ``python-typing-update`` on ``pylint/extensions`` directory (#6308)
Diffstat (limited to 'pylint/extensions/_check_docs_utils.py')
-rw-r--r--pylint/extensions/_check_docs_utils.py15
1 files changed, 8 insertions, 7 deletions
diff --git a/pylint/extensions/_check_docs_utils.py b/pylint/extensions/_check_docs_utils.py
index 0e2774bda..3c44df130 100644
--- a/pylint/extensions/_check_docs_utils.py
+++ b/pylint/extensions/_check_docs_utils.py
@@ -4,8 +4,9 @@
"""Utility methods for docstring checking."""
+from __future__ import annotations
+
import re
-from typing import List, Optional, Set, Tuple
import astroid
from astroid import nodes
@@ -95,12 +96,12 @@ def _get_raise_target(node):
return None
-def _split_multiple_exc_types(target: str) -> List[str]:
+def _split_multiple_exc_types(target: str) -> list[str]:
delimiters = r"(\s*,(?:\s*or\s)?\s*|\s+or\s+)"
return re.split(delimiters, target)
-def possible_exc_types(node: nodes.NodeNG) -> Set[nodes.ClassDef]:
+def possible_exc_types(node: nodes.NodeNG) -> set[nodes.ClassDef]:
"""Gets all the possible raised exception types for the given raise node.
.. note::
@@ -157,8 +158,8 @@ def possible_exc_types(node: nodes.NodeNG) -> Set[nodes.ClassDef]:
def docstringify(
- docstring: Optional[nodes.Const], default_type: str = "default"
-) -> "Docstring":
+ docstring: nodes.Const | None, default_type: str = "default"
+) -> Docstring:
best_match = (0, DOCSTRING_TYPES.get(default_type, Docstring)(docstring))
for docstring_type in (
SphinxDocstring,
@@ -190,7 +191,7 @@ class Docstring:
# These methods are designed to be overridden
# pylint: disable=no-self-use
- def __init__(self, doc: Optional[nodes.Const]) -> None:
+ def __init__(self, doc: nodes.Const | None) -> None:
docstring = doc.value if doc else ""
self.doc = docstring.expandtabs()
@@ -768,7 +769,7 @@ class NumpyDocstring(GoogleDocstring):
supports_yields = True
- def match_param_docs(self) -> Tuple[Set[str], Set[str]]:
+ def match_param_docs(self) -> tuple[set[str], set[str]]:
"""Matches parameter documentation section to parameter documentation rules."""
params_with_doc = set()
params_with_type = set()