Get the installed package version. Tries ``importlib.metadata`` first (canonical source from the installed dist-info), falling back to the package's ``__version__`` attribute if metadata is unavailable or corrupt. This matters for editable installs on filesystems where iCloud / OneD
()
| 55 | |
| 56 | |
| 57 | def _get_version() -> str: |
| 58 | """Get the installed package version. |
| 59 | |
| 60 | Tries ``importlib.metadata`` first (canonical source from the installed |
| 61 | dist-info), falling back to the package's ``__version__`` attribute if |
| 62 | metadata is unavailable or corrupt. This matters for editable installs |
| 63 | on filesystems where iCloud / OneDrive can leave orphan dist-info dirs |
| 64 | behind that confuse importlib.metadata's lookup. |
| 65 | """ |
| 66 | try: |
| 67 | v = pkg_version("code-review-graph") |
| 68 | if v: |
| 69 | return v |
| 70 | except PackageNotFoundError as exc: |
| 71 | logger.debug("Package metadata unavailable: %s", exc) |
| 72 | # Fallback: read __version__ directly from the package. |
| 73 | try: |
| 74 | from . import __version__ as fallback_version |
| 75 | if fallback_version: |
| 76 | return fallback_version |
| 77 | except ImportError: |
| 78 | pass |
| 79 | return "dev" |
| 80 | |
| 81 | |
| 82 | def _supports_color() -> bool: |
no outgoing calls
no test coverage detected