Merge branch '242-optional-numba-for-yaml-emitter' into 'development'

yaml.CSafeDumper can be subclassed

Closes #242

See merge request damask/DAMASK!678
This commit is contained in:
Martin Diehl 2022-12-06 20:17:24 +00:00
commit 418e2f022b
1 changed files with 7 additions and 5 deletions

View File

@ -8,8 +8,10 @@ import numpy as np
import yaml
try:
from yaml import CSafeLoader as SafeLoader
from yaml import CSafeDumper as SafeDumper
except ImportError:
from yaml import SafeLoader # type: ignore
from yaml import SafeDumper # type: ignore
from ._typehints import FileHandle
from . import Rotation
@ -17,20 +19,20 @@ from . import util
MyType = TypeVar('MyType', bound='Config')
class NiceDumper(yaml.SafeDumper):
class NiceDumper(SafeDumper):
"""Make YAML readable for humans."""
def write_line_break(self,
data: Optional[str] = None):
super().write_line_break(data)
super().write_line_break(data) # type: ignore
if len(self.indents) == 1:
super().write_line_break()
if len(self.indents) == 1: # type: ignore
super().write_line_break() # type: ignore
def increase_indent(self,
flow: bool = False,
indentless: bool = False):
return super().increase_indent(flow, False)
return super().increase_indent(flow, False) # type: ignore
def represent_data(self,
data: Any):