e4dcfc49aa
Tests / Import Check (Python 3.13) (push) Has been cancelled
Tests / Import Check (Python 3.14) (push) Has been cancelled
Tests / Python Tests (Python 3.11) (push) Has been cancelled
Tests / Python Tests (Python 3.12) (push) Has been cancelled
Tests / Python Tests (Python 3.14) (push) Has been cancelled
Tests / Test Summary (push) Has been cancelled
Tests / Lint and Format (push) Has been cancelled
Tests / Web Node Tests (push) Has been cancelled
Tests / Import Check (Python 3.11) (push) Has been cancelled
Tests / Import Check (Python 3.12) (push) Has been cancelled
Tests / Python Tests (Python 3.13) (push) Has been cancelled
23 lines
539 B
Python
23 lines
539 B
Python
"""Cheap, cached package-version lookup for parser signatures.
|
|
|
|
Using the installed distribution version (not a CLI ``--version`` subprocess)
|
|
keeps signature computation cheap while still invalidating the parse cache when
|
|
an engine is upgraded.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from functools import lru_cache
|
|
import importlib.metadata
|
|
|
|
|
|
@lru_cache(maxsize=None)
|
|
def package_version(name: str) -> str:
|
|
try:
|
|
return importlib.metadata.version(name)
|
|
except Exception:
|
|
return ""
|
|
|
|
|
|
__all__ = ["package_version"]
|