@@ -16,17 +16,18 @@ def dump(self, data: Any, stream=None, **kw) -> None | str:
1616 YAML .dump (self , data , stream , ** kw )
1717 if return_string :
1818 return stream .getvalue ()
19+ return None
1920
2021
2122#
2223# Overload the comment writer to remove superfluous newlines.
2324#
2425
2526# Save the original comment writer so our extended version can use it.
26- ruamel .yaml .emitter .Emitter .write_comment_original = ruamel .yaml .emitter .Emitter .write_comment
27+ ruamel .yaml .emitter .Emitter .write_comment_original = ruamel .yaml .emitter .Emitter .write_comment # type: ignore
2728
2829# Create the new comment writer.
29- def strip_empty_lines_write_comment (self , comment , pre = False ):
30+ def strip_empty_lines_write_comment (self , comment : Any , pre : bool = False ) -> None :
3031 # Check if comment is nothing but newlines.
3132 # Then replace with a single new line.
3233 string_check = comment .value .replace ("\n " , "" )
@@ -37,13 +38,13 @@ def strip_empty_lines_write_comment(self, comment, pre=False):
3738
3839
3940# Set ruamel.yaml to use the new writer.
40- ruamel .yaml .emitter .Emitter .write_comment = strip_empty_lines_write_comment
41+ ruamel .yaml .emitter .Emitter .write_comment = strip_empty_lines_write_comment # type: ignore
4142
4243
4344yaml = YAMLWithStrings ()
44- yaml .preserve_quotes = True
45+ yaml .preserve_quotes = True # type: ignore
4546yaml .default_flow_style = False
46- yaml .width = 120
47+ yaml .width = 120 # type: ignore
4748yaml .indent (mapping = 2 , sequence = 4 , offset = 2 )
4849
4950
@@ -52,4 +53,4 @@ def yaml_formatter(input: str) -> str:
5253 # comments and other useful data. The dump function uses that to add
5354 # comments back in.
5455 data = yaml .load (input )
55- return yaml .dump (data )
56+ return yaml .dump (data ) # type: ignore
0 commit comments