epregistry 0.0.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- epregistry-0.0.1/.copier-answers.yml +19 -0
- epregistry-0.0.1/.github/FUNDING.yml +3 -0
- epregistry-0.0.1/.github/copilot-instructions.md +19 -0
- epregistry-0.0.1/.github/dependabot.yml +9 -0
- epregistry-0.0.1/.github/workflows/build.yml +88 -0
- epregistry-0.0.1/.github/workflows/documentation.yml +57 -0
- epregistry-0.0.1/.gitignore +30 -0
- epregistry-0.0.1/.pre-commit-config.yaml +48 -0
- epregistry-0.0.1/LICENSE +22 -0
- epregistry-0.0.1/PKG-INFO +56 -0
- epregistry-0.0.1/README.md +32 -0
- epregistry-0.0.1/docs/.empty +0 -0
- epregistry-0.0.1/duties.py +60 -0
- epregistry-0.0.1/mkdocs.yml +92 -0
- epregistry-0.0.1/overrides/_dummy.txt +1 -0
- epregistry-0.0.1/pyproject.toml +220 -0
- epregistry-0.0.1/src/epregistry/__init__.py +7 -0
- epregistry-0.0.1/src/epregistry/epregistry.py +190 -0
- epregistry-0.0.1/src/epregistry/py.typed +0 -0
- epregistry-0.0.1/tests/__init__.py +3 -0
- epregistry-0.0.1/tests/conftest.py +1 -0
- epregistry-0.0.1/tests/test_epregistry.py +145 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Changes here will be overwritten by Copier
|
|
2
|
+
_commit: v1.3.3
|
|
3
|
+
_src_path: .\copier-phil65\
|
|
4
|
+
author_email: philipptemminghoff@googlemail.com
|
|
5
|
+
author_fullname: Philipp Temminghoff
|
|
6
|
+
author_username: phil65
|
|
7
|
+
copyright_date: '2024'
|
|
8
|
+
copyright_holder: Philipp Temminghoff
|
|
9
|
+
copyright_holder_email: philipptemminghoff@googlemail.com
|
|
10
|
+
project_description: A registry for entry points (cached and generically typed)
|
|
11
|
+
project_name: epregistry
|
|
12
|
+
python_minimum_version: '3.12'
|
|
13
|
+
python_package_command_line_name: epregistry
|
|
14
|
+
python_package_distribution_name: epregistry
|
|
15
|
+
python_package_import_name: epregistry
|
|
16
|
+
repository_name: epregistry
|
|
17
|
+
repository_namespace: phil65
|
|
18
|
+
repository_provider: github.com
|
|
19
|
+
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
## Code style
|
|
2
|
+
|
|
3
|
+
You can assume Python 3.12.
|
|
4
|
+
Use newest language features if possible
|
|
5
|
+
Consider using pattern matching, walrus operators and other new syntax features.
|
|
6
|
+
Adhere to pep8.
|
|
7
|
+
|
|
8
|
+
## Tests
|
|
9
|
+
|
|
10
|
+
Tests are written using PyTest. Dont put tests into a class.
|
|
11
|
+
|
|
12
|
+
## DocStrings
|
|
13
|
+
|
|
14
|
+
DocStrings are written in google-style.
|
|
15
|
+
Dont add the types to the "Args" section.
|
|
16
|
+
Only add a Return section if a value is returned and the meaning of the returned value
|
|
17
|
+
is not obvious.
|
|
18
|
+
You can use markdown admonitions with python-markdown syntax if neccessary (!!! info, !!! note, !!! warning).
|
|
19
|
+
You can use markdown tables and markdown lists if neccessary.
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
name: Build
|
|
2
|
+
|
|
3
|
+
on: [push, pull_request]
|
|
4
|
+
|
|
5
|
+
jobs:
|
|
6
|
+
test:
|
|
7
|
+
runs-on: ${{ matrix.os }}
|
|
8
|
+
continue-on-error: ${{ matrix.python_version == '3.14' }}
|
|
9
|
+
strategy:
|
|
10
|
+
matrix:
|
|
11
|
+
python_version: ["3.12", "3.13", "3.14"]
|
|
12
|
+
os: ["ubuntu-latest", "macos-latest", "windows-latest"]
|
|
13
|
+
steps:
|
|
14
|
+
- name: Check out repository
|
|
15
|
+
uses: actions/checkout@v4
|
|
16
|
+
|
|
17
|
+
- name: Set up Python ${{ matrix.python_version }}
|
|
18
|
+
uses: actions/setup-python@v5
|
|
19
|
+
with:
|
|
20
|
+
python-version: ${{ matrix.python_version }}
|
|
21
|
+
allow-prereleases: true
|
|
22
|
+
- name: Install uv
|
|
23
|
+
uses: astral-sh/setup-uv@v3
|
|
24
|
+
with:
|
|
25
|
+
enable-cache: true
|
|
26
|
+
cache-dependency-glob: pyproject.toml
|
|
27
|
+
cache-suffix: py${{ matrix.python_version }}
|
|
28
|
+
|
|
29
|
+
- name: Install dependencies (uv sync)
|
|
30
|
+
run: uv sync --all-extras
|
|
31
|
+
|
|
32
|
+
- name: Check for code issues (ruff check)
|
|
33
|
+
uses: astral-sh/ruff-action@v1
|
|
34
|
+
|
|
35
|
+
- name: Check code format (ruff format)
|
|
36
|
+
uses: astral-sh/ruff-action@v1
|
|
37
|
+
with:
|
|
38
|
+
args: "format --check"
|
|
39
|
+
|
|
40
|
+
- name: Static type checking (MyPy)
|
|
41
|
+
run: uv run mypy src/epregistry/
|
|
42
|
+
|
|
43
|
+
- name: Run tests
|
|
44
|
+
run: uv run pytest --cov-report=xml
|
|
45
|
+
|
|
46
|
+
- name: Upload test results to Codecov
|
|
47
|
+
uses: codecov/codecov-action@v4
|
|
48
|
+
with:
|
|
49
|
+
token: ${{ secrets.CODECOV_TOKEN }}
|
|
50
|
+
fail_ci_if_error: false
|
|
51
|
+
verbose: true
|
|
52
|
+
|
|
53
|
+
release:
|
|
54
|
+
runs-on: ubuntu-latest
|
|
55
|
+
needs: test
|
|
56
|
+
if: startsWith(github.ref, 'refs/tags/')
|
|
57
|
+
permissions:
|
|
58
|
+
# this permission is mandatory for trusted publishing
|
|
59
|
+
id-token: write
|
|
60
|
+
contents: write
|
|
61
|
+
steps:
|
|
62
|
+
- name: Check out repository
|
|
63
|
+
uses: actions/checkout@v4
|
|
64
|
+
|
|
65
|
+
- name: Set up Python
|
|
66
|
+
uses: actions/setup-python@v5
|
|
67
|
+
with:
|
|
68
|
+
python-version: "{{ python_minimum_version }}"
|
|
69
|
+
|
|
70
|
+
- name: Install uv
|
|
71
|
+
uses: astral-sh/setup-uv@v3
|
|
72
|
+
with:
|
|
73
|
+
enable-cache: true
|
|
74
|
+
cache-dependency-glob: pyproject.toml
|
|
75
|
+
cache-suffix: py${{ matrix.python_version }}
|
|
76
|
+
|
|
77
|
+
- name: Build package
|
|
78
|
+
run: uv build
|
|
79
|
+
|
|
80
|
+
- name: Release package on PyPI
|
|
81
|
+
run: uv publish
|
|
82
|
+
|
|
83
|
+
- name: Release package on GitHub
|
|
84
|
+
uses: ncipollo/release-action@v1
|
|
85
|
+
with:
|
|
86
|
+
body: ${{ github.event.head_commit.message }}
|
|
87
|
+
artifacts: dist/*.whl,dist/*.tar.gz
|
|
88
|
+
token: ${{ secrets.GITHUB_TOKEN }}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
name: Build documentation
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- main
|
|
7
|
+
|
|
8
|
+
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
|
|
9
|
+
permissions:
|
|
10
|
+
contents: read
|
|
11
|
+
pages: write
|
|
12
|
+
id-token: write
|
|
13
|
+
|
|
14
|
+
# Allow one concurrent deployment
|
|
15
|
+
concurrency:
|
|
16
|
+
group: "pages"
|
|
17
|
+
cancel-in-progress: true
|
|
18
|
+
|
|
19
|
+
# Default to bash
|
|
20
|
+
defaults:
|
|
21
|
+
run:
|
|
22
|
+
shell: bash
|
|
23
|
+
|
|
24
|
+
jobs:
|
|
25
|
+
build:
|
|
26
|
+
runs-on: ubuntu-latest
|
|
27
|
+
|
|
28
|
+
steps:
|
|
29
|
+
- uses: actions/checkout@v4
|
|
30
|
+
with:
|
|
31
|
+
fetch-depth: 0
|
|
32
|
+
- name: Set up Python
|
|
33
|
+
uses: actions/setup-python@v5
|
|
34
|
+
with:
|
|
35
|
+
python-version: "3.12"
|
|
36
|
+
- name: Install uv
|
|
37
|
+
uses: astral-sh/setup-uv@v3
|
|
38
|
+
- name: Install dependencies
|
|
39
|
+
run: |
|
|
40
|
+
uv sync --all-extras
|
|
41
|
+
- name: Build
|
|
42
|
+
run: uv run mknodes build
|
|
43
|
+
- name: Upload artifact
|
|
44
|
+
uses: actions/upload-pages-artifact@v3
|
|
45
|
+
with:
|
|
46
|
+
path: ./site
|
|
47
|
+
|
|
48
|
+
deploy:
|
|
49
|
+
environment:
|
|
50
|
+
name: github-pages
|
|
51
|
+
url: ${{ steps.deployment.outputs.page_url }}
|
|
52
|
+
runs-on: ubuntu-latest
|
|
53
|
+
needs: build
|
|
54
|
+
steps:
|
|
55
|
+
- name: Deploy to GitHub Pages
|
|
56
|
+
id: deployment
|
|
57
|
+
uses: actions/deploy-pages@v4
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
# Distribution / packaging
|
|
5
|
+
*.sublime-workspace
|
|
6
|
+
# Unit test / coverage reports
|
|
7
|
+
.coverage
|
|
8
|
+
coverage.xml
|
|
9
|
+
.cache
|
|
10
|
+
.hatch
|
|
11
|
+
.pytest_cache/
|
|
12
|
+
junit.xml
|
|
13
|
+
# Jupyter Notebook
|
|
14
|
+
.ipynb_checkpoints
|
|
15
|
+
# pyenv
|
|
16
|
+
.python-version
|
|
17
|
+
# dotenv
|
|
18
|
+
.env
|
|
19
|
+
# virtualenv
|
|
20
|
+
.venv
|
|
21
|
+
# mkdocs documentation
|
|
22
|
+
/site
|
|
23
|
+
# mypy
|
|
24
|
+
.mypy_cache/
|
|
25
|
+
# .vscode
|
|
26
|
+
.vscode/
|
|
27
|
+
# OS files
|
|
28
|
+
.DS_Store
|
|
29
|
+
# uv
|
|
30
|
+
uv.lock
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
default_language_version:
|
|
2
|
+
python: python3.12
|
|
3
|
+
default_stages: [pre-commit]
|
|
4
|
+
repos:
|
|
5
|
+
- repo: local
|
|
6
|
+
hooks:
|
|
7
|
+
- id: pytest-check
|
|
8
|
+
name: pytest-check
|
|
9
|
+
entry: uv run pytest
|
|
10
|
+
language: system
|
|
11
|
+
# stages: [push]
|
|
12
|
+
types: [python]
|
|
13
|
+
pass_filenames: false
|
|
14
|
+
always_run: true
|
|
15
|
+
|
|
16
|
+
- repo: https://github.com/pre-commit/pre-commit-hooks
|
|
17
|
+
# https://pre-commit.com/hooks.html
|
|
18
|
+
rev: v5.0.0
|
|
19
|
+
hooks:
|
|
20
|
+
- id: check-added-large-files
|
|
21
|
+
- id: check-case-conflict
|
|
22
|
+
- id: check-merge-conflict
|
|
23
|
+
- id: check-toml
|
|
24
|
+
- id: check-json
|
|
25
|
+
- id: check-xml
|
|
26
|
+
- id: check-yaml
|
|
27
|
+
args: [--allow-multiple-documents, --unsafe]
|
|
28
|
+
- id: debug-statements
|
|
29
|
+
- id: detect-private-key
|
|
30
|
+
|
|
31
|
+
- repo: https://github.com/pre-commit/mirrors-mypy
|
|
32
|
+
rev: v1.13.0
|
|
33
|
+
hooks:
|
|
34
|
+
- id: mypy
|
|
35
|
+
additional_dependencies: [orjson]
|
|
36
|
+
|
|
37
|
+
- repo: https://github.com/charliermarsh/ruff-pre-commit
|
|
38
|
+
rev: v0.7.2
|
|
39
|
+
hooks:
|
|
40
|
+
- id: ruff
|
|
41
|
+
- id: ruff-format
|
|
42
|
+
|
|
43
|
+
- repo: https://github.com/commitizen-tools/commitizen
|
|
44
|
+
rev: v3.30.0
|
|
45
|
+
hooks:
|
|
46
|
+
- id: commitizen
|
|
47
|
+
stages: [commit-msg]
|
|
48
|
+
additional_dependencies: [typing-extensions]
|
epregistry-0.0.1/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024, Philipp Temminghoff
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
|
+
Name: epregistry
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: A registry for entry points (cached and generically typed)
|
|
5
|
+
Project-URL: Documentation, https://phil65.github.io/epregistry/
|
|
6
|
+
Project-URL: Source, https://github.com/phil65/epregistry
|
|
7
|
+
Author-email: Philipp Temminghoff <philipptemminghoff@googlemail.com>
|
|
8
|
+
License-Expression: MIT
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Classifier: Development Status :: 4 - Beta
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: Operating System :: OS Independent
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
18
|
+
Classifier: Topic :: Documentation
|
|
19
|
+
Classifier: Topic :: Software Development
|
|
20
|
+
Classifier: Topic :: Utilities
|
|
21
|
+
Classifier: Typing :: Typed
|
|
22
|
+
Requires-Python: >=3.12
|
|
23
|
+
Description-Content-Type: text/markdown
|
|
24
|
+
|
|
25
|
+
# epregistry
|
|
26
|
+
|
|
27
|
+
[](https://pypi.org/project/epregistry/)
|
|
28
|
+
[](https://pypi.org/project/epregistry/)
|
|
29
|
+
[](https://pypi.org/project/epregistry/)
|
|
30
|
+
[](https://pypi.org/project/epregistry/)
|
|
31
|
+
[](https://pypi.org/project/epregistry/)
|
|
32
|
+
[](https://pypi.org/project/epregistry/)
|
|
33
|
+
[](https://pypi.org/project/epregistry/)
|
|
34
|
+
[](https://pypi.org/project/epregistry/)
|
|
35
|
+
[](https://pypi.org/project/epregistry/)
|
|
36
|
+
[](https://github.com/phil65/epregistry/releases)
|
|
37
|
+
[](https://github.com/phil65/epregistry/graphs/contributors)
|
|
38
|
+
[](https://github.com/phil65/epregistry/discussions)
|
|
39
|
+
[](https://github.com/phil65/epregistry/forks)
|
|
40
|
+
[](https://github.com/phil65/epregistry/issues)
|
|
41
|
+
[](https://github.com/phil65/epregistry/pulls)
|
|
42
|
+
[](https://github.com/phil65/epregistry/watchers)
|
|
43
|
+
[](https://github.com/phil65/epregistry/stars)
|
|
44
|
+
[](https://github.com/phil65/epregistry)
|
|
45
|
+
[](https://github.com/phil65/epregistry/commits)
|
|
46
|
+
[](https://github.com/phil65/epregistry/releases)
|
|
47
|
+
[](https://github.com/phil65/epregistry)
|
|
48
|
+
[](https://github.com/phil65/epregistry)
|
|
49
|
+
[](https://github.com/phil65/epregistry)
|
|
50
|
+
[](https://github.com/phil65/epregistry)
|
|
51
|
+
[](https://codecov.io/gh/phil65/epregistry/)
|
|
52
|
+
[](https://github.com/psf/black)
|
|
53
|
+
[](https://pyup.io/repos/github/phil65/epregistry/)
|
|
54
|
+
|
|
55
|
+
[Read the documentation!](https://phil65.github.io/epregistry/)
|
|
56
|
+
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# epregistry
|
|
2
|
+
|
|
3
|
+
[](https://pypi.org/project/epregistry/)
|
|
4
|
+
[](https://pypi.org/project/epregistry/)
|
|
5
|
+
[](https://pypi.org/project/epregistry/)
|
|
6
|
+
[](https://pypi.org/project/epregistry/)
|
|
7
|
+
[](https://pypi.org/project/epregistry/)
|
|
8
|
+
[](https://pypi.org/project/epregistry/)
|
|
9
|
+
[](https://pypi.org/project/epregistry/)
|
|
10
|
+
[](https://pypi.org/project/epregistry/)
|
|
11
|
+
[](https://pypi.org/project/epregistry/)
|
|
12
|
+
[](https://github.com/phil65/epregistry/releases)
|
|
13
|
+
[](https://github.com/phil65/epregistry/graphs/contributors)
|
|
14
|
+
[](https://github.com/phil65/epregistry/discussions)
|
|
15
|
+
[](https://github.com/phil65/epregistry/forks)
|
|
16
|
+
[](https://github.com/phil65/epregistry/issues)
|
|
17
|
+
[](https://github.com/phil65/epregistry/pulls)
|
|
18
|
+
[](https://github.com/phil65/epregistry/watchers)
|
|
19
|
+
[](https://github.com/phil65/epregistry/stars)
|
|
20
|
+
[](https://github.com/phil65/epregistry)
|
|
21
|
+
[](https://github.com/phil65/epregistry/commits)
|
|
22
|
+
[](https://github.com/phil65/epregistry/releases)
|
|
23
|
+
[](https://github.com/phil65/epregistry)
|
|
24
|
+
[](https://github.com/phil65/epregistry)
|
|
25
|
+
[](https://github.com/phil65/epregistry)
|
|
26
|
+
[](https://github.com/phil65/epregistry)
|
|
27
|
+
[](https://codecov.io/gh/phil65/epregistry/)
|
|
28
|
+
[](https://github.com/psf/black)
|
|
29
|
+
[](https://pyup.io/repos/github/phil65/epregistry/)
|
|
30
|
+
|
|
31
|
+
[Read the documentation!](https://phil65.github.io/epregistry/)
|
|
32
|
+
|
|
File without changes
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from duty import duty
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
@duty(capture=False)
|
|
7
|
+
def build(ctx, *args: str):
|
|
8
|
+
"""Build a MkNodes page."""
|
|
9
|
+
args_str = " " + " ".join(args) if args else ""
|
|
10
|
+
ctx.run(f"uv run mknodes build{args_str}")
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
@duty(capture=False)
|
|
14
|
+
def serve(ctx, *args: str):
|
|
15
|
+
"""Serve a MkNodes page."""
|
|
16
|
+
args_str = " " + " ".join(args) if args else ""
|
|
17
|
+
ctx.run(f"uv run mknodes serve{args_str}")
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
@duty(capture=False)
|
|
21
|
+
def test(ctx, *args: str):
|
|
22
|
+
"""Serve a MkNodes page."""
|
|
23
|
+
args_str = " " + " ".join(args) if args else ""
|
|
24
|
+
ctx.run(f"uv run pytest{args_str}")
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
@duty(capture=False)
|
|
28
|
+
def clean(ctx):
|
|
29
|
+
"""Clean all files from the Git directory except checked-in files."""
|
|
30
|
+
ctx.run("git clean -dfX")
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
@duty(capture=False)
|
|
34
|
+
def update(ctx):
|
|
35
|
+
"""Update all environment packages using pip directly."""
|
|
36
|
+
ctx.run("uv lock --upgrade")
|
|
37
|
+
ctx.run("uv sync --all-extras")
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
@duty(capture=False)
|
|
41
|
+
def lint(ctx):
|
|
42
|
+
"""Lint the code and fix issues if possible."""
|
|
43
|
+
ctx.run("uv run ruff check --fix .")
|
|
44
|
+
ctx.run("uv run ruff format .")
|
|
45
|
+
ctx.run("uv run mypy src/epregistry/")
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
@duty(capture=False)
|
|
49
|
+
def lint_check(ctx):
|
|
50
|
+
"""Lint the code."""
|
|
51
|
+
ctx.run("uv run ruff check .")
|
|
52
|
+
ctx.run("uv run ruff format --check .")
|
|
53
|
+
ctx.run("uv run mypy src/epregistry/")
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
@duty(capture=False)
|
|
57
|
+
def version(ctx, *args: str):
|
|
58
|
+
"""Bump package version."""
|
|
59
|
+
args_str = " " + " ".join(args) if args else ""
|
|
60
|
+
ctx.run(f"hatch version{args_str}")
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
site_name: "epregistry"
|
|
2
|
+
site_description: "A registry for entry points (cached and generically typed)"
|
|
3
|
+
repo_url: "https://github.com/phil65/epregistry/"
|
|
4
|
+
site_url: https://phil65.github.io/epregistry/
|
|
5
|
+
site_author: "Philipp Temminghoff"
|
|
6
|
+
copyright: Copyright © 2024 Philipp Temminghoff
|
|
7
|
+
|
|
8
|
+
theme:
|
|
9
|
+
name: material
|
|
10
|
+
custom_dir: overrides
|
|
11
|
+
icon:
|
|
12
|
+
logo: material/graph-outline
|
|
13
|
+
palette:
|
|
14
|
+
# Palette toggle for automatic mode
|
|
15
|
+
- media: "(prefers-color-scheme)"
|
|
16
|
+
toggle:
|
|
17
|
+
icon: material/brightness-auto
|
|
18
|
+
name: Switch to light mode
|
|
19
|
+
|
|
20
|
+
# Palette toggle for light mode
|
|
21
|
+
- media: "(prefers-color-scheme: light)"
|
|
22
|
+
scheme: default
|
|
23
|
+
primary: red
|
|
24
|
+
toggle:
|
|
25
|
+
icon: material/brightness-7
|
|
26
|
+
name: Switch to dark mode
|
|
27
|
+
|
|
28
|
+
# Palette toggle for dark mode
|
|
29
|
+
- media: "(prefers-color-scheme: dark)"
|
|
30
|
+
scheme: slate
|
|
31
|
+
primary: red
|
|
32
|
+
toggle:
|
|
33
|
+
icon: material/brightness-4
|
|
34
|
+
name: Switch to system preference
|
|
35
|
+
features:
|
|
36
|
+
- announce.dismiss
|
|
37
|
+
- content.action.edit
|
|
38
|
+
- content.code.copy
|
|
39
|
+
- content.code.select
|
|
40
|
+
- content.code.annotate
|
|
41
|
+
- content.tooltips
|
|
42
|
+
# - content.tabs.link
|
|
43
|
+
- navigation.tracking # update URL based on current item in TOC
|
|
44
|
+
- navigation.path # shows breadcrumbs
|
|
45
|
+
- navigation.tabs # make top level tabs
|
|
46
|
+
- navigation.indexes # documents can be directly attached to sections (overview pages)
|
|
47
|
+
- navigation.footer # next/previous page buttons in footer
|
|
48
|
+
- navigation.top # adds back-to-top button
|
|
49
|
+
# - navigation.sections # top-level sections are rendered as groups
|
|
50
|
+
# - navigation.expand # expand all subsections in left sidebar by default
|
|
51
|
+
- toc.follow # makes toc follow scrolling
|
|
52
|
+
# - toc.integrate # integrates toc into left menu
|
|
53
|
+
- search.highlight
|
|
54
|
+
- search.suggest
|
|
55
|
+
# - search.share
|
|
56
|
+
|
|
57
|
+
plugins:
|
|
58
|
+
- search
|
|
59
|
+
- autorefs
|
|
60
|
+
- mknodes
|
|
61
|
+
- mkdocstrings:
|
|
62
|
+
default_handler: python
|
|
63
|
+
handlers:
|
|
64
|
+
python:
|
|
65
|
+
import:
|
|
66
|
+
- url: https://docs.python.org/3/objects.inv
|
|
67
|
+
domains: [std, py]
|
|
68
|
+
options:
|
|
69
|
+
# https://mkdocstrings.github.io/python/usage/
|
|
70
|
+
enable_inventory: !ENV [CI, false]
|
|
71
|
+
show_signature_annotations: true
|
|
72
|
+
show_symbol_type_toc: true
|
|
73
|
+
show_symbol_type_heading: true
|
|
74
|
+
show_root_toc_entry: false
|
|
75
|
+
# merge_init_into_class: true
|
|
76
|
+
ignore_init_summary: true
|
|
77
|
+
inherited_members: false
|
|
78
|
+
signature_crossrefs: true
|
|
79
|
+
separate_signature: true
|
|
80
|
+
line_length: 90
|
|
81
|
+
markdown_extensions:
|
|
82
|
+
- attr_list
|
|
83
|
+
- pymdownx.emoji
|
|
84
|
+
- toc:
|
|
85
|
+
permalink: true
|
|
86
|
+
|
|
87
|
+
extra:
|
|
88
|
+
social:
|
|
89
|
+
- icon: fontawesome/brands/github
|
|
90
|
+
link: https://github.com/phil65
|
|
91
|
+
- icon: fontawesome/brands/python
|
|
92
|
+
link: https://pypi.org/project/epregistry/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
File exists to make sure that folder exists for git
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
[tool.hatch.version]
|
|
2
|
+
source = "regex_commit"
|
|
3
|
+
commit_extra_args = ["-e"]
|
|
4
|
+
path = "src/epregistry/__init__.py"
|
|
5
|
+
|
|
6
|
+
[build-system]
|
|
7
|
+
requires = ["hatchling", "hatch-regex-commit"]
|
|
8
|
+
build-backend = "hatchling.build"
|
|
9
|
+
|
|
10
|
+
[project]
|
|
11
|
+
name = "epregistry"
|
|
12
|
+
description = "A registry for entry points (cached and generically typed)"
|
|
13
|
+
authors = [{name = "Philipp Temminghoff", email = "philipptemminghoff@googlemail.com"}]
|
|
14
|
+
readme = "README.md"
|
|
15
|
+
dynamic = ["version"]
|
|
16
|
+
classifiers = [
|
|
17
|
+
"Development Status :: 4 - Beta",
|
|
18
|
+
"Intended Audience :: Developers",
|
|
19
|
+
"Operating System :: OS Independent",
|
|
20
|
+
"Programming Language :: Python :: 3",
|
|
21
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
22
|
+
"Programming Language :: Python :: 3.12",
|
|
23
|
+
"Programming Language :: Python :: 3.13",
|
|
24
|
+
"Programming Language :: Python :: 3.14",
|
|
25
|
+
"Topic :: Documentation",
|
|
26
|
+
"Topic :: Software Development",
|
|
27
|
+
"Topic :: Utilities",
|
|
28
|
+
"Typing :: Typed",
|
|
29
|
+
|
|
30
|
+
]
|
|
31
|
+
keywords = []
|
|
32
|
+
requires-python = ">=3.12"
|
|
33
|
+
dependencies = []
|
|
34
|
+
license = "MIT"
|
|
35
|
+
|
|
36
|
+
[tool.uv]
|
|
37
|
+
dev-dependencies = [
|
|
38
|
+
# lint
|
|
39
|
+
"ruff",
|
|
40
|
+
"mypy[faster-cache]",
|
|
41
|
+
# test
|
|
42
|
+
"pytest",
|
|
43
|
+
"pytest-cov",
|
|
44
|
+
# docs
|
|
45
|
+
"mkdocs-material",
|
|
46
|
+
"mkdocs-mknodes",
|
|
47
|
+
# dev
|
|
48
|
+
"pyreadline3",
|
|
49
|
+
"pyinstrument",
|
|
50
|
+
]
|
|
51
|
+
|
|
52
|
+
[project.urls]
|
|
53
|
+
Documentation = "https://phil65.github.io/epregistry/"
|
|
54
|
+
Source = "https://github.com/phil65/epregistry"
|
|
55
|
+
|
|
56
|
+
[tool.pytest.ini_options]
|
|
57
|
+
testpaths = "tests/"
|
|
58
|
+
log_cli = true
|
|
59
|
+
log_format = "%(asctime)s %(levelname)s %(message)s"
|
|
60
|
+
log_date_format = "%Y-%m-%d %H:%M:%S"
|
|
61
|
+
addopts = "--cov=src/epregistry/ --cov-report=term-missing --cov-report=xml"
|
|
62
|
+
|
|
63
|
+
[tool.coverage.report]
|
|
64
|
+
exclude_lines = [
|
|
65
|
+
"pragma: no cover",
|
|
66
|
+
"if TYPE_CHECKING:",
|
|
67
|
+
"@overload",
|
|
68
|
+
"except ImportError",
|
|
69
|
+
'if __name__ == "__main__":',
|
|
70
|
+
]
|
|
71
|
+
|
|
72
|
+
[tool.mypy]
|
|
73
|
+
python_version = "3.12"
|
|
74
|
+
disable_error_code = ["misc", "import"]
|
|
75
|
+
pretty = true
|
|
76
|
+
check_untyped_defs = true
|
|
77
|
+
exclude = ['venv/', '.venv/', 'tests/']
|
|
78
|
+
|
|
79
|
+
[tool.ruff]
|
|
80
|
+
line-length = 90
|
|
81
|
+
extend-exclude = ['docs']
|
|
82
|
+
target-version = "py312"
|
|
83
|
+
|
|
84
|
+
[tool.ruff.lint]
|
|
85
|
+
select = [
|
|
86
|
+
"A", # Flake8-builtins
|
|
87
|
+
# "ANN", # Flake8-Annotations
|
|
88
|
+
# "ASYNC", # Flake8-Async
|
|
89
|
+
# "ARG", # # Flake8-Unused-Arguments
|
|
90
|
+
"B", # flake8-bugbear
|
|
91
|
+
"BLE", # Flake8-blind-except
|
|
92
|
+
"C",
|
|
93
|
+
"C4", # flake8-comprehensions
|
|
94
|
+
# "C90", # MCCabe
|
|
95
|
+
"COM", # Flake8-commas
|
|
96
|
+
# "CPY", # Copyright-related rules
|
|
97
|
+
"D", # PyDocStyle
|
|
98
|
+
# "DTZ", # Flake8- Datetimez
|
|
99
|
+
"E", # PyCodeStyle Error
|
|
100
|
+
"EM", # flake8-errmsg
|
|
101
|
+
# "ERA", # Eradicate
|
|
102
|
+
"EXE", # flake8-executable
|
|
103
|
+
"F", # PyFlakes
|
|
104
|
+
"FA", # flake8-future-annotations
|
|
105
|
+
# "FBT", # flake8-boolean-trap
|
|
106
|
+
# "FIX", # flake8-fixme
|
|
107
|
+
"FLY", # flynt
|
|
108
|
+
"G", # flake8-logging-format
|
|
109
|
+
"I", # ISort
|
|
110
|
+
"ICN", # Flake8-import-conventions
|
|
111
|
+
"INP", # flake8-no-pep420
|
|
112
|
+
"INT", # flake8-gettext
|
|
113
|
+
"ISC", # flake8-implicit-str-concat
|
|
114
|
+
"N", # pep8-naming
|
|
115
|
+
# "NPY", # numpy-specific rules
|
|
116
|
+
# "PD", # pandas-vet
|
|
117
|
+
"PERF", # perflint
|
|
118
|
+
# "PGH", # pygrep-hooks
|
|
119
|
+
"PIE", # flake8-pie
|
|
120
|
+
"PLE", # PyLint Error
|
|
121
|
+
"PLC", # PyLint convention
|
|
122
|
+
# "PLW", # PyLint Warning
|
|
123
|
+
"PLR", # PyLint refactor
|
|
124
|
+
"PT", # flake8-pytest-style
|
|
125
|
+
"PTH", # flake8-use-pathlib
|
|
126
|
+
"PYI", # flake8-pyi
|
|
127
|
+
"Q", # flake8-quotes
|
|
128
|
+
"RET", # flake8-return
|
|
129
|
+
"RSE", # flake8-raise
|
|
130
|
+
"RUF", # ruff-specific rules
|
|
131
|
+
# "S", # flake8-bandit
|
|
132
|
+
"SIM", # flake8-simplify
|
|
133
|
+
"SLF", # flake8-self
|
|
134
|
+
"SLOT", # flake8-slots
|
|
135
|
+
# "T",
|
|
136
|
+
# "TD", # flake8-todos
|
|
137
|
+
"T10", # flake8-debugger
|
|
138
|
+
# "T20", # flake8-print
|
|
139
|
+
"TCH", # flake8-type-checking
|
|
140
|
+
"TID", # flake8-tidy-imports
|
|
141
|
+
"TRY", # tryceratops
|
|
142
|
+
"UP", # PyUpgrade
|
|
143
|
+
"W", # PyCodeStyle warning
|
|
144
|
+
"YTT", # flake8-2020
|
|
145
|
+
]
|
|
146
|
+
ignore = [
|
|
147
|
+
"C408", # Unnecessary {obj_type} call (rewrite as a literal)
|
|
148
|
+
"B905", # zip() without an explicit strict= parameter
|
|
149
|
+
"C901", # {name} is too complex ({complexity} > {max_complexity})
|
|
150
|
+
"COM812",
|
|
151
|
+
# "CPY001", # Missing copyright notice at top of file
|
|
152
|
+
"D100", # Missing docstring in public module
|
|
153
|
+
"D101", # Missing docstring in public class
|
|
154
|
+
"D102", # Missing docstring in public method
|
|
155
|
+
"D103", # Missing docstring in public function
|
|
156
|
+
"D104", # Missing docstring in public package
|
|
157
|
+
"D105", # Missing docstring in magic method
|
|
158
|
+
"D106", # Missing docstring in public nested class
|
|
159
|
+
"D107", # Missing docstring in __init__
|
|
160
|
+
"D203", # 1 blank line required before class docstring
|
|
161
|
+
"D204", # 1 blank line required after class docstring
|
|
162
|
+
"D213", # Multi-line docstring summary should start at the second line
|
|
163
|
+
"D215", # Section underline is over-indented ("{name}")
|
|
164
|
+
"D400", # First line should end with a period
|
|
165
|
+
"D401", # First line of docstring should be in imperative mood: "{first_line}"
|
|
166
|
+
"D404", # First word of the docstring should not be "This"
|
|
167
|
+
"D406", # Section name should end with a newline ("{name}")
|
|
168
|
+
"D407", # Missing dashed underline after section ("{name}")
|
|
169
|
+
"D408", # Section underline should be in the line following the section's name ("{name}")
|
|
170
|
+
"D409", # Section underline should match the length of its name ("{name}")
|
|
171
|
+
"D413", # Missing blank line after last section ("{name}")
|
|
172
|
+
"ISC001",
|
|
173
|
+
"PLR0912", # Too many branches
|
|
174
|
+
"PLR0913", # Too many arguments to function call
|
|
175
|
+
"PLR0915", # Too many statements
|
|
176
|
+
# "PLR2004", # Magic values instead of named consts
|
|
177
|
+
"SLF001", # Private member accessed
|
|
178
|
+
"TRY003", # Avoid specifying long messages outside the exception class
|
|
179
|
+
]
|
|
180
|
+
|
|
181
|
+
[tool.ruff.lint.flake8-quotes]
|
|
182
|
+
docstring-quotes = "double"
|
|
183
|
+
|
|
184
|
+
[tool.ruff.format]
|
|
185
|
+
# Enable preview style formatting.
|
|
186
|
+
preview = true
|
|
187
|
+
|
|
188
|
+
[tool.ruff.lint.isort]
|
|
189
|
+
lines-after-imports = 2
|
|
190
|
+
# lines-between-types = 1
|
|
191
|
+
# atomic = true
|
|
192
|
+
force-sort-within-sections = true
|
|
193
|
+
combine-as-imports = true
|
|
194
|
+
|
|
195
|
+
[tool.ruff.lint.per-file-ignores]
|
|
196
|
+
"__init__.py" = ["E402", "I001"]
|
|
197
|
+
|
|
198
|
+
[tool.pyright]
|
|
199
|
+
pythonVersion = "3.12"
|
|
200
|
+
pythonPlatform = "All"
|
|
201
|
+
deprecateTypingAliases = true
|
|
202
|
+
reportMissingTypeStubs = false
|
|
203
|
+
reportUnusedCallResult = false
|
|
204
|
+
reportUnknownVariableType = false
|
|
205
|
+
reportAny = false
|
|
206
|
+
reportImplicitOverride = false
|
|
207
|
+
reportUnusedFunction = false
|
|
208
|
+
reportImplicitStringConcatenation = false
|
|
209
|
+
|
|
210
|
+
[tool.mknodes]
|
|
211
|
+
allowed-commit-types = [
|
|
212
|
+
"fix",
|
|
213
|
+
"feat",
|
|
214
|
+
"refactor",
|
|
215
|
+
"docs",
|
|
216
|
+
"test",
|
|
217
|
+
"build",
|
|
218
|
+
"chore",
|
|
219
|
+
]
|
|
220
|
+
docstring-style = "google"
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
"""Module for managing entry points through a registry system."""
|
|
2
|
+
|
|
3
|
+
from collections import defaultdict
|
|
4
|
+
from collections.abc import Callable, Iterator
|
|
5
|
+
from functools import cache
|
|
6
|
+
from importlib.metadata import EntryPoint, entry_points
|
|
7
|
+
from typing import Any, Generic, TypeVar
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
T = TypeVar("T")
|
|
11
|
+
|
|
12
|
+
# Global cache for ALL entry points across all groups
|
|
13
|
+
_entry_point_cache: dict[str, dict[str, EntryPoint]] | None = None
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
@cache
|
|
17
|
+
def _initialize_cache() -> dict[str, dict[str, EntryPoint]]:
|
|
18
|
+
"""Initialize the global cache with ALL entry points.
|
|
19
|
+
|
|
20
|
+
Returns:
|
|
21
|
+
dict: A nested dictionary mapping group names to their entry points.
|
|
22
|
+
Structure: {group_name: {entry_point_name: entry_point}}
|
|
23
|
+
"""
|
|
24
|
+
all_entry_points: defaultdict[str, dict[str, Any]] = defaultdict(dict)
|
|
25
|
+
for ep in entry_points():
|
|
26
|
+
all_entry_points[ep.group][ep.name] = ep
|
|
27
|
+
return dict(all_entry_points)
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class EntryPointRegistry(Generic[T]):
|
|
31
|
+
"""A registry for managing and accessing entry points of a specific group.
|
|
32
|
+
|
|
33
|
+
This class provides a convenient interface to work with entry points from a specified
|
|
34
|
+
group. It handles caching and provides various methods to access / load entry points.
|
|
35
|
+
|
|
36
|
+
Args:
|
|
37
|
+
group: The entry point group to manage.
|
|
38
|
+
|
|
39
|
+
Attributes:
|
|
40
|
+
group: The name of the entry point group being managed.
|
|
41
|
+
"""
|
|
42
|
+
|
|
43
|
+
def __init__(self, group: str):
|
|
44
|
+
"""Initialize the registry for a specific entry point group.
|
|
45
|
+
|
|
46
|
+
Args:
|
|
47
|
+
group: The entry point group to manage.
|
|
48
|
+
"""
|
|
49
|
+
self.group = group
|
|
50
|
+
# Ensure the group exists in the cache
|
|
51
|
+
if self.group not in self._get_cache():
|
|
52
|
+
self._get_cache()[self.group] = {}
|
|
53
|
+
|
|
54
|
+
@staticmethod
|
|
55
|
+
def _get_cache() -> dict[str, dict[str, EntryPoint]]:
|
|
56
|
+
"""Get or initialize the global entry point cache.
|
|
57
|
+
|
|
58
|
+
Returns:
|
|
59
|
+
dict: The global cache of entry points.
|
|
60
|
+
"""
|
|
61
|
+
global _entry_point_cache
|
|
62
|
+
if _entry_point_cache is None:
|
|
63
|
+
_entry_point_cache = _initialize_cache()
|
|
64
|
+
return _entry_point_cache
|
|
65
|
+
|
|
66
|
+
def get(self, name: str) -> EntryPoint | None:
|
|
67
|
+
"""Get an entry point by name.
|
|
68
|
+
|
|
69
|
+
Args:
|
|
70
|
+
name: The name of the entry point.
|
|
71
|
+
|
|
72
|
+
Returns:
|
|
73
|
+
The entry point if found, None otherwise.
|
|
74
|
+
"""
|
|
75
|
+
return self._get_cache()[self.group].get(name)
|
|
76
|
+
|
|
77
|
+
def load(self, name: str) -> T | None:
|
|
78
|
+
"""Load an entry point by name.
|
|
79
|
+
|
|
80
|
+
Args:
|
|
81
|
+
name: The name of the entry point to load.
|
|
82
|
+
|
|
83
|
+
Returns:
|
|
84
|
+
The loaded entry point if found, None otherwise.
|
|
85
|
+
"""
|
|
86
|
+
entry_point = self.get(name)
|
|
87
|
+
return entry_point.load() if entry_point is not None else None
|
|
88
|
+
|
|
89
|
+
def __getitem__(self, name: str) -> EntryPoint:
|
|
90
|
+
"""Get an entry point by name.
|
|
91
|
+
|
|
92
|
+
Args:
|
|
93
|
+
name: The name of the entry point.
|
|
94
|
+
|
|
95
|
+
Returns:
|
|
96
|
+
The requested entry point.
|
|
97
|
+
|
|
98
|
+
Raises:
|
|
99
|
+
KeyError: If the entry point is not found.
|
|
100
|
+
"""
|
|
101
|
+
try:
|
|
102
|
+
return self._get_cache()[self.group][name]
|
|
103
|
+
except KeyError as e:
|
|
104
|
+
msg = f"No entry point named {name!r} found in group {self.group!r}"
|
|
105
|
+
raise KeyError(msg) from e
|
|
106
|
+
|
|
107
|
+
def __iter__(self) -> Iterator[str]:
|
|
108
|
+
"""Iterate over entry point names.
|
|
109
|
+
|
|
110
|
+
Returns:
|
|
111
|
+
Iterator of entry point names.
|
|
112
|
+
"""
|
|
113
|
+
return iter(self._get_cache()[self.group])
|
|
114
|
+
|
|
115
|
+
def __len__(self) -> int:
|
|
116
|
+
"""Get the number of available entry points.
|
|
117
|
+
|
|
118
|
+
Returns:
|
|
119
|
+
The number of entry points in this registry.
|
|
120
|
+
"""
|
|
121
|
+
return len(self._get_cache()[self.group])
|
|
122
|
+
|
|
123
|
+
def __contains__(self, name: str) -> bool:
|
|
124
|
+
"""Check if an entry point name exists.
|
|
125
|
+
|
|
126
|
+
Args:
|
|
127
|
+
name: The name to check.
|
|
128
|
+
|
|
129
|
+
Returns:
|
|
130
|
+
True if the entry point exists, False otherwise.
|
|
131
|
+
"""
|
|
132
|
+
return name in self._get_cache()[self.group]
|
|
133
|
+
|
|
134
|
+
def names(self) -> list[str]:
|
|
135
|
+
"""Get a list of all available entry point names.
|
|
136
|
+
|
|
137
|
+
Returns:
|
|
138
|
+
List of entry point names.
|
|
139
|
+
"""
|
|
140
|
+
return list(self._get_cache()[self.group].keys())
|
|
141
|
+
|
|
142
|
+
def get_all(self) -> dict[str, EntryPoint]:
|
|
143
|
+
"""Get all entry points as a dictionary.
|
|
144
|
+
|
|
145
|
+
Returns:
|
|
146
|
+
Dictionary mapping entry point names to entry points.
|
|
147
|
+
"""
|
|
148
|
+
return self._get_cache()[self.group]
|
|
149
|
+
|
|
150
|
+
def load_all(self) -> dict[str, T]:
|
|
151
|
+
"""Load all entry points.
|
|
152
|
+
|
|
153
|
+
Returns:
|
|
154
|
+
Dictionary mapping entry point names to loaded entry points.
|
|
155
|
+
"""
|
|
156
|
+
return {name: ep.load() for name, ep in self.get_all().items()}
|
|
157
|
+
|
|
158
|
+
def get_metadata(self, name: str) -> dict[str, Any]:
|
|
159
|
+
"""Get detailed metadata for an entry point."""
|
|
160
|
+
ep = self.get(name)
|
|
161
|
+
if not ep:
|
|
162
|
+
msg = f"No entry point named '{name}' found in group '{self.group}'"
|
|
163
|
+
raise ValueError(msg)
|
|
164
|
+
return {
|
|
165
|
+
"module": ep.module,
|
|
166
|
+
"attr": ep.attr,
|
|
167
|
+
"dist": ep.dist.metadata["Name"] if ep.dist else None,
|
|
168
|
+
"version": ep.dist.version if ep.dist else None,
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
def available_groups() -> list[str]:
|
|
173
|
+
"""Get a list of all available entry point groups.
|
|
174
|
+
|
|
175
|
+
Returns:
|
|
176
|
+
List of entry point group names.
|
|
177
|
+
"""
|
|
178
|
+
return list(EntryPointRegistry._get_cache().keys())
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
if __name__ == "__main__":
|
|
182
|
+
# Create a registry for console scripts
|
|
183
|
+
registry = EntryPointRegistry[Callable]("console_scripts")
|
|
184
|
+
|
|
185
|
+
# Print available console scripts
|
|
186
|
+
print("Available console scripts:")
|
|
187
|
+
for name in registry.names():
|
|
188
|
+
print(f"- {name}")
|
|
189
|
+
|
|
190
|
+
print(f"\nTotal scripts: {len(registry)}")
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
from collections.abc import Callable
|
|
2
|
+
from typing import Any
|
|
3
|
+
|
|
4
|
+
import pytest
|
|
5
|
+
|
|
6
|
+
from epregistry.epregistry import EntryPointRegistry, available_groups
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
# Constants for testing
|
|
10
|
+
CONSOLE_SCRIPTS = "console_scripts" # This group exists in most Python installations
|
|
11
|
+
NONEXISTENT_GROUP = "nonexistent.group"
|
|
12
|
+
NONEXISTENT_NAME = "nonexistent.name"
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
@pytest.fixture
|
|
16
|
+
def registry() -> EntryPointRegistry[Callable[..., Any]]:
|
|
17
|
+
"""Create a registry using console_scripts group."""
|
|
18
|
+
return EntryPointRegistry[Callable[..., Any]](CONSOLE_SCRIPTS)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def test_registry_initialization():
|
|
22
|
+
"""Test basic registry initialization."""
|
|
23
|
+
registry = EntryPointRegistry[Any](CONSOLE_SCRIPTS)
|
|
24
|
+
assert registry.group == CONSOLE_SCRIPTS
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def test_registry_get_nonexistent_entry_point(
|
|
28
|
+
registry: EntryPointRegistry[Callable[..., Any]],
|
|
29
|
+
):
|
|
30
|
+
"""Test getting a nonexistent entry point."""
|
|
31
|
+
entry_point = registry.get(NONEXISTENT_NAME)
|
|
32
|
+
assert entry_point is None
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def test_registry_getitem_nonexistent(registry: EntryPointRegistry[Callable[..., Any]]):
|
|
36
|
+
"""Test __getitem__ with nonexistent entry point."""
|
|
37
|
+
with pytest.raises(KeyError):
|
|
38
|
+
_ = registry[NONEXISTENT_NAME]
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def test_registry_iteration(registry: EntryPointRegistry[Callable[..., Any]]):
|
|
42
|
+
"""Test iteration over registry."""
|
|
43
|
+
names = list(registry)
|
|
44
|
+
assert isinstance(names, list)
|
|
45
|
+
# At least one entry point should exist in console_scripts
|
|
46
|
+
assert len(names) > 0
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def test_registry_length(registry: EntryPointRegistry[Callable[..., Any]]):
|
|
50
|
+
"""Test len() operation on registry."""
|
|
51
|
+
# Should have at least one console script
|
|
52
|
+
assert len(registry) > 0
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def test_registry_contains(registry: EntryPointRegistry[Callable[..., Any]]):
|
|
56
|
+
"""Test contains operation on registry."""
|
|
57
|
+
assert NONEXISTENT_NAME not in registry
|
|
58
|
+
# Get first available name and test it
|
|
59
|
+
if len(registry) > 0:
|
|
60
|
+
first_name = next(iter(registry))
|
|
61
|
+
assert first_name in registry
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def test_registry_names(registry: EntryPointRegistry[Callable[..., Any]]):
|
|
65
|
+
"""Test getting list of entry point names."""
|
|
66
|
+
names = registry.names()
|
|
67
|
+
assert isinstance(names, list)
|
|
68
|
+
assert len(names) > 0
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def test_registry_get_all(registry: EntryPointRegistry[Callable[..., Any]]):
|
|
72
|
+
"""Test getting all entry points."""
|
|
73
|
+
all_entry_points = registry.get_all()
|
|
74
|
+
assert isinstance(all_entry_points, dict)
|
|
75
|
+
assert len(all_entry_points) > 0
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
def test_registry_empty_group():
|
|
79
|
+
"""Test registry with empty group."""
|
|
80
|
+
registry = EntryPointRegistry[Any](NONEXISTENT_GROUP)
|
|
81
|
+
assert len(registry) == 0
|
|
82
|
+
assert registry.names() == []
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
def test_available_groups():
|
|
86
|
+
"""Test getting available groups."""
|
|
87
|
+
groups = available_groups()
|
|
88
|
+
assert isinstance(groups, list)
|
|
89
|
+
assert CONSOLE_SCRIPTS in groups
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
def test_get_metadata(registry: EntryPointRegistry[Callable[..., Any]]):
|
|
93
|
+
"""Test getting entry point metadata."""
|
|
94
|
+
if len(registry) > 0:
|
|
95
|
+
name = next(iter(registry))
|
|
96
|
+
metadata = registry.get_metadata(name)
|
|
97
|
+
assert isinstance(metadata, dict)
|
|
98
|
+
assert "module" in metadata
|
|
99
|
+
assert "attr" in metadata
|
|
100
|
+
assert "dist" in metadata
|
|
101
|
+
assert "version" in metadata
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
def test_get_metadata_nonexistent(registry: EntryPointRegistry[Callable[..., Any]]):
|
|
105
|
+
"""Test getting metadata for nonexistent entry point."""
|
|
106
|
+
with pytest.raises(ValueError, match="No entry point named*"):
|
|
107
|
+
registry.get_metadata(NONEXISTENT_NAME)
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
def test_generic_typing():
|
|
111
|
+
"""Test generic typing functionality."""
|
|
112
|
+
registry = EntryPointRegistry[Callable[..., Any]](CONSOLE_SCRIPTS)
|
|
113
|
+
assert isinstance(registry, EntryPointRegistry)
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
def test_load_missing_entry_point(registry: EntryPointRegistry[Callable[..., Any]]):
|
|
117
|
+
"""Test loading a nonexistent entry point."""
|
|
118
|
+
result = registry.load(NONEXISTENT_NAME)
|
|
119
|
+
assert result is None
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
@pytest.mark.parametrize(
|
|
123
|
+
("group", "expected_type"),
|
|
124
|
+
[
|
|
125
|
+
(CONSOLE_SCRIPTS, EntryPointRegistry[Callable[..., Any]]),
|
|
126
|
+
("pytest11", EntryPointRegistry[Any]), # pytest plugins group
|
|
127
|
+
],
|
|
128
|
+
)
|
|
129
|
+
def test_registry_type_parameters(group: str, expected_type: type):
|
|
130
|
+
"""Test registry with different type parameters."""
|
|
131
|
+
registry = expected_type(group)
|
|
132
|
+
assert isinstance(registry, EntryPointRegistry)
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
def test_load_all_empty_group():
|
|
136
|
+
"""Test load_all() with empty group."""
|
|
137
|
+
registry = EntryPointRegistry[Any](NONEXISTENT_GROUP)
|
|
138
|
+
assert registry.load_all() == {}
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
def test_multiple_registries_same_cache():
|
|
142
|
+
"""Test that multiple registries share the same cache."""
|
|
143
|
+
registry1 = EntryPointRegistry[Any](CONSOLE_SCRIPTS)
|
|
144
|
+
registry2 = EntryPointRegistry[Any](CONSOLE_SCRIPTS)
|
|
145
|
+
assert registry1._get_cache() is registry2._get_cache()
|