or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

builtins.mdconcurrency.mddata-processing.mddevelopment.mdessential-stdlib.mdindex.mdnetworking.mdsecurity.mdsystem-os.md
tile.json

development.mddocs/

Development and Testing

Tools for software development including logging, debugging, testing, command-line argument parsing, and code introspection.

Capabilities

Logging

Flexible event logging system for applications and libraries.

import logging

# Basic logging functions
def debug(msg, *args, **kwargs) -> None: ...
def info(msg, *args, **kwargs) -> None: ...
def warning(msg, *args, **kwargs) -> None: ...
def warn(msg, *args, **kwargs) -> None: ...  # Deprecated alias
def error(msg, *args, **kwargs) -> None: ...
def exception(msg, *args, **kwargs) -> None: ...
def critical(msg, *args, **kwargs) -> None: ...
def fatal(msg, *args, **kwargs) -> None: ...  # Alias for critical

# Configuration functions
def basicConfig(**kwargs) -> None: ...
def getLogger(name: str = None) -> Logger: ...
def disable(level: int = CRITICAL) -> None: ...

# Logger class
class Logger:
    def __init__(self, name: str, level: int = NOTSET) -> None: ...
    
    # Logging methods
    def debug(self, msg, *args, **kwargs) -> None: ...
    def info(self, msg, *args, **kwargs) -> None: ...
    def warning(self, msg, *args, **kwargs) -> None: ...
    def warn(self, msg, *args, **kwargs) -> None: ...
    def error(self, msg, *args, **kwargs) -> None: ...
    def exception(self, msg, *args, **kwargs) -> None: ...
    def critical(self, msg, *args, **kwargs) -> None: ...
    def fatal(self, msg, *args, **kwargs) -> None: ...
    def log(self, level: int, msg, *args, **kwargs) -> None: ...
    
    # Logger configuration
    def setLevel(self, level: int) -> None: ...
    def getEffectiveLevel(self) -> int: ...
    def isEnabledFor(self, level: int) -> bool: ...
    def addHandler(self, hdlr: Handler) -> None: ...
    def removeHandler(self, hdlr: Handler) -> None: ...
    def addFilter(self, filter) -> None: ...
    def removeFilter(self, filter) -> None: ...
    def hasHandlers(self) -> bool: ...
    
    # Properties
    @property
    def name(self) -> str: ...
    @property
    def level(self) -> int: ...
    @property
    def parent(self) -> Logger: ...
    @property
    def propagate(self) -> bool: ...
    @propagate.setter
    def propagate(self, value: bool) -> None: ...

# Handler classes
class Handler:
    def __init__(self, level: int = NOTSET) -> None: ...
    def emit(self, record: LogRecord) -> None: ...
    def handle(self, record: LogRecord) -> bool: ...
    def setLevel(self, level: int) -> None: ...
    def setFormatter(self, formatter: Formatter) -> None: ...
    def addFilter(self, filter) -> None: ...
    def removeFilter(self, filter) -> None: ...
    def flush(self) -> None: ...
    def close(self) -> None: ...

class StreamHandler(Handler):
    def __init__(self, stream=None) -> None: ...

class FileHandler(StreamHandler):
    def __init__(self, filename: str, mode: str = 'a', 
                 encoding=None, delay: bool = False, 
                 errors=None) -> None: ...

class RotatingFileHandler(FileHandler):
    def __init__(self, filename: str, mode: str = 'a', maxBytes: int = 0, 
                 backupCount: int = 0, encoding=None, delay: bool = False, 
                 errors=None) -> None: ...

class TimedRotatingFileHandler(FileHandler):
    def __init__(self, filename: str, when: str = 'h', interval: int = 1, 
                 backupCount: int = 0, encoding=None, delay: bool = False, 
                 utc: bool = False, atTime=None, errors=None) -> None: ...

# Formatter class
class Formatter:
    def __init__(self, fmt=None, datefmt=None, style: str = '%', 
                 validate: bool = True) -> None: ...
    def format(self, record: LogRecord) -> str: ...
    def formatTime(self, record: LogRecord, datefmt=None) -> str: ...
    def formatException(self, ei) -> str: ...
    def formatStack(self, stack_info: str) -> str: ...

# Log record
class LogRecord:
    def __init__(self, name: str, level: int, pathname: str, lineno: int, 
                 msg, args, exc_info, func=None, sinfo=None) -> None: ...
    @property
    def name(self) -> str: ...
    @property
    def msg(self): ...
    @property
    def args(self): ...
    @property
    def levelname(self) -> str: ...
    @property
    def levelno(self) -> int: ...
    @property
    def pathname(self) -> str: ...
    @property
    def filename(self) -> str: ...
    @property
    def module(self) -> str: ...
    @property
    def lineno(self) -> int: ...
    @property
    def funcName(self) -> str: ...
    @property
    def created(self) -> float: ...
    @property
    def msecs(self) -> float: ...
    @property
    def relativeCreated(self) -> float: ...
    @property
    def thread(self) -> int: ...
    @property
    def threadName(self) -> str: ...
    @property
    def processName(self) -> str: ...
    @property
    def process(self) -> int: ...
    @property
    def getMessage(self) -> str: ...

# Logging levels
CRITICAL: int = 50
FATAL: int = CRITICAL
ERROR: int = 40
WARNING: int = 30
WARN: int = WARNING
INFO: int = 20
DEBUG: int = 10
NOTSET: int = 0

Command-Line Argument Parsing

Comprehensive command-line interface creation with argparse.

import argparse

class ArgumentParser:
    def __init__(self, prog=None, usage=None, description=None, epilog=None, 
                 parents=[], formatter_class=HelpFormatter, prefix_chars: str = '-', 
                 fromfile_prefix_chars=None, argument_default=None, 
                 conflict_handler: str = 'error', add_help: bool = True, 
                 allow_abbrev: bool = True, exit_on_error: bool = True) -> None: ...
    
    # Adding arguments
    def add_argument(self, *name_or_flags, action=None, nargs=None, const=None, 
                     default=None, type=None, choices=None, required=None, 
                     help=None, metavar=None, dest=None) -> Action: ...
    def add_argument_group(self, title=None, description=None) -> ArgumentGroup: ...
    def add_mutually_exclusive_group(self, required: bool = False) -> MutuallyExclusiveGroup: ...
    
    # Parsing
    def parse_args(self, args=None, namespace=None) -> Namespace: ...
    def parse_known_args(self, args=None, namespace=None) -> tuple: ...
    def parse_intermixed_args(self, args=None, namespace=None) -> Namespace: ...
    def parse_known_intermixed_args(self, args=None, namespace=None) -> tuple: ...
    
    # Utilities
    def print_usage(self, file=None) -> None: ...
    def print_help(self, file=None) -> None: ...
    def format_usage(self) -> str: ...
    def format_help(self) -> str: ...
    def error(self, message: str) -> None: ...
    def set_defaults(self, **kwargs) -> None: ...
    def get_default(self, dest: str): ...

class Namespace:
    def __init__(self, **kwargs) -> None: ...
    def __contains__(self, key: str) -> bool: ...
    def __eq__(self, other) -> bool: ...

# Argument group classes
class ArgumentGroup:
    def add_argument(self, *name_or_flags, **kwargs) -> Action: ...

class MutuallyExclusiveGroup(ArgumentGroup):
    def add_argument(self, *name_or_flags, **kwargs) -> Action: ...

# Action classes
class Action:
    def __init__(self, option_strings, dest, nargs=None, const=None, 
                 default=None, type=None, choices=None, required: bool = False, 
                 help=None, metavar=None) -> None: ...
    def __call__(self, parser, namespace, values, option_string=None) -> None: ...

class BooleanOptionalAction(Action): ...

# Formatter classes
class HelpFormatter: ...
class RawDescriptionHelpFormatter(HelpFormatter): ...
class RawTextHelpFormatter(RawDescriptionHelpFormatter): ...
class ArgumentDefaultsHelpFormatter(HelpFormatter): ...
class MetavarTypeHelpFormatter(HelpFormatter): ...

# File type
class FileType:
    def __init__(self, mode: str = 'r', bufsize: int = -1, 
                 encoding=None, errors=None) -> None: ...
    def __call__(self, string: str): ...

# Exceptions
class ArgumentError(Exception): ...
class ArgumentTypeError(Exception): ...

Unit Testing

Built-in unit testing framework for creating and running tests.

import unittest

# Test case class
class TestCase:
    def __init__(self, methodName: str = 'runTest') -> None: ...
    
    # Test methods
    def setUp(self) -> None: ...
    def tearDown(self) -> None: ...
    def setUpClass(cls) -> None: ...
    def tearDownClass(cls) -> None: ...
    def run(self, result=None) -> TestResult: ...
    def skipTest(self, reason: str) -> None: ...
    def subTest(self, msg=None, **params): ...
    
    # Assertion methods
    def assertEqual(self, first, second, msg=None) -> None: ...
    def assertNotEqual(self, first, second, msg=None) -> None: ...
    def assertTrue(self, expr, msg=None) -> None: ...
    def assertFalse(self, expr, msg=None) -> None: ...
    def assertIs(self, expr1, expr2, msg=None) -> None: ...
    def assertIsNot(self, expr1, expr2, msg=None) -> None: ...
    def assertIsNone(self, expr, msg=None) -> None: ...
    def assertIsNotNone(self, expr, msg=None) -> None: ...
    def assertIn(self, member, container, msg=None) -> None: ...
    def assertNotIn(self, member, container, msg=None) -> None: ...
    def assertIsInstance(self, obj, cls, msg=None) -> None: ...
    def assertNotIsInstance(self, obj, cls, msg=None) -> None: ...
    def assertRaises(self, exception, callable=None, *args, **kwds): ...
    def assertRaisesRegex(self, exception, regex, callable=None, *args, **kwds): ...
    def assertWarns(self, warning, callable=None, *args, **kwds): ...
    def assertWarnsRegex(self, warning, regex, callable=None, *args, **kwds): ...
    def assertLogs(self, logger=None, level=None): ...
    def assertAlmostEqual(self, first, second, places=None, msg=None, delta=None) -> None: ...
    def assertNotAlmostEqual(self, first, second, places=None, msg=None, delta=None) -> None: ...
    def assertGreater(self, a, b, msg=None) -> None: ...
    def assertGreaterEqual(self, a, b, msg=None) -> None: ...
    def assertLess(self, a, b, msg=None) -> None: ...
    def assertLessEqual(self, a, b, msg=None) -> None: ...
    def assertRegex(self, text: str, regex, msg=None) -> None: ...
    def assertNotRegex(self, text: str, regex, msg=None) -> None: ...
    def assertCountEqual(self, first, second, msg=None) -> None: ...
    def assertMultiLineEqual(self, first: str, second: str, msg=None) -> None: ...
    def assertSequenceEqual(self, seq1, seq2, msg=None, seq_type=None) -> None: ...
    def assertListEqual(self, list1: list, list2: list, msg=None) -> None: ...
    def assertTupleEqual(self, tuple1: tuple, tuple2: tuple, msg=None) -> None: ...
    def assertSetEqual(self, set1: set, set2: set, msg=None) -> None: ...
    def assertDictEqual(self, d1: dict, d2: dict, msg=None) -> None: ...

# Test suite
class TestSuite:
    def __init__(self, tests=()) -> None: ...
    def addTest(self, test) -> None: ...
    def addTests(self, tests) -> None: ...
    def run(self, result) -> TestResult: ...
    def __iter__(self): ...
    def countTestCases(self) -> int: ...

# Test result
class TestResult:
    def __init__(self, stream=None, descriptions=None, verbosity=None) -> None: ...
    def startTest(self, test) -> None: ...
    def stopTest(self, test) -> None: ...
    def addError(self, test, err) -> None: ...
    def addFailure(self, test, err) -> None: ...
    def addSuccess(self, test) -> None: ...
    def addSkip(self, test, reason: str) -> None: ...
    def addExpectedFailure(self, test, err) -> None: ...
    def addUnexpectedSuccess(self, test) -> None: ...
    def wasSuccessful(self) -> bool: ...
    def stop(self) -> None: ...
    @property
    def testsRun(self) -> int: ...
    @property
    def errors(self) -> list: ...
    @property
    def failures(self) -> list: ...
    @property
    def skipped(self) -> list: ...

# Test runner
class TestRunner:
    def run(self, test) -> TestResult: ...

class TextTestRunner(TestRunner):
    def __init__(self, stream=None, descriptions: bool = True, verbosity: int = 1, 
                 failfast: bool = False, buffer: bool = False, resultclass=None, 
                 warnings=None, tb_locals: bool = False) -> None: ...

# Test loader
class TestLoader:
    def loadTestsFromTestCase(self, testCaseClass) -> TestSuite: ...
    def loadTestsFromModule(self, module) -> TestSuite: ...
    def loadTestsFromName(self, name: str, module=None) -> TestSuite: ...
    def loadTestsFromNames(self, names: list, module=None) -> TestSuite: ...
    def discover(self, start_dir: str, pattern: str = 'test*.py', 
                 top_level_dir=None) -> TestSuite: ...

# Test decorators and utilities
def skip(reason: str): ...
def skipIf(condition: bool, reason: str): ...
def skipUnless(condition: bool, reason: str): ...
def expectedFailure(test_item): ...

def main(module: str = '__main__', defaultTest=None, argv=None, 
         testRunner=None, testLoader=None, exit: bool = True, 
         verbosity: int = 1, failfast=None, catchbreak=None, buffer=None, 
         warnings=None, tb_locals: bool = False) -> None: ...

# Mock objects (unittest.mock)
class Mock:
    def __init__(self, spec=None, side_effect=None, return_value=None, 
                 wraps=None, name=None, spec_set=None, unsafe: bool = False, 
                 **kwargs) -> None: ...
    def assert_called(self) -> None: ...
    def assert_called_once(self) -> None: ...
    def assert_called_with(self, *args, **kwargs) -> None: ...
    def assert_called_once_with(self, *args, **kwargs) -> None: ...
    def assert_any_call(self, *args, **kwargs) -> None: ...
    def assert_has_calls(self, calls: list, any_order: bool = False) -> None: ...
    def assert_not_called(self) -> None: ...
    def reset_mock(self, visited=None, return_value: bool = False, 
                   side_effect: bool = False) -> None: ...
    @property
    def called(self) -> bool: ...
    @property
    def call_count(self) -> int: ...
    @property
    def return_value(self): ...
    @property
    def side_effect(self): ...
    @property
    def call_args(self): ...
    @property
    def call_args_list(self) -> list: ...

class MagicMock(Mock): ...

def patch(target: str, new=None, spec=None, create: bool = False, 
          spec_set=None, autospec=None, new_callable=None, **kwargs): ...
def patch.object(target, attribute: str, new=None, spec=None, 
                 create: bool = False, spec_set=None, autospec=None, 
                 new_callable=None, **kwargs): ...
def patch.multiple(target, spec=None, create: bool = False, 
                   spec_set=None, autospec=None, new_callable=None, 
                   **kwargs): ...
def patch.dict(in_dict, values=(), clear: bool = False, **kwargs): ...

Debugging and Introspection

Tools for debugging code and introspecting Python objects and execution.

import pdb
import traceback
import inspect

# Python debugger (pdb)
def run(statement: str, globals=None, locals=None) -> None: ...
def runeval(expression: str, globals=None, locals=None): ...
def runcall(func, *args, **kwds): ...
def set_trace() -> None: ...
def post_mortem(t=None) -> None: ...
def pm() -> None: ...

class Pdb:
    def __init__(self, completekey: str = 'tab', stdin=None, stdout=None, 
                 skip=None, nosigint: bool = False, readrc: bool = True) -> None: ...
    def run(self, cmd: str, globals=None, locals=None) -> None: ...
    def runeval(self, expr: str, globals=None, locals=None): ...
    def runcall(self, func, *args, **kwds): ...
    def set_trace(self, frame=None) -> None: ...

# Traceback utilities
def print_exc(limit=None, file=None, chain: bool = True) -> None: ...
def print_exception(etype, value, tb, limit=None, file=None, chain: bool = True) -> None: ...
def print_last(limit=None, file=None, chain: bool = True) -> None: ...
def print_stack(f=None, limit=None, file=None) -> None: ...
def extract_tb(tb, limit=None) -> StackSummary: ...
def extract_stack(f=None, limit=None) -> StackSummary: ...
def format_list(extracted_list) -> list: ...
def format_exception_only(etype, value) -> list: ...
def format_exception(etype, value, tb, limit=None, chain: bool = True) -> list: ...
def format_exc(limit=None, chain: bool = True) -> str: ...
def format_tb(tb, limit=None) -> list: ...
def format_stack(f=None, limit=None) -> list: ...

class TracebackException:
    def __init__(self, exc_type, exc_value, exc_traceback, limit=None, 
                 lookup_lines: bool = True, capture_locals: bool = False, 
                 compact: bool = False, max_group_width: int = 15, 
                 max_group_depth: int = 10) -> None: ...
    @classmethod
    def from_exception(cls, exc, limit=None, lookup_lines: bool = True, 
                       capture_locals: bool = False, compact: bool = False): ...
    def format(self, chain: bool = True) -> list: ...
    def format_exception_only(self) -> list: ...

# Inspection utilities
def getmembers(object, predicate=None) -> list: ...
def getmodule(object): ...
def ismodule(object) -> bool: ...
def isclass(object) -> bool: ...
def ismethod(object) -> bool: ...
def isfunction(object) -> bool: ...
def isgeneratorfunction(object) -> bool: ...
def isgenerator(object) -> bool: ...
def iscoroutinefunction(object) -> bool: ...
def iscoroutine(object) -> bool: ...
def isbuiltin(object) -> bool: ...
def isroutine(object) -> bool: ...
def isabstract(object) -> bool: ...
def ismethoddescriptor(object) -> bool: ...
def isdatadescriptor(object) -> bool: ...
def isgetsetdescriptor(object) -> bool: ...
def ismemberdescriptor(object) -> bool: ...

def getdoc(object) -> str: ...
def getcomments(object) -> str: ...
def getfile(object) -> str: ...
def getmodulename(path: str) -> str: ...
def getsourcefile(object) -> str: ...
def getsourcelines(object) -> tuple: ...
def getsource(object) -> str: ...
def cleandoc(doc: str) -> str: ...

def signature(callable, follow_wrapped: bool = True) -> Signature: ...
def getcallargs(func, *args, **kwds) -> dict: ...

class Signature:
    def __init__(self, parameters=None, return_annotation=None) -> None: ...
    def bind(self, *args, **kwargs) -> BoundArguments: ...
    def bind_partial(self, *args, **kwargs) -> BoundArguments: ...
    def replace(self, parameters=None, return_annotation=None) -> Signature: ...
    @property
    def parameters(self): ...
    @property
    def return_annotation(self): ...

class Parameter:
    def __init__(self, name: str, kind, default=None, annotation=None) -> None: ...
    def replace(self, name=None, kind=None, default=None, annotation=None) -> Parameter: ...
    @property
    def name(self) -> str: ...
    @property
    def default(self): ...
    @property
    def annotation(self): ...
    @property
    def kind(self): ...
    
    # Parameter kinds
    POSITIONAL_ONLY: int
    POSITIONAL_OR_KEYWORD: int
    VAR_POSITIONAL: int
    KEYWORD_ONLY: int
    VAR_KEYWORD: int

class BoundArguments:
    def __init__(self, signature: Signature, arguments: dict) -> None: ...
    def apply_defaults(self) -> None: ...
    @property
    def arguments(self) -> dict: ...
    @property
    def signature(self) -> Signature: ...

Types

Logging Types

# Log level type
LogLevel = int  # One of DEBUG, INFO, WARNING, ERROR, CRITICAL

# Log record fields
LogRecordDict = dict[str, object]  # Log record as dictionary

# Handler stream types  
StreamType = object  # File-like object for handlers

Argument Parser Types

# Argument type conversion function
ArgumentType = callable[[str], object]

# Argument choices
ArgumentChoices = list | set | tuple | range

# Argument action types
ArgumentAction = str  # 'store', 'store_const', 'store_true', 'store_false', 'append', 'append_const', 'count', 'help', 'version'

Test Types

# Test callable type
TestMethod = callable[[], None]

# Test case identifier
TestCaseId = str  # Typically 'module.class.method'

# Test result outcome
TestOutcome = str  # 'success', 'failure', 'error', 'skip', 'expected_failure', 'unexpected_success'

Inspection Types

# Frame information
FrameInfo = tuple  # (frame, filename, lineno, function, code_context, index)

# Stack trace information
TraceTuple = tuple  # (filename, lineno, function, text)

# Module members
MemberInfo = tuple[str, object]  # (name, value) pairs