RAHHH
This commit is contained in:
36
backend/lib/python3.12/site-packages/incremental/_hatch.py
Normal file
36
backend/lib/python3.12/site-packages/incremental/_hatch.py
Normal file
@@ -0,0 +1,36 @@
|
||||
# Copyright (c) Twisted Matrix Laboratories.
|
||||
# See LICENSE for details.
|
||||
|
||||
import os
|
||||
import shlex
|
||||
from typing import Any, Dict, List, Type, TypedDict
|
||||
|
||||
from hatchling.version.source.plugin.interface import VersionSourceInterface
|
||||
from hatchling.plugin import hookimpl
|
||||
|
||||
from incremental import _load_pyproject_toml, _existing_version
|
||||
|
||||
|
||||
class _VersionData(TypedDict):
|
||||
version: str
|
||||
|
||||
|
||||
class IncrementalVersionSource(VersionSourceInterface):
|
||||
PLUGIN_NAME = "incremental"
|
||||
|
||||
def get_version_data(self) -> _VersionData: # type: ignore[override]
|
||||
path = os.path.join(self.root, "./pyproject.toml")
|
||||
config = _load_pyproject_toml(path)
|
||||
return {"version": _existing_version(config.version_path).public()}
|
||||
|
||||
def set_version(self, version: str, version_data: Dict[Any, Any]) -> None:
|
||||
raise NotImplementedError(
|
||||
f"Run `python -m incremental.version --newversion"
|
||||
f" {shlex.quote(version)}` to set the version.\n\n"
|
||||
f" See `python -m incremental.version --help` for more options."
|
||||
)
|
||||
|
||||
|
||||
@hookimpl
|
||||
def hatch_register_version_source() -> List[Type[VersionSourceInterface]]:
|
||||
return [IncrementalVersionSource]
|
||||
Reference in New Issue
Block a user