Utils
Auto-generated documentation for builder.mypy_boto3_builder.writers.utils module.
Jinja2 renderer and black formatter.
- mypy-boto3 / Modules /
Builder
/ Mypy Boto3 Builder / Writers / Utils
blackify
def blackify(content: str, file_path: Path, fast: bool = True) -> str:
Format content
with black
if file_path
is *.py
or *.pyi
.
On error writes invalid content
to file_path
to check for errors.
Arguments
content
- Python code to format.file_path
- Target file path.fast
- Whether to skip AST post-check.
Returns
Formatted python code.
Raises
ValueError
- Ifcontent
is not a valid Python code.
render_jinja2_template
def render_jinja2_template(
template_path: Path,
package: Optional[Package] = None,
service_name: Optional[ServiceName] = None,
) -> str:
Render Jinja2 template to a string.
Arguments
template_path
- Relative path to template inTEMPLATES_PATH
module
- Module record.service_name
- ServiceName instance.
Returns
A rendered template.