├── tests ├── __init__.py ├── test_typing.yml └── test_wraps.py ├── src └── tightwrap │ ├── py.typed │ ├── __init__.py │ └── _backported.py ├── Justfile ├── tox.ini ├── pyproject.toml ├── .github └── workflows │ ├── pypi-package.yml │ └── main.yml ├── README.md ├── .gitignore └── LICENSE /tests/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/tightwrap/py.typed: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Justfile: -------------------------------------------------------------------------------- 1 | mypy: 2 | uv run mypy src/ tests 3 | 4 | ruff: 5 | uv run ruff check src/ tests 6 | 7 | fmt: 8 | uv run ruff format --check src/ tests 9 | 10 | lint: mypy ruff fmt 11 | 12 | test *args="": 13 | uv run pytest {{args}} 14 | 15 | sync: 16 | uv sync --all-groups 17 | -------------------------------------------------------------------------------- /tests/test_typing.yml: -------------------------------------------------------------------------------- 1 | - case: argument_error 2 | main: | 3 | from tightwrap import wraps 4 | 5 | def inner(a: int) -> int: 6 | return a + 1 7 | 8 | @wraps(inner) 9 | def wrapped(*args, **kwargs) -> int: 10 | return inner(*args, **kwargs) 11 | 12 | wrapped("a string") # E: Argument 1 to "wrapped" has incompatible type "str"; expected "int" [arg-type] -------------------------------------------------------------------------------- /tox.ini: -------------------------------------------------------------------------------- 1 | # Keep docs in sync with docs env and .readthedocs.yml. 2 | [gh-actions] 3 | python = 4 | 3.10: py310 5 | 3.11: py311 6 | 3.12: py312, lint 7 | 3.13: py313 8 | 3.14: py314 9 | 10 | [tox] 11 | envlist = py38, py39, py310, py311, py312, py313, lint 12 | isolated_build = True 13 | 14 | [testenv:lint] 15 | basepython = python3.12 16 | allowlist_externals = 17 | just 18 | uv 19 | commands = 20 | uv sync --all-groups 21 | just lint 22 | 23 | [testenv] 24 | setenv = 25 | PDM_IGNORE_SAVED_PYTHON="1" 26 | COVERAGE_PROCESS_START={toxinidir}/pyproject.toml 27 | commands_pre = 28 | uv sync --all-groups 29 | python -c 'import pathlib; pathlib.Path("{env_site_packages_dir}/cov.pth").write_text("import coverage; coverage.process_startup()")' 30 | commands = 31 | uv run coverage run -m pytest tests {posargs} 32 | allowlist_externals = uv 33 | package = wheel 34 | wheel_build_env = .pkg 35 | -------------------------------------------------------------------------------- /pyproject.toml: -------------------------------------------------------------------------------- 1 | [project] 2 | name = "tightwrap" 3 | description = "A typed `functools.wraps`." 4 | authors = [ 5 | {name = "Tin Tvrtković", email = "tinchester@gmail.com"}, 6 | ] 7 | dependencies = [ 8 | "typing_extensions>=4.0.0; python_version<='3.10'" 9 | ] 10 | requires-python = ">=3.8" 11 | readme = "README.md" 12 | license = {text = "Apache2"} 13 | dynamic = ["version"] 14 | classifiers = [ 15 | "Intended Audience :: Developers", 16 | "Programming Language :: Python :: 3.10", 17 | "Programming Language :: Python :: 3.11", 18 | "Programming Language :: Python :: 3.12", 19 | "Programming Language :: Python :: 3.13", 20 | "Programming Language :: Python :: 3.14", 21 | "Programming Language :: Python :: Implementation :: CPython", 22 | "Typing :: Typed", 23 | ] 24 | 25 | 26 | [build-system] 27 | requires = ["hatchling", "hatch-vcs"] 28 | build-backend = "hatchling.build" 29 | 30 | 31 | [tool.coverage.run] 32 | parallel = true 33 | source_pkgs = ["tightwrap"] 34 | omit = ["_backported.py"] 35 | 36 | 37 | [tool.hatch.version] 38 | source = "vcs" 39 | raw-options = { local_scheme = "no-local-version" } 40 | 41 | 42 | [dependency-groups] 43 | lint = [ 44 | "mypy>=1.8.0", 45 | "ruff>=0.1.11", 46 | ] 47 | test = [ 48 | "pytest>=7.4.4", 49 | "coverage>=7.4.0", 50 | "pytest-mypy-plugins>=3.0.0", 51 | ] 52 | -------------------------------------------------------------------------------- /tests/test_wraps.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | from typing import Any, Callable 4 | 5 | from tightwrap import ( 6 | _get_resolved_signature, # pyright: ignore[reportPrivateUsage] 7 | wraps, 8 | ) 9 | 10 | 11 | def test_wraps() -> None: 12 | """Wraps works.""" 13 | 14 | def wrapped(a: int) -> int: 15 | return a + 1 16 | 17 | @wraps(wrapped) 18 | def wrapper(a: int) -> int: 19 | return wrapped(a) 20 | 21 | assert wrapper(3) == 4 22 | assert _get_resolved_signature(wrapped) == _get_resolved_signature(wrapper) 23 | 24 | _: Callable[[int], int] = wrapper 25 | 26 | 27 | def test_wraps_different_return() -> None: 28 | def wrapped(a: int) -> int: 29 | return a + 1 30 | 31 | @wraps(wrapped) 32 | def wrapper(*args: Any, **kwargs: Any) -> str: 33 | return str(wrapped(*args, **kwargs)) 34 | 35 | wrapped_signature = _get_resolved_signature(wrapped) 36 | wrapper_signature = _get_resolved_signature(wrapper) 37 | 38 | assert wrapper(3) == "4" 39 | assert wrapped_signature.parameters == wrapper_signature.parameters 40 | assert wrapper_signature.return_annotation is str 41 | assert wrapped_signature.return_annotation is int 42 | 43 | _: Callable[[int], str] = wrapper 44 | 45 | 46 | def test_wrap_unannotated() -> None: 47 | """Unannotated functions can be wrapped.""" 48 | 49 | def inner(a): 50 | return a + 1 51 | 52 | @wraps(inner) 53 | def outer(*args: Any, **kwargs: Any) -> int: 54 | return inner(*args, **kwargs) 55 | 56 | assert outer(3) == 4 57 | -------------------------------------------------------------------------------- /src/tightwrap/__init__.py: -------------------------------------------------------------------------------- 1 | import sys 2 | from functools import wraps as functools_wraps 3 | from inspect import Signature, _empty 4 | from typing import Any, Callable, TypeVar, cast 5 | 6 | from ._backported import eval_if_necessary, get_annotations 7 | 8 | if sys.version_info >= (3, 10): 9 | from typing import ParamSpec 10 | else: 11 | from typing_extensions import ParamSpec 12 | 13 | P = ParamSpec("P") 14 | T = TypeVar("T") 15 | R = TypeVar("R") 16 | 17 | 18 | def _get_resolved_signature(fn: Callable[..., Any]) -> Signature: 19 | signature = Signature.from_callable(fn) 20 | evaluated_annotations, fn_globals, fn_locals = get_annotations(fn) 21 | 22 | for name, parameter in signature.parameters.items(): 23 | parameter._annotation = evaluated_annotations.get(name, _empty) # type: ignore 24 | 25 | new_return_annotation = eval_if_necessary( 26 | signature.return_annotation, fn_globals, fn_locals 27 | ) 28 | signature._return_annotation = new_return_annotation # type: ignore 29 | 30 | return signature 31 | 32 | 33 | def wraps(wrapped: Callable[P, Any]) -> Callable[[Callable[..., R]], Callable[P, R]]: 34 | """Apply `functools.wraps`""" 35 | 36 | def wrapper(fn: Callable[..., R]) -> Callable[P, R]: 37 | wrapper_return = _get_resolved_signature(fn).return_annotation 38 | res = functools_wraps(wrapped)(fn) 39 | 40 | orig_sig = _get_resolved_signature(wrapped) 41 | 42 | if orig_sig.return_annotation != wrapper_return: 43 | # We do a little rewriting. 44 | new_sig = Signature(None, return_annotation=wrapper_return) 45 | new_sig._parameters = orig_sig.parameters # type: ignore 46 | res.__signature__ = new_sig # type: ignore 47 | 48 | return cast(Callable[P, R], res) 49 | 50 | return wrapper 51 | -------------------------------------------------------------------------------- /.github/workflows/pypi-package.yml: -------------------------------------------------------------------------------- 1 | --- 2 | name: Build & maybe upload PyPI package 3 | 4 | on: 5 | push: 6 | branches: [main] 7 | tags: ["*"] 8 | release: 9 | types: 10 | - published 11 | workflow_dispatch: 12 | 13 | permissions: 14 | contents: read 15 | id-token: write 16 | 17 | jobs: 18 | build-package: 19 | name: Build & verify package 20 | runs-on: ubuntu-latest 21 | 22 | steps: 23 | - uses: actions/checkout@v4 24 | with: 25 | fetch-depth: 0 26 | 27 | - uses: hynek/build-and-inspect-python-package@v2 28 | 29 | # Upload to Test PyPI on every commit on main. 30 | release-test-pypi: 31 | name: Publish in-dev package to test.pypi.org 32 | environment: release-test-pypi 33 | if: github.event_name == 'push' && github.ref == 'refs/heads/main' 34 | runs-on: ubuntu-latest 35 | needs: build-package 36 | 37 | steps: 38 | - name: Download packages built by build-and-inspect-python-package 39 | uses: actions/download-artifact@v4 40 | with: 41 | name: Packages 42 | path: dist 43 | 44 | - name: Upload package to Test PyPI 45 | uses: pypa/gh-action-pypi-publish@release/v1 46 | with: 47 | repository-url: https://test.pypi.org/legacy/ 48 | 49 | # Upload to real PyPI on GitHub Releases. 50 | release-pypi: 51 | name: Publish released package to pypi.org 52 | environment: release-pypi 53 | if: github.event.action == 'published' 54 | runs-on: ubuntu-latest 55 | needs: build-package 56 | 57 | steps: 58 | - name: Download packages built by build-and-inspect-python-package 59 | uses: actions/download-artifact@v4 60 | with: 61 | name: Packages 62 | path: dist 63 | 64 | - name: Upload package to PyPI 65 | uses: pypa/gh-action-pypi-publish@release/v1 66 | -------------------------------------------------------------------------------- /src/tightwrap/_backported.py: -------------------------------------------------------------------------------- 1 | import functools 2 | import sys 3 | from types import GetSetDescriptorType, ModuleType 4 | from typing import Any, Callable, Dict, Tuple, cast 5 | 6 | 7 | Annotations = Dict[str, Any] 8 | Globals = Dict[str, Any] 9 | Locals = Dict[str, Any] 10 | GetAnnotationsResults = Tuple[Annotations, Globals, Locals] 11 | 12 | 13 | def eval_if_necessary(source: Any, globals: Globals, locals: Locals) -> Any: 14 | if not isinstance(source, str): 15 | return source 16 | 17 | return eval(source, globals, locals) 18 | 19 | 20 | def get_annotations(obj: Callable[..., Any]) -> GetAnnotationsResults: 21 | # Copied from https://github.com/python/cpython/blob/3.12/Lib/inspect.py#L176-L288 22 | 23 | obj_globals: Any 24 | obj_locals: Any 25 | unwrap: Any 26 | 27 | if isinstance(obj, type): 28 | obj_dict = getattr(obj, "__dict__", None) 29 | 30 | if obj_dict and hasattr(obj_dict, "get"): 31 | ann = obj_dict.get("__annotations__", None) 32 | if isinstance(ann, GetSetDescriptorType): 33 | ann = None 34 | else: 35 | ann = None 36 | 37 | obj_globals = None 38 | module_name = getattr(obj, "__module__", None) 39 | 40 | if module_name: 41 | module = sys.modules.get(module_name, None) 42 | 43 | if module: 44 | obj_globals = getattr(module, "__dict__", None) 45 | 46 | obj_locals = dict(vars(obj)) 47 | unwrap = obj 48 | 49 | elif isinstance(obj, ModuleType): 50 | ann = getattr(obj, "__annotations__", None) 51 | obj_globals = getattr(obj, "__dict__") 52 | obj_locals = None 53 | unwrap = None 54 | 55 | elif callable(obj): 56 | ann = getattr(obj, "__annotations__", None) 57 | obj_globals = getattr(obj, "__globals__", None) 58 | obj_locals = None 59 | unwrap = obj 60 | 61 | else: 62 | raise TypeError(f"{obj!r} is not a module, class, or callable.") 63 | 64 | if ann is None: 65 | return cast(GetAnnotationsResults, ({}, obj_globals, obj_locals)) 66 | 67 | if not isinstance(ann, dict): 68 | raise ValueError(f"{obj!r}.__annotations__ is neither a dict nor None") 69 | 70 | if not ann: 71 | return cast(GetAnnotationsResults, ({}, obj_globals, obj_locals)) 72 | 73 | if unwrap is not None: 74 | while True: 75 | if hasattr(unwrap, "__wrapped__"): 76 | unwrap = unwrap.__wrapped__ 77 | continue 78 | if isinstance(unwrap, functools.partial): 79 | unwrap = unwrap.func 80 | continue 81 | break 82 | if hasattr(unwrap, "__globals__"): 83 | obj_globals = unwrap.__globals__ 84 | 85 | return_value = { 86 | key: eval_if_necessary(value, obj_globals, obj_locals) 87 | for key, value in cast(Dict[str, Any], ann).items() 88 | } 89 | 90 | return cast(GetAnnotationsResults, (return_value, obj_globals, obj_locals)) 91 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # tightwrap 2 | 3 | [![PyPI](https://img.shields.io/pypi/v/tightwrap.svg)](https://pypi.python.org/pypi/tightwrap) 4 | [![Build](https://github.com/Tinche/tightwrap/workflows/CI/badge.svg)](https://github.com/Tinche/tightwrap/actions?workflow=CI) 5 | [![Coverage](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/Tinche/090e3ce4d18dd18bb1323538d6de8ffd/raw/covbadge.json)](https://github.com/Tinche/tightwrap/actions/workflows/main.yml) 6 | [![Supported Python Versions](https://img.shields.io/pypi/pyversions/tightwrap.svg)](https://github.com/Tinche/tightwrap) 7 | [![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff) 8 | 9 | _tightwrap_ (pronounced _typed wrap_) is a drop-in replacement for [`functools.wraps`](https://docs.python.org/3/library/functools.html#functools.wraps) that works with static typing. 10 | _tightwrap_ is very small, so if you don't want to add a dependency to it just [vendor this file](https://github.com/Tinche/tightwrap/blob/main/src/tightwrap/__init__.py). 11 | 12 | `functools.wraps` is very commonly used to adapt runtime function signatures when wrapping functions, but it doesn't work well with static typing tools. 13 | `tightwrap.wraps` has the same interface and you should use it instead: 14 | 15 | ```python 16 | from tightwrap import wraps 17 | 18 | def function(a: int) -> int: 19 | return a + 1 20 | 21 | @wraps(function) 22 | def wrapping(*args, **kwargs) -> int: 23 | return function(*args, **kwargs) 24 | 25 | reveal_type(wrapping) # Revealed type is "def (a: builtins.int) -> builtins.int" 26 | 27 | wrapping("a string") # error: Argument 1 to "wrapping" has incompatible type "str"; expected "int" 28 | ``` 29 | 30 | _tightwrap_ applies `functools.wraps` under the hood so runtime inspection continues to work. 31 | 32 | If your wrapper has a different return type than the function you're wrapping, 33 | `tightwrap.wraps` will use the _wrapper_ return type and make the runtime signature return type match. 34 | 35 | For comparison, when using `functools.wraps` the current version of Mypy reports: 36 | 37 | ```python 38 | from functools import wraps 39 | 40 | def function(a: int) -> int: 41 | return a + 1 42 | 43 | @wraps(function) 44 | def wrapping(*args, **kwargs) -> int: 45 | return function(*args, **kwargs) 46 | 47 | reveal_type(wrapping) # Revealed type is "def (*args: Any, **kwargs: Any) -> builtins.int" 48 | 49 | wrapping("a string") # No type error, blows up at runtime. 50 | ``` 51 | 52 | ## Changelog 53 | 54 | ### 24.4.0 (UNRELEASED) 55 | 56 | - Add support for Python 3.14. 57 | ([#8](https://github.com/Tinche/tightwrap/pull/8)) 58 | - Add support for Python 3.13. 59 | ([#4](https://github.com/Tinche/tightwrap/pull/4)) 60 | - Drop support for Python 3.8 and 3.9. 61 | ([#8](https://github.com/Tinche/tightwrap/pull/8)) 62 | 63 | ### 24.3.0 (2024-05-24) 64 | 65 | - Fix wrapping unannotated functions. 66 | ([#2](https://github.com/Tinche/tightwrap/issues/2) [#3](https://github.com/Tinche/tightwrap/pull/3)) 67 | 68 | ### 24.2.0 (2024-05-04) 69 | 70 | - Add support for Python 3.8 and 3.9. 71 | ([#1](https://github.com/Tinche/tightwrap/pull/1)) 72 | 73 | ### 24.1.0 (2024-01-09) 74 | 75 | - Initial version. 76 | -------------------------------------------------------------------------------- /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | name: CI 3 | 4 | on: 5 | push: 6 | branches: ["main"] 7 | pull_request: 8 | branches: ["main"] 9 | workflow_dispatch: 10 | 11 | jobs: 12 | tests: 13 | name: "Python ${{ matrix.python-version }}" 14 | runs-on: "ubuntu-latest" 15 | 16 | strategy: 17 | matrix: 18 | python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"] 19 | 20 | steps: 21 | - uses: "actions/checkout@v3" 22 | 23 | - uses: "actions/setup-python@v4" 24 | with: 25 | python-version: "${{ matrix.python-version }}" 26 | allow-prereleases: true 27 | 28 | - uses: extractions/setup-just@v3 29 | 30 | - uses: hynek/setup-cached-uv@757bedc3f972eb7227a1aa657651f15a8527c817 # v2.3.0 31 | 32 | - name: "Run Tox" 33 | run: | 34 | set -xe 35 | python -VV 36 | python -Im site 37 | python -Im pip install --upgrade pip wheel 38 | python -Im pip install --upgrade tox tox-gh-actions 39 | python -Im tox 40 | 41 | - name: Upload coverage data 42 | uses: actions/upload-artifact@v4 43 | with: 44 | name: coverage-data-${{ matrix.python-version }} 45 | path: .coverage.* 46 | if-no-files-found: ignore 47 | include-hidden-files: true 48 | 49 | coverage: 50 | name: "Combine & check coverage." 51 | needs: "tests" 52 | runs-on: "ubuntu-latest" 53 | 54 | steps: 55 | - uses: "actions/checkout@v3" 56 | 57 | - uses: "actions/setup-python@v4" 58 | with: 59 | cache: "pip" 60 | python-version: "3.11" 61 | 62 | - run: "python -Im pip install --upgrade coverage[toml]" 63 | 64 | - name: Download coverage data 65 | uses: actions/download-artifact@v4 66 | with: 67 | pattern: coverage-data-* 68 | merge-multiple: true 69 | 70 | - name: "Combine coverage" 71 | run: | 72 | python -Im coverage combine 73 | python -Im coverage html --skip-covered --skip-empty 74 | python -Im coverage json 75 | 76 | # Report and write to summary. 77 | python -Im coverage report | sed 's/^/ /' >> $GITHUB_STEP_SUMMARY 78 | 79 | export TOTAL=$(python -c "import json;print(json.load(open('coverage.json'))['totals']['percent_covered_display'])") 80 | echo "total=$TOTAL" >> $GITHUB_ENV 81 | 82 | # Report again and fail if under the threshold. 83 | python -Im coverage report --fail-under=97 84 | 85 | - name: "Upload HTML report." 86 | uses: "actions/upload-artifact@v4" 87 | with: 88 | name: "html-report" 89 | path: "htmlcov" 90 | if: always() 91 | 92 | package: 93 | name: "Build & verify package" 94 | runs-on: "ubuntu-latest" 95 | 96 | steps: 97 | - uses: "actions/checkout@v3" 98 | 99 | - uses: "actions/setup-python@v4" 100 | with: 101 | python-version: "3.11" 102 | 103 | - name: "Install tools" 104 | run: "python -m pip install twine check-wheel-contents build" 105 | 106 | - name: "Build package" 107 | run: "python -m build" 108 | 109 | - name: "List result" 110 | run: "ls -l dist" 111 | 112 | - name: "Check wheel contents" 113 | run: "check-wheel-contents dist/*.whl" 114 | 115 | - name: "Check long_description" 116 | run: "python -m twine check dist/*" 117 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | share/python-wheels/ 24 | *.egg-info/ 25 | .installed.cfg 26 | *.egg 27 | MANIFEST 28 | 29 | # PyInstaller 30 | # Usually these files are written by a python script from a template 31 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 32 | *.manifest 33 | *.spec 34 | 35 | # Installer logs 36 | pip-log.txt 37 | pip-delete-this-directory.txt 38 | 39 | # Unit test / coverage reports 40 | htmlcov/ 41 | .tox/ 42 | .nox/ 43 | .coverage 44 | .coverage.* 45 | .cache 46 | nosetests.xml 47 | coverage.xml 48 | *.cover 49 | *.py,cover 50 | .hypothesis/ 51 | .pytest_cache/ 52 | cover/ 53 | 54 | # Translations 55 | *.mo 56 | *.pot 57 | 58 | # Django stuff: 59 | *.log 60 | local_settings.py 61 | db.sqlite3 62 | db.sqlite3-journal 63 | 64 | # Flask stuff: 65 | instance/ 66 | .webassets-cache 67 | 68 | # Scrapy stuff: 69 | .scrapy 70 | 71 | # Sphinx documentation 72 | docs/_build/ 73 | 74 | # PyBuilder 75 | .pybuilder/ 76 | target/ 77 | 78 | # Jupyter Notebook 79 | .ipynb_checkpoints 80 | 81 | # IPython 82 | profile_default/ 83 | ipython_config.py 84 | 85 | # pyenv 86 | # For a library or package, you might want to ignore these files since the code is 87 | # intended to run in multiple environments; otherwise, check them in: 88 | # .python-version 89 | 90 | # pipenv 91 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 92 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 93 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 94 | # install all needed dependencies. 95 | #Pipfile.lock 96 | 97 | # poetry 98 | # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. 99 | # This is especially recommended for binary packages to ensure reproducibility, and is more 100 | # commonly ignored for libraries. 101 | # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control 102 | #poetry.lock 103 | 104 | # pdm 105 | # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. 106 | #pdm.lock 107 | # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it 108 | # in version control. 109 | # https://pdm-project.org/#use-with-ide 110 | .pdm.toml 111 | .pdm-python 112 | .pdm-build/ 113 | 114 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm 115 | __pypackages__/ 116 | 117 | # Celery stuff 118 | celerybeat-schedule 119 | celerybeat.pid 120 | 121 | # SageMath parsed files 122 | *.sage.py 123 | 124 | # Environments 125 | .env 126 | .venv 127 | env/ 128 | venv/ 129 | ENV/ 130 | env.bak/ 131 | venv.bak/ 132 | 133 | # Spyder project settings 134 | .spyderproject 135 | .spyproject 136 | 137 | # Rope project settings 138 | .ropeproject 139 | 140 | # mkdocs documentation 141 | /site 142 | 143 | # mypy 144 | .mypy_cache/ 145 | .dmypy.json 146 | dmypy.json 147 | 148 | # Pyre type checker 149 | .pyre/ 150 | 151 | # pytype static type analyzer 152 | .pytype/ 153 | 154 | # Cython debug symbols 155 | cython_debug/ 156 | 157 | # PyCharm 158 | # JetBrains specific template is maintained in a separate JetBrains.gitignore that can 159 | # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore 160 | # and can be added to the global gitignore or merged into this file. For a more nuclear 161 | # option (not recommended) you can uncomment the following to ignore the entire idea folder. 162 | #.idea/ 163 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. 10 | 11 | "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. 12 | 13 | "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. 14 | 15 | "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. 16 | 17 | "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. 18 | 19 | "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. 20 | 21 | "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). 22 | 23 | "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. 24 | 25 | "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." 26 | 27 | "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 28 | 29 | 2. Grant of Copyright License. 30 | 31 | Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 32 | 33 | 3. Grant of Patent License. 34 | 35 | Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 36 | 37 | 4. Redistribution. 38 | 39 | You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: 40 | 41 | You must give any other recipients of the Work or Derivative Works a copy of this License; and 42 | You must cause any modified files to carry prominent notices stating that You changed the files; and 43 | You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and 44 | If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. 45 | 46 | You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 47 | 48 | 5. Submission of Contributions. 49 | 50 | Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 51 | 52 | 6. Trademarks. 53 | 54 | This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 55 | 56 | 7. Disclaimer of Warranty. 57 | 58 | Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 59 | 60 | 8. Limitation of Liability. 61 | 62 | In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 63 | 64 | 9. Accepting Warranty or Additional Liability. 65 | 66 | While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. 67 | 68 | END OF TERMS AND CONDITIONS --------------------------------------------------------------------------------