From fb37c19e083490ca0bf461509d09cf05533055b2 Mon Sep 17 00:00:00 2001 From: BlueGlassBlock Date: Fri, 24 Jun 2022 18:38:32 +0800 Subject: [PATCH] improve docstrings and add py.typed --- .github/workflows/pypi-publish.yml | 24 ++++++++++++++++++++++++ creart/creator.py | 22 +++++++++++++++++++++- creart/py.typed | 0 3 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/pypi-publish.yml create mode 100644 creart/py.typed diff --git a/.github/workflows/pypi-publish.yml b/.github/workflows/pypi-publish.yml new file mode 100644 index 0000000..76cad04 --- /dev/null +++ b/.github/workflows/pypi-publish.yml @@ -0,0 +1,24 @@ +name: Python package +on: + push: + tags: + - "v*.*.*" +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-python@v3 + name: Ensure Python Runtime + with: + python-version: '3.x' + architecture: 'x64' + - name: Ensure PDM & twine + run: | + python3 -m pip install pdm twine + - name: Build Package + run: | + pdm build + - name: Publish to PyPI + run: | + twine upload dist/* --non-interactive -u __token__ -p ${{ secrets.PYPI_TOKEN }} \ No newline at end of file diff --git a/creart/creator.py b/creart/creator.py index 3108bb6..177f820 100644 --- a/creart/creator.py +++ b/creart/creator.py @@ -7,24 +7,44 @@ @dataclass class CreateTargetInfo: + """Information of create target.""" + module: str + """dotted name of target's module""" + identify: str - + """target's qualified name""" + # info for cli humanized_name: str | None = None + """humanized name""" + description: str | None = None + """description of target""" + author: list[str] | None = None + """list of authors""" + T = TypeVar("T") + class AbstractCreator(metaclass=ABCMeta): + """factory of `targets` class attributes + + add `entry points` in your distribution to support auto discovery. + """ + targets: ClassVar[tuple[CreateTargetInfo, ...]] + """Supported targets' creation info, as a tuple.""" @staticmethod def available() -> bool: + """This function will be called to determine whether the targets could be created.""" return True @staticmethod @abstractmethod def create(create_type: type[T]) -> T: + """Actual creation implementation.""" ... diff --git a/creart/py.typed b/creart/py.typed new file mode 100644 index 0000000..e69de29