Skip to content

topmark.filetypes.instances

topmark / filetypes / instances

Built-in and plugin-provided file type declarations for the base registry.

This module aggregates FileType definitions from TopMark's built-in file type modules and from the topmark.filetypes entry point group. The resulting base registry is built lazily on first access and cached for reuse.

Notes
  • Built-in file type modules are imported lazily.
  • Plugin file types are discovered through the topmark.filetypes entry point group.
  • The returned base registry is a plain dict and should be treated as immutable by callers.
  • This module exposes the base registry only (built-ins + entry points). For the effective composed view used by the public registry facade, use topmark.registry.filetypes.FileTypeRegistry.as_mapping.
  • Overlay mutations belong in topmark.registry, not in this module.

get_base_file_type_registry cached

get_base_file_type_registry()

Return and cache the base file type registry.

The base registry contains built-in and plugin-provided file types keyed by FileType.local_key.

Returns:

Type Description
dict[str, FileType]

Cached mapping of file type local key to FileType.

Notes

For the effective composed registry (including overlay mutations used by tests and advanced callers), use topmark.registry.filetypes.FileTypeRegistry.as_mapping.

Source code in src/topmark/filetypes/instances.py
@lru_cache(maxsize=1)
def get_base_file_type_registry() -> dict[str, FileType]:
    """Return and cache the base file type registry.

    The base registry contains built-in and plugin-provided file types keyed by
    ``FileType.local_key``.

    Returns:
        Cached mapping of file type local key to `FileType`.

    Notes:
        For the effective composed registry (including overlay mutations used by
        tests and advanced callers), use
        [`topmark.registry.filetypes.FileTypeRegistry.as_mapping`][topmark.registry.filetypes.FileTypeRegistry.as_mapping].
    """
    all_types: list[FileType] = _aggregate_all_filetypes()
    registry: dict[str, FileType] = _generate_registry(all_types)
    logger.debug("Loaded %d file types", len(registry))
    return registry