summaryrefslogtreecommitdiff
path: root/sphinx/ext/graphviz.py
diff options
context:
space:
mode:
authorAdam Turner <9087854+aa-turner@users.noreply.github.com>2023-01-01 20:43:59 +0000
committerAdam Turner <9087854+aa-turner@users.noreply.github.com>2023-01-01 20:48:39 +0000
commit14a9289d780240bbce78ad3640e8e1b1b12df43f (patch)
treefd753f5b0f8c7053923b78c8fef2b90b60f9c7fa /sphinx/ext/graphviz.py
parent26f79b0d2dd88b353ac65623897bdfbe8bc07cab (diff)
downloadsphinx-git-14a9289d780240bbce78ad3640e8e1b1b12df43f.tar.gz
Use PEP 604 types
Diffstat (limited to 'sphinx/ext/graphviz.py')
-rw-r--r--sphinx/ext/graphviz.py14
1 files changed, 7 insertions, 7 deletions
diff --git a/sphinx/ext/graphviz.py b/sphinx/ext/graphviz.py
index 8e7e5828c..b9b2c1558 100644
--- a/sphinx/ext/graphviz.py
+++ b/sphinx/ext/graphviz.py
@@ -8,7 +8,7 @@ import re
import subprocess
from os import path
from subprocess import CalledProcessError
-from typing import Any, Optional
+from typing import Any
from docutils import nodes
from docutils.nodes import Node
@@ -44,7 +44,7 @@ class ClickableMapDefinition:
href_re = re.compile('href=".*?"')
def __init__(self, filename: str, content: str, dot: str = '') -> None:
- self.id: Optional[str] = None
+ self.id: str | None = None
self.filename = filename
self.content = content.splitlines()
self.clickable: list[str] = []
@@ -212,8 +212,8 @@ class GraphvizSimple(SphinxDirective):
def render_dot(self: SphinxTranslator, code: str, options: dict, format: str,
- prefix: str = 'graphviz', filename: Optional[str] = None
- ) -> tuple[Optional[str], Optional[str]]:
+ prefix: str = 'graphviz', filename: str | None = None
+ ) -> tuple[str | None, str | None]:
"""Render graphviz code into a PNG or PDF output file."""
graphviz_dot = options.get('graphviz_dot', self.builder.config.graphviz_dot)
hashkey = (code + str(options) + str(graphviz_dot) +
@@ -265,8 +265,8 @@ def render_dot(self: SphinxTranslator, code: str, options: dict, format: str,
def render_dot_html(self: HTML5Translator, node: graphviz, code: str, options: dict,
- prefix: str = 'graphviz', imgcls: Optional[str] = None,
- alt: Optional[str] = None, filename: Optional[str] = None
+ prefix: str = 'graphviz', imgcls: str | None = None,
+ alt: str | None = None, filename: str | None = None
) -> tuple[str, str]:
format = self.builder.config.graphviz_output_format
try:
@@ -322,7 +322,7 @@ def html_visit_graphviz(self: HTML5Translator, node: graphviz) -> None:
def render_dot_latex(self: LaTeXTranslator, node: graphviz, code: str,
- options: dict, prefix: str = 'graphviz', filename: Optional[str] = None
+ options: dict, prefix: str = 'graphviz', filename: str | None = None
) -> None:
try:
fname, outfn = render_dot(self, code, options, 'pdf', prefix, filename)