def update_without_suffix(self, suffix: str, *functions, **kwargs) -> Composer: """ Given a suffix and a list of (named) functions, this adds the functions to the composer but first strips the suffix from their name. This is very useful to stop name shadowing. Args: suffix: The suffix to strip off the function names functions: functions to add while stripping the suffix kwargs: named functions to add Returns: A new composer with the functions added """ args_with_names = { strip_required_suffix(arg.__name__, suffix): arg for arg in functions } return self.update(**args_with_names, **kwargs)
def unwrapped_markdown(s): s = markdown(s) s = strip_required_prefix(s, "<p>") s = strip_required_suffix(s, "</p>") return s
import re import sys import threading import traceback from functools import lru_cache, partial from io import StringIO from itertools import combinations from random import shuffle import pygments from littleutils import strip_required_prefix, strip_required_suffix, withattrs from pygments.formatters import HtmlFormatter from pygments.lexers import get_lexer_by_name from pygments.styles import get_style_by_name site_packages = strip_required_suffix(pygments.__file__, f"pygments{os.path.sep}__init__.py") sys.path.append(site_packages + "didyoumean") from didyoumean.didyoumean_internal import get_suggestions_for_exception # noqa lexer = get_lexer_by_name("python3") monokai = get_style_by_name("monokai") html_formatter = HtmlFormatter(nowrap=True) internal_dir = os.path.dirname( os.path.dirname((lambda: 0).__code__.co_filename)) def assign(**attrs): def decorator(f): return withattrs(f, **attrs)
import ast import os import executing from littleutils import strip_required_suffix site_packages = strip_required_suffix( executing.__file__, f"executing{os.path.sep}__init__.py" ) def is_valid_syntax(text): try: ast.parse(text) return True except Exception: return False
from io import StringIO from itertools import combinations from random import shuffle from textwrap import dedent import pygments import stack_data from littleutils import strip_required_prefix, strip_required_suffix, withattrs from markdown import markdown from markdown.extensions import Extension from markdown.treeprocessors import Treeprocessor from pygments.formatters import HtmlFormatter from pygments.lexers import get_lexer_by_name from pygments.styles import get_style_by_name site_packages = strip_required_suffix(pygments.__file__, "pygments/__init__.py") sys.path.append(site_packages + "didyoumean/") from didyoumean.didyoumean_internal import get_suggestions_for_exception # noqa lexer = get_lexer_by_name("python3") monokai = get_style_by_name("monokai") html_formatter = HtmlFormatter(nowrap=True) internal_dir = os.path.dirname(os.path.dirname( (lambda: 0).__code__.co_filename )) def assign(**attrs):