def __init__(self, pre: str | ast.Module, post: str | ast.Module):
        """
        pre and post are either strings, or ast.Modules object that need to be run just before or after
        the user code.

        While strings are possible, we suggest using ast.Modules
        object and mangling the corresponding variable names
        to be invalid python identifiers to avoid name conflicts.
        """
        if isinstance(pre, str):
            pre = parse(pre)
        if isinstance(post, str):
            post = parse(post)

        self.pre = pre.body
        self.post = post.body
        self.active = True

        pre and post are either strings, or ast.Modules object that need to be run just before or after
        the user code.

        While strings are possible, we suggest using ast.Modules
        object and mangling the corresponding variable names
        to be invalid python identifiers to avoid name conflicts.
        
pyinstrument/magic/_utils.py