14
14
from __future__ import absolute_import , division , print_function
15
15
16
16
import io
17
- from typing import Any , Dict , Optional , TextIO , Union , TYPE_CHECKING
17
+ from typing import Any , Dict , IO , Optional , Union
18
18
19
19
from docutils .core import publish_parts
20
20
from docutils .nodes import colspec , image
23
23
24
24
from .clean import clean
25
25
26
- if TYPE_CHECKING :
27
- # Prevent a circular import
28
- from .integration .distutils import _WarningStream
29
-
30
26
31
27
class ReadMeHTMLTranslator (HTMLTranslator ): # type: ignore[misc] # docutils is incomplete, returns `Any` python/typeshed#7256 # noqa E501
32
28
@@ -109,7 +105,7 @@ def emptytag(
109
105
110
106
def render (
111
107
raw : str ,
112
- stream : Optional [Union [ io . StringIO , TextIO , "_WarningStream" ]] = None ,
108
+ stream : Optional [IO [ str ]] = None ,
113
109
** kwargs : Any
114
110
) -> Optional [str ]:
115
111
if stream is None :
@@ -134,16 +130,6 @@ def render(
134
130
return clean (rendered )
135
131
else :
136
132
# If the warnings stream is empty, docutils had none, so add ours.
137
-
138
- # We have to currently handle the legacy disutils integration check
139
- # command, as it implements its own warnings stream structure.
140
- # Once that code is removed, we can remove this conditional.
141
- if hasattr (stream , "output" ):
142
- if not stream .output .getvalue (): # type: ignore[union-attr]
143
- stream .write ("No content rendered from RST source." )
144
- elif isinstance (stream , io .StringIO ) and not stream .getvalue ():
145
- stream .write ("No content rendered from RST source." )
146
- elif isinstance (stream , TextIO ) and not stream .readlines ():
147
- # This is `sys.stderr` from using readme_renderer CLI
133
+ if not stream .tell ():
148
134
stream .write ("No content rendered from RST source." )
149
135
return None
0 commit comments