propcache-0.3.1/0000755000175000017500000000000014770661563015626 5ustar billchenchinabillchenchinapropcache-0.3.1/src/0000755000175000017500000000000014770661563016415 5ustar billchenchinabillchenchinapropcache-0.3.1/src/propcache.egg-info/0000755000175000017500000000000014770661563022053 5ustar billchenchinabillchenchinapropcache-0.3.1/src/propcache.egg-info/top_level.txt0000644000175000017500000000001214770661563024576 0ustar billchenchinabillchenchinapropcache propcache-0.3.1/src/propcache.egg-info/not-zip-safe0000644000175000017500000000000114770661562024300 0ustar billchenchinabillchenchina propcache-0.3.1/src/propcache.egg-info/dependency_links.txt0000644000175000017500000000000114770661563026121 0ustar billchenchinabillchenchina propcache-0.3.1/src/propcache.egg-info/PKG-INFO0000644000175000017500000002476414770661563023165 0ustar billchenchinabillchenchinaMetadata-Version: 2.4 Name: propcache Version: 0.3.1 Summary: Accelerated property cache Home-page: https://github.com/aio-libs/propcache Author: Andrew Svetlov Author-email: andrew.svetlov@gmail.com Maintainer: aiohttp team Maintainer-email: team@aiohttp.org License: Apache-2.0 Project-URL: Chat: Matrix, https://matrix.to/#/#aio-libs:matrix.org Project-URL: Chat: Matrix Space, https://matrix.to/#/#aio-libs-space:matrix.org Project-URL: CI: GitHub Workflows, https://github.com/aio-libs/propcache/actions?query=branch:master Project-URL: Code of Conduct, https://github.com/aio-libs/.github/blob/master/CODE_OF_CONDUCT.md Project-URL: Coverage: codecov, https://codecov.io/github/aio-libs/propcache Project-URL: Docs: Changelog, https://propcache.readthedocs.io/en/latest/changes/ Project-URL: Docs: RTD, https://propcache.readthedocs.io Project-URL: GitHub: issues, https://github.com/aio-libs/propcache/issues Project-URL: GitHub: repo, https://github.com/aio-libs/propcache Keywords: cython,cext,propcache Classifier: Development Status :: 5 - Production/Stable Classifier: Intended Audience :: Developers Classifier: License :: OSI Approved :: Apache Software License Classifier: Programming Language :: Cython Classifier: Programming Language :: Python Classifier: Programming Language :: Python :: 3 Classifier: Programming Language :: Python :: 3.9 Classifier: Programming Language :: Python :: 3.10 Classifier: Programming Language :: Python :: 3.11 Classifier: Programming Language :: Python :: 3.12 Classifier: Programming Language :: Python :: 3.13 Classifier: Topic :: Internet :: WWW/HTTP Classifier: Topic :: Software Development :: Libraries :: Python Modules Requires-Python: >=3.9 Description-Content-Type: text/x-rst License-File: LICENSE License-File: NOTICE Dynamic: license-file propcache ========= The module provides a fast implementation of cached properties for Python 3.9+. .. image:: https://github.com/aio-libs/propcache/actions/workflows/ci-cd.yml/badge.svg :target: https://github.com/aio-libs/propcache/actions?query=workflow%3ACI :align: right .. image:: https://codecov.io/gh/aio-libs/propcache/branch/master/graph/badge.svg :target: https://codecov.io/gh/aio-libs/propcache .. image:: https://badge.fury.io/py/propcache.svg :target: https://badge.fury.io/py/propcache .. image:: https://readthedocs.org/projects/propcache/badge/?version=latest :target: https://propcache.readthedocs.io .. image:: https://img.shields.io/pypi/pyversions/propcache.svg :target: https://pypi.python.org/pypi/propcache .. image:: https://img.shields.io/matrix/aio-libs:matrix.org?label=Discuss%20on%20Matrix%20at%20%23aio-libs%3Amatrix.org&logo=matrix&server_fqdn=matrix.org&style=flat :target: https://matrix.to/#/%23aio-libs:matrix.org :alt: Matrix Room — #aio-libs:matrix.org .. image:: https://img.shields.io/matrix/aio-libs-space:matrix.org?label=Discuss%20on%20Matrix%20at%20%23aio-libs-space%3Amatrix.org&logo=matrix&server_fqdn=matrix.org&style=flat :target: https://matrix.to/#/%23aio-libs-space:matrix.org :alt: Matrix Space — #aio-libs-space:matrix.org Introduction ------------ The API is designed to be nearly identical to the built-in ``functools.cached_property`` class, except for the additional ``under_cached_property`` class which uses ``self._cache`` instead of ``self.__dict__`` to store the cached values and prevents ``__set__`` from being called. For full documentation please read https://propcache.readthedocs.io. Installation ------------ :: $ pip install propcache The library is Python 3 only! PyPI contains binary wheels for Linux, Windows and MacOS. If you want to install ``propcache`` on another operating system where wheels are not provided, the the tarball will be used to compile the library from the source code. It requires a C compiler and and Python headers installed. To skip the compilation you must explicitly opt-in by using a PEP 517 configuration setting ``pure-python``, or setting the ``PROPCACHE_NO_EXTENSIONS`` environment variable to a non-empty value, e.g.: .. code-block:: console $ pip install propcache --config-settings=pure-python=false Please note that the pure-Python (uncompiled) version is much slower. However, PyPy always uses a pure-Python implementation, and, as such, it is unaffected by this variable. API documentation ------------------ The documentation is located at https://propcache.readthedocs.io. Source code ----------- The project is hosted on GitHub_ Please file an issue on the `bug tracker `_ if you have found a bug or have some suggestion in order to improve the library. Discussion list --------------- *aio-libs* google group: https://groups.google.com/forum/#!forum/aio-libs Feel free to post your questions and ideas here. Authors and License ------------------- The ``propcache`` package is derived from ``yarl`` which is written by Andrew Svetlov. It's *Apache 2* licensed and freely available. .. _GitHub: https://github.com/aio-libs/propcache ========= Changelog ========= .. You should *NOT* be adding new change log entries to this file, this file is managed by towncrier. You *may* edit previous change logs to fix problems like typo corrections or such. To add a new change log entry, please see https://pip.pypa.io/en/latest/development/#adding-a-news-entry we named the news folder "changes". WARNING: Don't drop the next directive! .. towncrier release notes start 0.3.1 ===== *(2025-03-25)* Bug fixes --------- - Improved typing annotations, fixing some type errors under correct usage and improving typing robustness generally -- by `@Dreamsorcerer `__. *Related issues and pull requests on GitHub:* `#103 `__. ---- 0.3.0 ===== *(2025-02-20)* Features -------- - Implemented support for the free-threaded build of CPython 3.13 -- by `@lysnikolaou `__. *Related issues and pull requests on GitHub:* `#84 `__. Packaging updates and notes for downstreams ------------------------------------------- - Started building wheels for the free-threaded build of CPython 3.13 -- by `@lysnikolaou `__. *Related issues and pull requests on GitHub:* `#84 `__. Contributor-facing changes -------------------------- - GitHub Actions CI/CD is now configured to manage caching pip-ecosystem dependencies using `re-actors/cache-python-deps`_ -- an action by `@webknjaz `__ that takes into account ABI stability and the exact version of Python runtime. .. _`re-actors/cache-python-deps`: https://github.com/marketplace/actions/cache-python-deps *Related issues and pull requests on GitHub:* `#93 `__. ---- 0.2.1 ===== *(2024-12-01)* Bug fixes --------- - Stopped implicitly allowing the use of Cython pre-release versions when building the distribution package -- by `@ajsanchezsanz `__ and `@markgreene74 `__. *Related commits on GitHub:* `64df0a6 `__. - Fixed ``wrapped`` and ``func`` not being accessible in the Cython versions of ``propcache.api.cached_property`` and ``propcache.api.under_cached_property`` decorators -- by `@bdraco `__. *Related issues and pull requests on GitHub:* `#72 `__. Removals and backward incompatible breaking changes --------------------------------------------------- - Removed support for Python 3.8 as it has reached end of life -- by `@bdraco `__. *Related issues and pull requests on GitHub:* `#57 `__. Packaging updates and notes for downstreams ------------------------------------------- - Stopped implicitly allowing the use of Cython pre-release versions when building the distribution package -- by `@ajsanchezsanz `__ and `@markgreene74 `__. *Related commits on GitHub:* `64df0a6 `__. ---- 0.2.0 ===== *(2024-10-07)* Bug fixes --------- - Fixed loading the C-extensions on Python 3.8 -- by `@bdraco `__. *Related issues and pull requests on GitHub:* `#26 `__. Features -------- - Improved typing for the ``propcache.api.under_cached_property`` decorator -- by `@bdraco `__. *Related issues and pull requests on GitHub:* `#38 `__. Improved documentation ---------------------- - Added API documentation for the ``propcache.api.cached_property`` and ``propcache.api.under_cached_property`` decorators -- by `@bdraco `__. *Related issues and pull requests on GitHub:* `#16 `__. Packaging updates and notes for downstreams ------------------------------------------- - Moved ``propcache.api.under_cached_property`` and ``propcache.api.cached_property`` to `propcache.api` -- by `@bdraco `__. Both decorators remain importable from the top-level package, however importing from `propcache.api` is now the recommended way to use them. *Related issues and pull requests on GitHub:* `#19 `__, `#24 `__, `#32 `__. - Converted project to use a src layout -- by `@bdraco `__. *Related issues and pull requests on GitHub:* `#22 `__, `#29 `__, `#37 `__. ---- 0.1.0 ===== *(2024-10-03)* Features -------- - Added ``armv7l`` wheels -- by `@bdraco `__. *Related issues and pull requests on GitHub:* `#5 `__. ---- 0.0.0 ===== *(2024-10-02)* - Initial release. propcache-0.3.1/src/propcache.egg-info/SOURCES.txt0000644000175000017500000000271114770661563023740 0ustar billchenchinabillchenchina.coveragerc CHANGES.rst LICENSE MANIFEST.in NOTICE README.rst pyproject.toml pytest.ini setup.cfg towncrier.toml CHANGES/.TEMPLATE.rst CHANGES/.gitignore CHANGES/README.rst docs/Makefile docs/api.rst docs/changes.rst docs/conf.py docs/index.rst docs/make.bat docs/spelling_wordlist.txt docs/_static/README.txt docs/contributing/guidelines.rst docs/contributing/release_guide.rst packaging/README.md packaging/pep517_backend/__init__.py packaging/pep517_backend/__main__.py packaging/pep517_backend/_backend.py packaging/pep517_backend/_compat.py packaging/pep517_backend/_cython_configuration.py packaging/pep517_backend/_transformers.py packaging/pep517_backend/cli.py packaging/pep517_backend/hooks.py requirements/codspeed.txt requirements/cython-freethreading.txt requirements/cython.txt requirements/dev.txt requirements/doc-spelling.txt requirements/doc.txt requirements/lint.txt requirements/test-freethreading.txt requirements/test-pure.txt requirements/test.txt requirements/towncrier.txt src/propcache/__init__.py src/propcache/_helpers.py src/propcache/_helpers_c.pyx src/propcache/_helpers_py.py src/propcache/api.py src/propcache/py.typed src/propcache.egg-info/PKG-INFO src/propcache.egg-info/SOURCES.txt src/propcache.egg-info/dependency_links.txt src/propcache.egg-info/not-zip-safe src/propcache.egg-info/top_level.txt tests/conftest.py tests/test_api.py tests/test_benchmarks.py tests/test_cached_property.py tests/test_init.py tests/test_under_cached_property.pypropcache-0.3.1/src/propcache/0000755000175000017500000000000014770661563020361 5ustar billchenchinabillchenchinapropcache-0.3.1/src/propcache/_helpers_c.pyx0000644000175000017500000000501114770661556023225 0ustar billchenchinabillchenchina# cython: language_level=3, freethreading_compatible=True from types import GenericAlias cdef _sentinel = object() cdef class under_cached_property: """Use as a class method decorator. It operates almost exactly like the Python `@property` decorator, but it puts the result of the method it decorates into the instance dict after the first call, effectively replacing the function it decorates with an instance variable. It is, in Python parlance, a data descriptor. """ cdef readonly object wrapped cdef object name def __init__(self, wrapped): self.wrapped = wrapped self.name = wrapped.__name__ @property def __doc__(self): return self.wrapped.__doc__ def __get__(self, inst, owner): if inst is None: return self cdef dict cache = inst._cache val = cache.get(self.name, _sentinel) if val is _sentinel: val = self.wrapped(inst) cache[self.name] = val return val def __set__(self, inst, value): raise AttributeError("cached property is read-only") __class_getitem__ = classmethod(GenericAlias) cdef class cached_property: """Use as a class method decorator. It operates almost exactly like the Python `@property` decorator, but it puts the result of the method it decorates into the instance dict after the first call, effectively replacing the function it decorates with an instance variable. It is, in Python parlance, a data descriptor. """ cdef readonly object func cdef object name def __init__(self, func): self.func = func self.name = None @property def __doc__(self): return self.func.__doc__ def __set_name__(self, owner, name): if self.name is None: self.name = name elif name != self.name: raise TypeError( "Cannot assign the same cached_property to two different names " f"({self.name!r} and {name!r})." ) def __get__(self, inst, owner): if inst is None: return self if self.name is None: raise TypeError( "Cannot use cached_property instance" " without calling __set_name__ on it.") cdef dict cache = inst.__dict__ val = cache.get(self.name, _sentinel) if val is _sentinel: val = self.func(inst) cache[self.name] = val return val __class_getitem__ = classmethod(GenericAlias) propcache-0.3.1/src/propcache/api.py0000644000175000017500000000026314770661556021507 0ustar billchenchinabillchenchina"""Public API of the property caching library.""" from ._helpers import cached_property, under_cached_property __all__ = ( "cached_property", "under_cached_property", ) propcache-0.3.1/src/propcache/_helpers.py0000644000175000017500000000302114770661556022532 0ustar billchenchinabillchenchinaimport os import sys from typing import TYPE_CHECKING __all__ = ("cached_property", "under_cached_property") NO_EXTENSIONS = bool(os.environ.get("PROPCACHE_NO_EXTENSIONS")) # type: bool if sys.implementation.name != "cpython": NO_EXTENSIONS = True # isort: off if TYPE_CHECKING: from ._helpers_py import cached_property as cached_property_py from ._helpers_py import under_cached_property as under_cached_property_py cached_property = cached_property_py under_cached_property = under_cached_property_py elif not NO_EXTENSIONS: # pragma: no branch try: from ._helpers_c import cached_property as cached_property_c # type: ignore[attr-defined, unused-ignore] from ._helpers_c import under_cached_property as under_cached_property_c # type: ignore[attr-defined, unused-ignore] cached_property = cached_property_c under_cached_property = under_cached_property_c except ImportError: # pragma: no cover from ._helpers_py import cached_property as cached_property_py from ._helpers_py import under_cached_property as under_cached_property_py cached_property = cached_property_py # type: ignore[assignment, misc] under_cached_property = under_cached_property_py else: from ._helpers_py import cached_property as cached_property_py from ._helpers_py import under_cached_property as under_cached_property_py cached_property = cached_property_py # type: ignore[assignment, misc] under_cached_property = under_cached_property_py # isort: on propcache-0.3.1/src/propcache/_helpers_py.py0000644000175000017500000000357514770661556023260 0ustar billchenchinabillchenchina"""Various helper functions.""" import sys from collections.abc import Mapping from functools import cached_property from typing import Any, Callable, Generic, Optional, Protocol, TypeVar, Union, overload __all__ = ("under_cached_property", "cached_property") if sys.version_info >= (3, 11): from typing import Self else: Self = Any _T = TypeVar("_T") # We use Mapping to make it possible to use TypedDict, but this isn't # technically type safe as we need to assign into the dict. _Cache = TypeVar("_Cache", bound=Mapping[str, Any]) class _CacheImpl(Protocol[_Cache]): _cache: _Cache class under_cached_property(Generic[_T]): """Use as a class method decorator. It operates almost exactly like the Python `@property` decorator, but it puts the result of the method it decorates into the instance dict after the first call, effectively replacing the function it decorates with an instance variable. It is, in Python parlance, a data descriptor. """ def __init__(self, wrapped: Callable[[Any], _T]) -> None: self.wrapped = wrapped self.__doc__ = wrapped.__doc__ self.name = wrapped.__name__ @overload def __get__(self, inst: None, owner: Optional[type[object]] = None) -> Self: ... @overload def __get__(self, inst: _CacheImpl[Any], owner: Optional[type[object]] = None) -> _T: ... # type: ignore[misc] def __get__( self, inst: Optional[_CacheImpl[Any]], owner: Optional[type[object]] = None ) -> Union[_T, Self]: if inst is None: return self try: return inst._cache[self.name] # type: ignore[no-any-return] except KeyError: val = self.wrapped(inst) inst._cache[self.name] = val return val def __set__(self, inst: _CacheImpl[Any], value: _T) -> None: raise AttributeError("cached property is read-only") propcache-0.3.1/src/propcache/py.typed0000644000175000017500000000001614770661556022057 0ustar billchenchinabillchenchina# Placeholder propcache-0.3.1/src/propcache/__init__.py0000644000175000017500000000170514770661556022477 0ustar billchenchinabillchenchina"""propcache: An accelerated property cache for Python classes.""" from typing import TYPE_CHECKING _PUBLIC_API = ("cached_property", "under_cached_property") __version__ = "0.3.1" __all__ = () # Imports have moved to `propcache.api` in 0.2.0+. # This module is now a facade for the API. if TYPE_CHECKING: from .api import cached_property as cached_property # noqa: F401 from .api import under_cached_property as under_cached_property # noqa: F401 def _import_facade(attr: str) -> object: """Import the public API from the `api` module.""" if attr in _PUBLIC_API: from . import api # pylint: disable=import-outside-toplevel return getattr(api, attr) raise AttributeError(f"module '{__package__}' has no attribute '{attr}'") def _dir_facade() -> list[str]: """Include the public API in the module's dir() output.""" return [*_PUBLIC_API, *globals().keys()] __getattr__ = _import_facade __dir__ = _dir_facade propcache-0.3.1/NOTICE0000644000175000017500000000114114770661556016531 0ustar billchenchinabillchenchina Copyright 2016-2021, Andrew Svetlov and aio-libs team Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. propcache-0.3.1/pyproject.toml0000644000175000017500000000726614770661556020557 0ustar billchenchinabillchenchina[build-system] requires = [ # NOTE: The following build dependencies are necessary for initial # NOTE: provisioning of the in-tree build backend located under # NOTE: `packaging/pep517_backend/`. "expandvars", "setuptools >= 47", # Minimum required for `version = attr:` "tomli; python_version < '3.11'", ] backend-path = ["packaging"] # requires `pip >= 20` or `pep517 >= 0.6.0` build-backend = "pep517_backend.hooks" # wraps `setuptools.build_meta` [tool.local.cythonize] # This attr can contain multiple globs src = ["src/propcache/*.pyx"] [tool.local.cythonize.env] # Env vars provisioned during cythonize call #CFLAGS = "-DCYTHON_TRACE=1 ${CFLAGS}" #LDFLAGS = "${LDFLAGS}" [tool.local.cythonize.flags] # This section can contain the following booleans: # * annotate — generate annotated HTML page for source files # * build — build extension modules using distutils # * inplace — build extension modules in place using distutils (implies -b) # * force — force recompilation # * quiet — be less verbose during compilation # * lenient — increase Python compat by ignoring some compile time errors # * keep-going — compile as much as possible, ignore compilation failures annotate = false build = false inplace = true force = true quiet = false lenient = false keep-going = false [tool.local.cythonize.kwargs] # This section can contain args that have values: # * exclude=PATTERN exclude certain file patterns from the compilation # * parallel=N run builds in N parallel jobs (default: calculated per system) # exclude = "**.py" # parallel = 12 [tool.local.cythonize.kwargs.directive] # This section can contain compiler directives. Ref: # https://cython.rtfd.io/en/latest/src/userguide/source_files_and_compilation.html#compiler-directives embedsignature = "True" emit_code_comments = "True" linetrace = "True" # Implies `profile=True` [tool.local.cythonize.kwargs.compile-time-env] # This section can contain compile time env vars [tool.local.cythonize.kwargs.option] # This section can contain cythonize options # Ref: https://github.com/cython/cython/blob/d6e6de9/Cython/Compiler/Options.py#L694-L730 #docstrings = "True" #embed_pos_in_docstring = "True" #warning_errors = "True" #error_on_unknown_names = "True" #error_on_uninitialized = "True" [tool.cibuildwheel] build-frontend = "build" enable = ["cpython-freethreading"] before-test = [ # NOTE: Attempt to have pip pre-compile PyYAML wheel with our build # NOTE: constraints unset. The hope is that pip will cache that wheel # NOTE: and the test env provisioning stage will pick up PyYAML from # NOTE: said cache rather than attempting to build it with a conflicting. # NOTE: Version of Cython. # Ref: https://github.com/pypa/cibuildwheel/issues/1666 "PIP_CONSTRAINT= pip install PyYAML", ] test-requires = "-r requirements/test.txt" test-command = "pytest -v --no-cov {project}/tests" # don't build PyPy wheels, install from source instead skip = "pp*" [tool.cibuildwheel.environment] COLOR = "yes" FORCE_COLOR = "1" MYPY_FORCE_COLOR = "1" PIP_CONSTRAINT = "requirements/cython.txt" PRE_COMMIT_COLOR = "always" PY_COLORS = "1" [tool.cibuildwheel.config-settings] pure-python = "false" [tool.cibuildwheel.windows] before-test = [] # Windows cmd has different syntax and pip chooses wheels [tool.cibuildwheel.linux] before-all = "yum install -y libffi-devel || apk add --upgrade libffi-dev || apt-get install libffi-dev" # TODO: Remove this when there's a Cython 3.1 final release # Remove PIP_CONSTRAINT from the environment [[tool.cibuildwheel.overrides]] select = "cp313t-*" test-requires = "-r requirements/test-freethreading.txt" inherit.environment = "append" environment = {PIP_CONSTRAINT = "requirements/cython-freethreading.txt"} propcache-0.3.1/setup.cfg0000644000175000017500000000414614770661563017454 0ustar billchenchinabillchenchina[bdist_wheel] universal = 0 [metadata] name = propcache version = attr: propcache.__version__ url = https://github.com/aio-libs/propcache project_urls = Chat: Matrix = https://matrix.to/#/#aio-libs:matrix.org Chat: Matrix Space = https://matrix.to/#/#aio-libs-space:matrix.org CI: GitHub Workflows = https://github.com/aio-libs/propcache/actions?query=branch:master Code of Conduct = https://github.com/aio-libs/.github/blob/master/CODE_OF_CONDUCT.md Coverage: codecov = https://codecov.io/github/aio-libs/propcache Docs: Changelog = https://propcache.readthedocs.io/en/latest/changes/ Docs: RTD = https://propcache.readthedocs.io GitHub: issues = https://github.com/aio-libs/propcache/issues GitHub: repo = https://github.com/aio-libs/propcache description = Accelerated property cache long_description = file: README.rst, CHANGES.rst long_description_content_type = text/x-rst author = Andrew Svetlov author_email = andrew.svetlov@gmail.com maintainer = aiohttp team maintainer_email = team@aiohttp.org license = Apache-2.0 license_files = LICENSE NOTICE classifiers = Development Status :: 5 - Production/Stable Intended Audience :: Developers License :: OSI Approved :: Apache Software License Programming Language :: Cython Programming Language :: Python Programming Language :: Python :: 3 Programming Language :: Python :: 3.9 Programming Language :: Python :: 3.10 Programming Language :: Python :: 3.11 Programming Language :: Python :: 3.12 Programming Language :: Python :: 3.13 Topic :: Internet :: WWW/HTTP Topic :: Software Development :: Libraries :: Python Modules keywords = cython cext propcache [options] python_requires = >=3.9 package_dir = =src packages = propcache zip_safe = False include_package_data = True [options.package_data] * = *.so *.pyd *.pyx [options.exclude_package_data] * = *.c *.h [pep8] max-line-length = 79 [flake8] extend-select = B950 ignore = E203,E301,E302,E501,E704,W503,W504,F811 max-line-length = 88 per-file-ignores = packaging/pep517_backend/hooks.py: F401 [isort] profile = black [egg_info] tag_build = tag_date = 0 propcache-0.3.1/docs/0000755000175000017500000000000014770661563016556 5ustar billchenchinabillchenchinapropcache-0.3.1/docs/Makefile0000644000175000017500000001705714770661556020232 0ustar billchenchinabillchenchina# Makefile for Sphinx documentation # # You can set these variables from the command line. SPHINXOPTS = SPHINXBUILD = sphinx-build PAPER = BUILDDIR = _build # Internal variables. PAPEROPT_a4 = -D latex_paper_size=a4 PAPEROPT_letter = -D latex_paper_size=letter ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . # the i18n builder cannot share the environment and doctrees with the others I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . .PHONY: help help: @echo "Please use \`make ' where is one of" @echo " html to make standalone HTML files" @echo " dirhtml to make HTML files named index.html in directories" @echo " singlehtml to make a single large HTML file" @echo " pickle to make pickle files" @echo " json to make JSON files" @echo " htmlhelp to make HTML files and a HTML help project" @echo " qthelp to make HTML files and a qthelp project" @echo " applehelp to make an Apple Help Book" @echo " devhelp to make HTML files and a Devhelp project" @echo " epub to make an epub" @echo " epub3 to make an epub3" @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" @echo " latexpdf to make LaTeX files and run them through pdflatex" @echo " latexpdfja to make LaTeX files and run them through platex/dvipdfmx" @echo " text to make text files" @echo " man to make manual pages" @echo " texinfo to make Texinfo files" @echo " info to make Texinfo files and run them through makeinfo" @echo " gettext to make PO message catalogs" @echo " changes to make an overview of all changed/added/deprecated items" @echo " xml to make Docutils-native XML files" @echo " pseudoxml to make pseudoxml-XML files for display purposes" @echo " linkcheck to check all external links for integrity" @echo " doctest to run all doctests embedded in the documentation (if enabled)" @echo " coverage to run coverage check of the documentation (if enabled)" @echo " dummy to check syntax errors of document sources" .PHONY: clean clean: rm -rf $(BUILDDIR)/* .PHONY: html html: $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html @echo @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." .PHONY: dirhtml dirhtml: $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml @echo @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." .PHONY: singlehtml singlehtml: $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml @echo @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." .PHONY: pickle pickle: $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle @echo @echo "Build finished; now you can process the pickle files." .PHONY: json json: $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json @echo @echo "Build finished; now you can process the JSON files." .PHONY: htmlhelp htmlhelp: $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp @echo @echo "Build finished; now you can run HTML Help Workshop with the" \ ".hhp project file in $(BUILDDIR)/htmlhelp." .PHONY: qthelp qthelp: $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp @echo @echo "Build finished; now you can run "qcollectiongenerator" with the" \ ".qhcp project file in $(BUILDDIR)/qthelp, like this:" @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/propcache.qhcp" @echo "To view the help file:" @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/propcache.qhc" .PHONY: applehelp applehelp: $(SPHINXBUILD) -b applehelp $(ALLSPHINXOPTS) $(BUILDDIR)/applehelp @echo @echo "Build finished. The help book is in $(BUILDDIR)/applehelp." @echo "N.B. You won't be able to view it unless you put it in" \ "~/Library/Documentation/Help or install it in your application" \ "bundle." .PHONY: devhelp devhelp: $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp @echo @echo "Build finished." @echo "To view the help file:" @echo "# mkdir -p $$HOME/.local/share/devhelp/propcache" @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/propcache" @echo "# devhelp" .PHONY: epub epub: $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub @echo @echo "Build finished. The epub file is in $(BUILDDIR)/epub." .PHONY: epub3 epub3: $(SPHINXBUILD) -b epub3 $(ALLSPHINXOPTS) $(BUILDDIR)/epub3 @echo @echo "Build finished. The epub3 file is in $(BUILDDIR)/epub3." .PHONY: latex latex: $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex @echo @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." @echo "Run \`make' in that directory to run these through (pdf)latex" \ "(use \`make latexpdf' here to do that automatically)." .PHONY: latexpdf latexpdf: $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex @echo "Running LaTeX files through pdflatex..." $(MAKE) -C $(BUILDDIR)/latex all-pdf @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." .PHONY: latexpdfja latexpdfja: $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex @echo "Running LaTeX files through platex and dvipdfmx..." $(MAKE) -C $(BUILDDIR)/latex all-pdf-ja @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." .PHONY: text text: $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text @echo @echo "Build finished. The text files are in $(BUILDDIR)/text." .PHONY: man man: $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man @echo @echo "Build finished. The manual pages are in $(BUILDDIR)/man." .PHONY: texinfo texinfo: $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo @echo @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo." @echo "Run \`make' in that directory to run these through makeinfo" \ "(use \`make info' here to do that automatically)." .PHONY: info info: $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo @echo "Running Texinfo files through makeinfo..." make -C $(BUILDDIR)/texinfo info @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo." .PHONY: gettext gettext: $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale @echo @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale." .PHONY: changes changes: $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes @echo @echo "The overview file is in $(BUILDDIR)/changes." .PHONY: linkcheck linkcheck: $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck @echo @echo "Link check complete; look for any errors in the above output " \ "or in $(BUILDDIR)/linkcheck/output.txt." .PHONY: doctest doctest: $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest @echo "Testing of doctests in the sources finished, look at the " \ "results in $(BUILDDIR)/doctest/output.txt." .PHONY: coverage coverage: $(SPHINXBUILD) -b coverage $(ALLSPHINXOPTS) $(BUILDDIR)/coverage @echo "Testing of coverage in the sources finished, look at the " \ "results in $(BUILDDIR)/coverage/python.txt." .PHONY: xml xml: $(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml @echo @echo "Build finished. The XML files are in $(BUILDDIR)/xml." .PHONY: pseudoxml pseudoxml: $(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml @echo @echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml." .PHONY: dummy dummy: $(SPHINXBUILD) -b dummy $(ALLSPHINXOPTS) $(BUILDDIR)/dummy @echo @echo "Build finished. Dummy builder generates no files." spelling: $(SPHINXBUILD) -b spelling $(ALLSPHINXOPTS) $(BUILDDIR)/spelling @echo @echo "Build finished." propcache-0.3.1/docs/changes.rst0000644000175000017500000000054714770661556020730 0ustar billchenchinabillchenchina.. _propcache_changes: ========= Changelog ========= .. only:: not is_release To be included in v\ |release| (if present) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ .. towncrier-draft-entries:: |release| [UNRELEASED DRAFT] Released versions ^^^^^^^^^^^^^^^^^ .. include:: ../CHANGES.rst :start-after: .. towncrier release notes start propcache-0.3.1/docs/_static/0000755000175000017500000000000014770661563020204 5ustar billchenchinabillchenchinapropcache-0.3.1/docs/_static/README.txt0000644000175000017500000000000014770661556021672 0ustar billchenchinabillchenchinapropcache-0.3.1/docs/spelling_wordlist.txt0000644000175000017500000000063714770661556023073 0ustar billchenchinabillchenchinaBluesky Bugfixes CPython Changelog Codecov Cython GPG IPv PRs PYX Towncrier Twitter UTF aiohttp backend boolean booleans bools changelog changelogs config de decodable dev dists downstreams facto glibc google hardcoded hostnames macOS mailto manylinux multi nightlies pre propcache rc reStructuredText reencoding requote requoting runtimes sdist src subclass subclasses subcomponent svetlov uncompiled unobvious v1 propcache-0.3.1/docs/contributing/0000755000175000017500000000000014770661563021265 5ustar billchenchinabillchenchinapropcache-0.3.1/docs/contributing/release_guide.rst0000644000175000017500000000761714770661556024631 0ustar billchenchinabillchenchina************* Release Guide ************* Welcome to the |project| Release Guide! This page contains information on how to release a new version of |project| using the automated Continuous Delivery pipeline. .. tip:: The intended audience for this document is maintainers and core contributors. Pre-release activities ====================== 1. Check if there are any open Pull Requests that could be desired in the upcoming release. If there are any — merge them. If some are incomplete, try to get them ready. Don't forget to review the enclosed change notes per our guidelines. 2. Visually inspect the draft section of the :ref:`Changelog` page. Make sure the content looks consistent, uses the same writing style, targets the end-users and adheres to our documented guidelines. Most of the changelog sections will typically use the past tense or another way to relay the effect of the changes for the users, since the previous release. It should not target core contributors as the information they are normally interested in is already present in the Git history. Update the changelog fragments if you see any problems with this changelog section. 3. Optionally, test the previously published nightlies, that are available through GitHub Actions CI/CD artifacts, locally. 4. If you are satisfied with the above, inspect the changelog section categories in the draft. Presence of the breaking changes or features will hint you what version number segment to bump for the release. 5. Update the hardcoded version string in :file:`propcache/__init__.py`. Generate a new changelog from the fragments, and commit it along with the fragments removal and the Python module changes. Use the following commands, don't prepend a leading-``v`` before the version number. Just use the raw version number as per :pep:`440`. .. code-block:: shell-session [dir:propcache] $ propcache/__init__.py [dir:propcache] $ python -m towncrier build \ -- --version 'VERSION_WITHOUT_LEADING_V' [dir:propcache] $ git commit -v CHANGES{.rst,/} propcache/__init__.py .. seealso:: :ref:`Adding change notes with your PRs` Writing beautiful changelogs for humans The release stage ================= 1. Tag the commit with version and changelog changes, created during the preparation stage. If possible, make it GPG-signed. Prepend a leading ``v`` before the version number for the tag name. Add an extra sentence describing the release contents, in a few words. .. code-block:: shell-session [dir:propcache] $ git tag \ -s 'VERSION_WITH_LEADING_V' \ -m 'VERSION_WITH_LEADING_V' \ -m 'This release does X and Y.' 2. Push that tag to the upstream repository, which ``origin`` is considered to be in the example below. .. code-block:: shell-session [dir:propcache] $ git push origin 'VERSION_WITH_LEADING_V' 3. You can open the `GitHub Actions CI/CD workflow page `_ in your web browser to monitor the progress. But generally, you don't need to babysit the CI. 4. Check that web page or your email inbox for the notification with an approval request. GitHub will send it when it reaches the final "publishing" job. 5. Approve the deployment and wait for the CD workflow to complete. 6. Verify that the following things got created: - a PyPI release - a Git tag - a GitHub Releases page 7. Tell everyone you released a new version of |project| :) Depending on your mental capacity and the burnout stage, you are encouraged to post the updates in issues asking for the next release, contributed PRs, Bluesky, Twitter etc. You can also call out prominent contributors and thank them! .. _GitHub Actions CI/CD workflow: https://github.com/aio-libs/propcache/actions/workflows/ci-cd.yml propcache-0.3.1/docs/contributing/guidelines.rst0000644000175000017500000000176614770661556024163 0ustar billchenchinabillchenchina----------------- Contributing docs ----------------- We use Sphinx_ to generate our docs website. You can trigger the process locally by executing: .. code-block:: shell-session $ make doc It is also integrated with `Read The Docs`_ that builds and publishes each commit to the main branch and generates live docs previews for each pull request. The sources of the Sphinx_ documents use reStructuredText as a de-facto standard. But in order to make contributing docs more beginner-friendly, we've integrated `MyST parser`_ allowing us to also accept new documents written in an extended version of Markdown that supports using Sphinx directives and roles. `Read the docs `_ to learn more on how to use it. .. _MyST docs: https://myst-parser.readthedocs.io/en/latest/using/intro.html#writing-myst-in-sphinx .. _MyST parser: https://pypi.org/project/myst-parser/ .. _Read The Docs: https://readthedocs.org .. _Sphinx: https://www.sphinx-doc.org .. include:: ../../CHANGES/README.rst propcache-0.3.1/docs/conf.py0000644000175000017500000003146614770661556020071 0ustar billchenchinabillchenchina#!/usr/bin/env python3 # # propcache documentation build configuration file, created by # sphinx-quickstart on Mon Aug 29 19:55:36 2016. # # This file is execfile()d with the current directory set to its # containing dir. # # Note that not all possible configuration values are present in this # autogenerated file. # # All configuration values have a default; values that are commented out # serve to show the default. # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. # # import os # import sys # sys.path.insert(0, os.path.abspath('.')) # -- General configuration ------------------------------------------------ # If your documentation needs a minimal Sphinx version, state it here. # # needs_sphinx = '1.0' import os import re from pathlib import Path PROJECT_ROOT_DIR = Path(__file__).parents[1].resolve() IS_RELEASE_ON_RTD = ( os.getenv("READTHEDOCS", "False") == "True" and os.environ["READTHEDOCS_VERSION_TYPE"] == "tag" ) if IS_RELEASE_ON_RTD: tags.add("is_release") _docs_path = Path(__file__).parent _version_path = _docs_path / "../src/propcache/__init__.py" with _version_path.open() as fp: try: _version_info = re.search( r"^__version__ = \"" r"(?P\d+)" r"\.(?P\d+)" r"\.(?P\d+)" r"(?P.*)?\"$", fp.read(), re.M, ).groupdict() except IndexError: raise RuntimeError("Unable to determine version.") # Add any Sphinx extension module names here, as strings. They can be # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. extensions = [ # stdlib-party extensions: "sphinx.ext.extlinks", "sphinx.ext.intersphinx", "sphinx.ext.coverage", "sphinx.ext.doctest", "sphinx.ext.viewcode", # Third-party extensions: "alabaster", "sphinxcontrib.towncrier.ext", # provides `towncrier-draft-entries` directive "myst_parser", # extended markdown; https://pypi.org/project/myst-parser/ ] try: import sphinxcontrib.spelling # noqa extensions.append("sphinxcontrib.spelling") except ImportError: pass intersphinx_mapping = { "python": ("https://docs.python.org/3", None), } # Add any paths that contain templates here, relative to this directory. # templates_path = ['_templates'] # The suffix(es) of source filenames. # You can specify multiple suffix as a list of string: # # source_suffix = ['.rst', '.md'] # The encoding of source files. # # source_encoding = 'utf-8-sig' # The master toctree document. master_doc = "index" # -- Project information ----------------------------------------------------- github_url = "https://github.com" github_repo_org = "aio-libs" github_repo_name = "propcache" github_repo_slug = f"{github_repo_org}/{github_repo_name}" github_repo_url = f"{github_url}/{github_repo_slug}" github_sponsors_url = f"{github_url}/sponsors" project = github_repo_name copyright = f"2016, Andrew Svetlov, {project} contributors and aio-libs team" author = "Andrew Svetlov and aio-libs team" # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the # built documents. # # The short X.Y version. version = "{major}.{minor}".format(**_version_info) # The full version, including alpha/beta/rc tags. release = "{major}.{minor}.{patch}-{tag}".format(**_version_info) rst_epilog = f""" .. |project| replace:: {project} """ # pylint: disable=invalid-name # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. # # This is also used if you do content translation via gettext catalogs. # Usually you set "language" from the command line for these cases. language = "en" # There are two options for replacing |today|: either, you set today to some # non-false value, then it is used: # # today = '' # # Else, today_fmt is used as the format for a strftime call. # # today_fmt = '%B %d, %Y' # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. # This patterns also effect to html_static_path and html_extra_path exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"] # The reST default role (used for this markup: `text`) to use for all # documents. # # default_role = None # If true, '()' will be appended to :func: etc. cross-reference text. # # add_function_parentheses = True # If true, the current module name will be prepended to all description # unit titles (such as .. function::). # # add_module_names = True # If true, sectionauthor and moduleauthor directives will be shown in the # output. They are ignored by default. # # show_authors = False # The name of the Pygments (syntax highlighting) style to use. pygments_style = "sphinx" # A list of ignored prefixes for module index sorting. # modindex_common_prefix = [] # If true, keep warnings as "system message" paragraphs in the built documents. # keep_warnings = False # If true, `todo` and `todoList` produce output, else they produce nothing. todo_include_todos = False # -- Extension configuration ------------------------------------------------- # -- Options for extlinks extension --------------------------------------- extlinks = { "issue": (f"{github_repo_url}/issues/%s", "#%s"), "pr": (f"{github_repo_url}/pull/%s", "PR #%s"), "commit": (f"{github_repo_url}/commit/%s", "%s"), "gh": (f"{github_url}/%s", "GitHub: %s"), "user": (f"{github_sponsors_url}/%s", "@%s"), } # -- Options for HTML output ---------------------------------------------- # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. # html_theme = "alabaster" html_theme_options = { "description": "propcache", "github_user": "aio-libs", "github_repo": "propcache", "github_button": True, "github_type": "star", "github_banner": True, "codecov_button": True, "pre_bg": "#FFF6E5", "note_bg": "#E5ECD1", "note_border": "#BFCF8C", "body_text": "#482C0A", "sidebar_text": "#49443E", "sidebar_header": "#4B4032", "sidebar_collapse": False, } # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the # documentation. # # html_theme_options = {} # Add any paths that contain custom themes here, relative to this directory. # html_theme_path = [] # The name for this set of Sphinx documents. # " v documentation" by default. # # html_title = 'propcache v0.1.0' # A shorter title for the navigation bar. Default is the same as html_title. # # html_short_title = None # The name of an image file (relative to this directory) to place at the top # of the sidebar. # # html_logo = None # The name of an image file (relative to this directory) to use as a favicon of # the docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 # pixels large. # # html_favicon = None # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". html_static_path = ["_static"] # Add any extra paths that contain custom files (such as robots.txt or # .htaccess) here, relative to this directory. These files are copied # directly to the root of the documentation. # # html_extra_path = [] # If not None, a 'Last updated on:' timestamp is inserted at every page # bottom, using the given strftime format. # The empty string is equivalent to '%b %d, %Y'. # # html_last_updated_fmt = None # If true, SmartyPants will be used to convert quotes and dashes to # typographically correct entities. # # html_use_smartypants = True # Custom sidebar templates, maps document names to template names. # # html_sidebars = {} html_sidebars = { "**": [ "about.html", "navigation.html", "searchbox.html", ] } # Additional templates that should be rendered to pages, maps page names to # template names. # # html_additional_pages = {} # If false, no module index is generated. # # html_domain_indices = True # If false, no index is generated. # # html_use_index = True # If true, the index is split into individual pages for each letter. # # html_split_index = False # If true, links to the reST sources are added to the pages. # # html_show_sourcelink = True # If true, "Created using Sphinx" is shown in the HTML footer. Default is True. # # html_show_sphinx = True # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. # # html_show_copyright = True # If true, an OpenSearch description file will be output, and all pages will # contain a tag referring to it. The value of this option must be the # base URL from which the finished HTML is served. # # html_use_opensearch = '' # This is the file name suffix for HTML files (e.g. ".xhtml"). # html_file_suffix = None # Language to be used for generating the HTML full-text search index. # Sphinx supports the following languages: # 'da', 'de', 'en', 'es', 'fi', 'fr', 'h', 'it', 'ja' # 'nl', 'no', 'pt', 'ro', 'r', 'sv', 'tr', 'zh' # # html_search_language = 'en' # A dictionary with options for the search language support, empty by default. # 'ja' uses this config value. # 'zh' user can custom change `jieba` dictionary path. # # html_search_options = {'type': 'default'} # The name of a javascript file (relative to the configuration directory) that # implements a search results scorer. If empty, the default will be used. # # html_search_scorer = 'scorer.js' # Output file base name for HTML help builder. htmlhelp_basename = "propcachedoc" # -- Options for LaTeX output --------------------------------------------- latex_elements = { # The paper size ('letterpaper' or 'a4paper'). # # 'papersize': 'letterpaper', # The font size ('10pt', '11pt' or '12pt'). # # 'pointsize': '10pt', # Additional stuff for the LaTeX preamble. # # 'preamble': '', # Latex figure (float) alignment # # 'figure_align': 'htbp', } # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, # author, documentclass [howto, manual, or own class]). latex_documents = [ ( master_doc, "propcache.tex", "propcache Documentation", "Andrew Svetlov", "manual", ), ] # The name of an image file (relative to this directory) to place at the top of # the title page. # # latex_logo = None # For "manual" documents, if this is true, then toplevel headings are parts, # not chapters. # # latex_use_parts = False # If true, show page references after internal links. # # latex_show_pagerefs = False # If true, show URL addresses after external links. # # latex_show_urls = False # Documents to append as an appendix to all manuals. # # latex_appendices = [] # It false, will not define \strong, \code, itleref, \crossref ... but only # \sphinxstrong, ..., \sphinxtitleref, ... To help avoid clash with user added # packages. # # latex_keep_old_macro_names = True # If false, no module index is generated. # # latex_domain_indices = True # -- Options for manual page output --------------------------------------- # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [(master_doc, "propcache", "propcache Documentation", [author], 1)] # If true, show URL addresses after external links. # # man_show_urls = False # -- Options for Texinfo output ------------------------------------------- # Grouping the document tree into Texinfo files. List of tuples # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ ( master_doc, "propcache", "propcache Documentation", author, "propcache", "One line description of project.", "Miscellaneous", ), ] # Documents to append as an appendix to all manuals. # # texinfo_appendices = [] # If false, no module index is generated. # # texinfo_domain_indices = True # How to display URL addresses: 'footnote', 'no', or 'inline'. # # texinfo_show_urls = 'footnote' # If true, do not generate a @detailmenu in the "Top" node's menu. # # texinfo_no_detailmenu = False default_role = "any" nitpicky = True nitpick_ignore = [ ("envvar", "TMPDIR"), ] # -- Options for towncrier_draft extension ----------------------------------- towncrier_draft_autoversion_mode = "draft" # or: 'sphinx-version', 'sphinx-release' towncrier_draft_include_empty = True towncrier_draft_working_directory = PROJECT_ROOT_DIR # Not yet supported: towncrier_draft_config_path = 'pyproject.toml' # relative to cwd propcache-0.3.1/docs/make.bat0000644000175000017500000001707214770661556020174 0ustar billchenchinabillchenchina@ECHO OFF REM Command file for Sphinx documentation if "%SPHINXBUILD%" == "" ( set SPHINXBUILD=sphinx-build ) set BUILDDIR=_build set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% . set I18NSPHINXOPTS=%SPHINXOPTS% . if NOT "%PAPER%" == "" ( set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS% set I18NSPHINXOPTS=-D latex_paper_size=%PAPER% %I18NSPHINXOPTS% ) if "%1" == "" goto help if "%1" == "help" ( :help echo.Please use `make ^` where ^ is one of echo. html to make standalone HTML files echo. dirhtml to make HTML files named index.html in directories echo. singlehtml to make a single large HTML file echo. pickle to make pickle files echo. json to make JSON files echo. htmlhelp to make HTML files and a HTML help project echo. qthelp to make HTML files and a qthelp project echo. devhelp to make HTML files and a Devhelp project echo. epub to make an epub echo. epub3 to make an epub3 echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter echo. text to make text files echo. man to make manual pages echo. texinfo to make Texinfo files echo. gettext to make PO message catalogs echo. changes to make an overview over all changed/added/deprecated items echo. xml to make Docutils-native XML files echo. pseudoxml to make pseudoxml-XML files for display purposes echo. linkcheck to check all external links for integrity echo. doctest to run all doctests embedded in the documentation if enabled echo. coverage to run coverage check of the documentation if enabled echo. dummy to check syntax errors of document sources goto end ) if "%1" == "clean" ( for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i del /q /s %BUILDDIR%\* goto end ) REM Check if sphinx-build is available and fallback to Python version if any %SPHINXBUILD% 1>NUL 2>NUL if errorlevel 9009 goto sphinx_python goto sphinx_ok :sphinx_python set SPHINXBUILD=python -m sphinx.__init__ %SPHINXBUILD% 2> nul if errorlevel 9009 ( echo. echo.The 'sphinx-build' command was not found. Make sure you have Sphinx echo.installed, then set the SPHINXBUILD environment variable to point echo.to the full path of the 'sphinx-build' executable. Alternatively you echo.may add the Sphinx directory to PATH. echo. echo.If you don't have Sphinx installed, grab it from echo.http://sphinx-doc.org/ exit /b 1 ) :sphinx_ok if "%1" == "html" ( %SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html if errorlevel 1 exit /b 1 echo. echo.Build finished. The HTML pages are in %BUILDDIR%/html. goto end ) if "%1" == "dirhtml" ( %SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml if errorlevel 1 exit /b 1 echo. echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml. goto end ) if "%1" == "singlehtml" ( %SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml if errorlevel 1 exit /b 1 echo. echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml. goto end ) if "%1" == "pickle" ( %SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle if errorlevel 1 exit /b 1 echo. echo.Build finished; now you can process the pickle files. goto end ) if "%1" == "json" ( %SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json if errorlevel 1 exit /b 1 echo. echo.Build finished; now you can process the JSON files. goto end ) if "%1" == "htmlhelp" ( %SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp if errorlevel 1 exit /b 1 echo. echo.Build finished; now you can run HTML Help Workshop with the ^ .hhp project file in %BUILDDIR%/htmlhelp. goto end ) if "%1" == "qthelp" ( %SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp if errorlevel 1 exit /b 1 echo. echo.Build finished; now you can run "qcollectiongenerator" with the ^ .qhcp project file in %BUILDDIR%/qthelp, like this: echo.^> qcollectiongenerator %BUILDDIR%\qthelp\propcache.qhcp echo.To view the help file: echo.^> assistant -collectionFile %BUILDDIR%\qthelp\propcache.ghc goto end ) if "%1" == "devhelp" ( %SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp if errorlevel 1 exit /b 1 echo. echo.Build finished. goto end ) if "%1" == "epub" ( %SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub if errorlevel 1 exit /b 1 echo. echo.Build finished. The epub file is in %BUILDDIR%/epub. goto end ) if "%1" == "epub3" ( %SPHINXBUILD% -b epub3 %ALLSPHINXOPTS% %BUILDDIR%/epub3 if errorlevel 1 exit /b 1 echo. echo.Build finished. The epub3 file is in %BUILDDIR%/epub3. goto end ) if "%1" == "latex" ( %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex if errorlevel 1 exit /b 1 echo. echo.Build finished; the LaTeX files are in %BUILDDIR%/latex. goto end ) if "%1" == "latexpdf" ( %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex cd %BUILDDIR%/latex make all-pdf cd %~dp0 echo. echo.Build finished; the PDF files are in %BUILDDIR%/latex. goto end ) if "%1" == "latexpdfja" ( %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex cd %BUILDDIR%/latex make all-pdf-ja cd %~dp0 echo. echo.Build finished; the PDF files are in %BUILDDIR%/latex. goto end ) if "%1" == "text" ( %SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text if errorlevel 1 exit /b 1 echo. echo.Build finished. The text files are in %BUILDDIR%/text. goto end ) if "%1" == "man" ( %SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man if errorlevel 1 exit /b 1 echo. echo.Build finished. The manual pages are in %BUILDDIR%/man. goto end ) if "%1" == "texinfo" ( %SPHINXBUILD% -b texinfo %ALLSPHINXOPTS% %BUILDDIR%/texinfo if errorlevel 1 exit /b 1 echo. echo.Build finished. The Texinfo files are in %BUILDDIR%/texinfo. goto end ) if "%1" == "gettext" ( %SPHINXBUILD% -b gettext %I18NSPHINXOPTS% %BUILDDIR%/locale if errorlevel 1 exit /b 1 echo. echo.Build finished. The message catalogs are in %BUILDDIR%/locale. goto end ) if "%1" == "changes" ( %SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes if errorlevel 1 exit /b 1 echo. echo.The overview file is in %BUILDDIR%/changes. goto end ) if "%1" == "linkcheck" ( %SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck if errorlevel 1 exit /b 1 echo. echo.Link check complete; look for any errors in the above output ^ or in %BUILDDIR%/linkcheck/output.txt. goto end ) if "%1" == "doctest" ( %SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest if errorlevel 1 exit /b 1 echo. echo.Testing of doctests in the sources finished, look at the ^ results in %BUILDDIR%/doctest/output.txt. goto end ) if "%1" == "coverage" ( %SPHINXBUILD% -b coverage %ALLSPHINXOPTS% %BUILDDIR%/coverage if errorlevel 1 exit /b 1 echo. echo.Testing of coverage in the sources finished, look at the ^ results in %BUILDDIR%/coverage/python.txt. goto end ) if "%1" == "xml" ( %SPHINXBUILD% -b xml %ALLSPHINXOPTS% %BUILDDIR%/xml if errorlevel 1 exit /b 1 echo. echo.Build finished. The XML files are in %BUILDDIR%/xml. goto end ) if "%1" == "pseudoxml" ( %SPHINXBUILD% -b pseudoxml %ALLSPHINXOPTS% %BUILDDIR%/pseudoxml if errorlevel 1 exit /b 1 echo. echo.Build finished. The pseudo-XML files are in %BUILDDIR%/pseudoxml. goto end ) if "%1" == "dummy" ( %SPHINXBUILD% -b dummy %ALLSPHINXOPTS% %BUILDDIR%/dummy if errorlevel 1 exit /b 1 echo. echo.Build finished. Dummy builder generates no files. goto end ) :end propcache-0.3.1/docs/index.rst0000644000175000017500000000321414770661556020421 0ustar billchenchinabillchenchina.. propcache documentation master file, created by sphinx-quickstart on Mon Aug 29 19:55:36 2016. You can adapt this file completely to your liking, but it should at least contain the root `toctree` directive. propcache ========= The module provides accelerated versions of ``cached_property`` Introduction ------------ Usage ----- The API is designed to be nearly identical to the built-in ``cached_property`` class, except for the additional ``under_cached_property`` class which uses ``self._cache`` instead of ``self.__dict__`` to store the cached values and prevents ``__set__`` from being called. API documentation ----------------- Open :ref:`propcache-api` for reading full list of available methods. Source code ----------- The project is hosted on GitHub_ Please file an issue on the `bug tracker `_ if you have found a bug or have some suggestion in order to improve the library. Discussion list --------------- *aio-libs* google group: https://groups.google.com/forum/#!forum/aio-libs Feel free to post your questions and ideas here. Authors and License ------------------- The ``propcache`` package is derived from ``yarl`` which is written by Andrew Svetlov. It's *Apache 2* licensed and freely available. Contents: .. toctree:: :maxdepth: 2 api .. toctree:: :caption: What's new changes .. toctree:: :caption: Contributing contributing/guidelines .. toctree:: :caption: Maintenance contributing/release_guide Indices and tables ================== * :ref:`genindex` * :ref:`modindex` * :ref:`search` .. _GitHub: https://github.com/aio-libs/propcache propcache-0.3.1/docs/api.rst0000644000175000017500000000306614770661556020070 0ustar billchenchinabillchenchina.. _propcache-api: ========= Reference ========= .. module:: propcache.api cached_property =============== .. decorator:: cached_property(func) This decorator functions exactly the same as the standard library :func:`cached_property` decorator, but it's available in the :mod:`propcache.api` module along with an accelerated Cython version. As with the standard library version, the cached value is stored in the instance's ``__dict__`` dictionary. To clear a cached value, you can use the ``del`` operator on the instance's attribute or call ``instance.__dict__.pop('attribute_name', None)``. under_cached_property ===================== .. decorator:: under_cached_property(func) Transform a method of a class into a property whose value is computed only once and then cached as a private attribute. Similar to the :func:`cached_property` decorator, but the cached value is stored in the instance's ``_cache`` dictionary instead of ``__dict__``. Example:: from propcache.api import under_cached_property class MyClass: def __init__(self, data: List[float]): self._data = data self._cache = {} @cached_property def calculated_data(self): return expensive_operation(self._data) def clear_cache(self): self._cache.clear() instance = MyClass([1.0, 2.0, 3.0]) print(instance.calculated_data) # expensive operation instance.clear_cache() print(instance.calculated_data) # expensive operation propcache-0.3.1/CHANGES/0000755000175000017500000000000014770661563016676 5ustar billchenchinabillchenchinapropcache-0.3.1/CHANGES/.TEMPLATE.rst0000644000175000017500000000467514770661556020737 0ustar billchenchinabillchenchina{# TOWNCRIER TEMPLATE #} *({{ versiondata.date }})* {% for section, _ in sections.items() %} {% set underline = underlines[0] %}{% if section %}{{section}} {{ underline * section|length }}{% set underline = underlines[1] %} {% endif %} {% if sections[section] %} {% for category, val in definitions.items() if category in sections[section]%} {{ definitions[category]['name'] }} {{ underline * definitions[category]['name']|length }} {% if definitions[category]['showcontent'] %} {% for text, change_note_refs in sections[section][category].items() %} - {{ text }} {{- '\n' * 2 -}} {#- NOTE: Replacing 'e' with 'f' is a hack that prevents Jinja's `int` NOTE: filter internal implementation from treating the input as an NOTE: infinite float when it looks like a scientific notation (with a NOTE: single 'e' char in between digits), raising an `OverflowError`, NOTE: subsequently. 'f' is still a hex letter so it won't affect the NOTE: check for whether it's a (short or long) commit hash or not. Ref: https://github.com/pallets/jinja/issues/1921 -#} {%- set pr_issue_numbers = change_note_refs | map('lower') | map('replace', 'e', 'f') | map('int', default=None) | select('integer') | map('string') | list -%} {%- set arbitrary_refs = [] -%} {%- set commit_refs = [] -%} {%- with -%} {%- set commit_ref_candidates = change_note_refs | reject('in', pr_issue_numbers) -%} {%- for cf in commit_ref_candidates -%} {%- if cf | length in (7, 8, 40) and cf | int(default=None, base=16) is not none -%} {%- set _ = commit_refs.append(cf) -%} {%- else -%} {%- set _ = arbitrary_refs.append(cf) -%} {%- endif -%} {%- endfor -%} {%- endwith -%} {% if pr_issue_numbers %} *Related issues and pull requests on GitHub:* :issue:`{{ pr_issue_numbers | join('`, :issue:`') }}`. {{- '\n' * 2 -}} {%- endif -%} {% if commit_refs %} *Related commits on GitHub:* :commit:`{{ commit_refs | join('`, :commit:`') }}`. {{- '\n' * 2 -}} {%- endif -%} {% if arbitrary_refs %} *Unlinked references:* {{ arbitrary_refs | join(', ') }}. {{- '\n' * 2 -}} {%- endif -%} {% endfor %} {% else %} - {{ sections[section][category]['']|join(', ') }} {% endif %} {% if sections[section][category]|length == 0 %} No significant changes. {% else %} {% endif %} {% endfor %} {% else %} No significant changes. {% endif %} {% endfor %} ---- {{ '\n' * 2 }} propcache-0.3.1/CHANGES/README.rst0000644000175000017500000001051414770661556020370 0ustar billchenchinabillchenchina.. _Adding change notes with your PRs: Adding change notes with your PRs ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ It is very important to maintain a log for news of how updating to the new version of the software will affect end-users. This is why we enforce collection of the change fragment files in pull requests as per `Towncrier philosophy`_. The idea is that when somebody makes a change, they must record the bits that would affect end-users only including information that would be useful to them. Then, when the maintainers publish a new release, they'll automatically use these records to compose a change log for the respective version. It is important to understand that including unnecessary low-level implementation related details generates noise that is not particularly useful to the end-users most of the time. And so such details should be recorded in the Git history rather than a changelog. Alright! So how to add a news fragment? ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ``propcache`` uses `towncrier `_ for changelog management. To submit a change note about your PR, add a text file into the ``CHANGES/`` folder. It should contain an explanation of what applying this PR will change in the way end-users interact with the project. One sentence is usually enough but feel free to add as many details as you feel necessary for the users to understand what it means. **Use the past tense** for the text in your fragment because, combined with others, it will be a part of the "news digest" telling the readers **what changed** in a specific version of the library *since the previous version*. You should also use reStructuredText syntax for highlighting code (inline or block), linking parts of the docs or external sites. If you wish to sign your change, feel free to add ``-- by :user:`github-username``` at the end (replace ``github-username`` with your own!). Finally, name your file following the convention that Towncrier understands: it should start with the number of an issue or a PR followed by a dot, then add a patch type, like ``feature``, ``doc``, ``contrib`` etc., and add ``.rst`` as a suffix. If you need to add more than one fragment, you may add an optional sequence number (delimited with another period) between the type and the suffix. In general the name will follow ``..rst`` pattern, where the categories are: - ``bugfix``: A bug fix for something we deemed an improper undesired behavior that got corrected in the release to match pre-agreed expectations. - ``feature``: A new behavior, public APIs. That sort of stuff. - ``deprecation``: A declaration of future API removals and breaking changes in behavior. - ``breaking``: When something public gets removed in a breaking way. Could be deprecated in an earlier release. - ``doc``: Notable updates to the documentation structure or build process. - ``packaging``: Notes for downstreams about unobvious side effects and tooling. Changes in the test invocation considerations and runtime assumptions. - ``contrib``: Stuff that affects the contributor experience. e.g. Running tests, building the docs, setting up the development environment. - ``misc``: Changes that are hard to assign to any of the above categories. A pull request may have more than one of these components, for example a code change may introduce a new feature that deprecates an old feature, in which case two fragments should be added. It is not necessary to make a separate documentation fragment for documentation changes accompanying the relevant code changes. Examples for adding changelog entries to your Pull Requests ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File :file:`CHANGES/603.removal.1.rst`: .. code-block:: rst Dropped Python 3.5 support; Python 3.6 is the minimal supported Python version -- by :user:`webknjaz`. File :file:`CHANGES/550.bugfix.rst`: .. code-block:: rst Started shipping Windows wheels for the x86 architecture -- by :user:`Dreamsorcerer`. File :file:`CHANGES/553.feature.rst`: .. code-block:: rst Added support for ``GenericAliases`` (``MultiDict[str]``) under Python 3.9 and higher -- by :user:`mjpieters`. .. tip:: See :file:`towncrier.toml` for all available categories (``tool.towncrier.type``). .. _Towncrier philosophy: https://towncrier.readthedocs.io/en/stable/#philosophy propcache-0.3.1/CHANGES/.gitignore0000644000175000017500000000057614770661556020700 0ustar billchenchinabillchenchina* !.TEMPLATE.rst !.gitignore !README.rst !*.bugfix !*.bugfix.rst !*.bugfix.*.rst !*.breaking !*.breaking.rst !*.breaking.*.rst !*.contrib !*.contrib.rst !*.contrib.*.rst !*.deprecation !*.deprecation.rst !*.deprecation.*.rst !*.doc !*.doc.rst !*.doc.*.rst !*.feature !*.feature.rst !*.feature.*.rst !*.misc !*.misc.rst !*.misc.*.rst !*.packaging !*.packaging.rst !*.packaging.*.rst propcache-0.3.1/LICENSE0000644000175000017500000002613614770661556016645 0ustar billchenchinabillchenchina Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "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. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "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. "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). "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. "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." "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. 2. Grant of Copyright License. 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. 3. Grant of Patent License. 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. 4. Redistribution. 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: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) 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 (d) 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. 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. 5. Submission of Contributions. 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. 6. Trademarks. 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. 7. Disclaimer of Warranty. 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. 8. Limitation of Liability. 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. 9. Accepting Warranty or Additional Liability. 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. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. propcache-0.3.1/PKG-INFO0000644000175000017500000002476414770661563016740 0ustar billchenchinabillchenchinaMetadata-Version: 2.4 Name: propcache Version: 0.3.1 Summary: Accelerated property cache Home-page: https://github.com/aio-libs/propcache Author: Andrew Svetlov Author-email: andrew.svetlov@gmail.com Maintainer: aiohttp team Maintainer-email: team@aiohttp.org License: Apache-2.0 Project-URL: Chat: Matrix, https://matrix.to/#/#aio-libs:matrix.org Project-URL: Chat: Matrix Space, https://matrix.to/#/#aio-libs-space:matrix.org Project-URL: CI: GitHub Workflows, https://github.com/aio-libs/propcache/actions?query=branch:master Project-URL: Code of Conduct, https://github.com/aio-libs/.github/blob/master/CODE_OF_CONDUCT.md Project-URL: Coverage: codecov, https://codecov.io/github/aio-libs/propcache Project-URL: Docs: Changelog, https://propcache.readthedocs.io/en/latest/changes/ Project-URL: Docs: RTD, https://propcache.readthedocs.io Project-URL: GitHub: issues, https://github.com/aio-libs/propcache/issues Project-URL: GitHub: repo, https://github.com/aio-libs/propcache Keywords: cython,cext,propcache Classifier: Development Status :: 5 - Production/Stable Classifier: Intended Audience :: Developers Classifier: License :: OSI Approved :: Apache Software License Classifier: Programming Language :: Cython Classifier: Programming Language :: Python Classifier: Programming Language :: Python :: 3 Classifier: Programming Language :: Python :: 3.9 Classifier: Programming Language :: Python :: 3.10 Classifier: Programming Language :: Python :: 3.11 Classifier: Programming Language :: Python :: 3.12 Classifier: Programming Language :: Python :: 3.13 Classifier: Topic :: Internet :: WWW/HTTP Classifier: Topic :: Software Development :: Libraries :: Python Modules Requires-Python: >=3.9 Description-Content-Type: text/x-rst License-File: LICENSE License-File: NOTICE Dynamic: license-file propcache ========= The module provides a fast implementation of cached properties for Python 3.9+. .. image:: https://github.com/aio-libs/propcache/actions/workflows/ci-cd.yml/badge.svg :target: https://github.com/aio-libs/propcache/actions?query=workflow%3ACI :align: right .. image:: https://codecov.io/gh/aio-libs/propcache/branch/master/graph/badge.svg :target: https://codecov.io/gh/aio-libs/propcache .. image:: https://badge.fury.io/py/propcache.svg :target: https://badge.fury.io/py/propcache .. image:: https://readthedocs.org/projects/propcache/badge/?version=latest :target: https://propcache.readthedocs.io .. image:: https://img.shields.io/pypi/pyversions/propcache.svg :target: https://pypi.python.org/pypi/propcache .. image:: https://img.shields.io/matrix/aio-libs:matrix.org?label=Discuss%20on%20Matrix%20at%20%23aio-libs%3Amatrix.org&logo=matrix&server_fqdn=matrix.org&style=flat :target: https://matrix.to/#/%23aio-libs:matrix.org :alt: Matrix Room — #aio-libs:matrix.org .. image:: https://img.shields.io/matrix/aio-libs-space:matrix.org?label=Discuss%20on%20Matrix%20at%20%23aio-libs-space%3Amatrix.org&logo=matrix&server_fqdn=matrix.org&style=flat :target: https://matrix.to/#/%23aio-libs-space:matrix.org :alt: Matrix Space — #aio-libs-space:matrix.org Introduction ------------ The API is designed to be nearly identical to the built-in ``functools.cached_property`` class, except for the additional ``under_cached_property`` class which uses ``self._cache`` instead of ``self.__dict__`` to store the cached values and prevents ``__set__`` from being called. For full documentation please read https://propcache.readthedocs.io. Installation ------------ :: $ pip install propcache The library is Python 3 only! PyPI contains binary wheels for Linux, Windows and MacOS. If you want to install ``propcache`` on another operating system where wheels are not provided, the the tarball will be used to compile the library from the source code. It requires a C compiler and and Python headers installed. To skip the compilation you must explicitly opt-in by using a PEP 517 configuration setting ``pure-python``, or setting the ``PROPCACHE_NO_EXTENSIONS`` environment variable to a non-empty value, e.g.: .. code-block:: console $ pip install propcache --config-settings=pure-python=false Please note that the pure-Python (uncompiled) version is much slower. However, PyPy always uses a pure-Python implementation, and, as such, it is unaffected by this variable. API documentation ------------------ The documentation is located at https://propcache.readthedocs.io. Source code ----------- The project is hosted on GitHub_ Please file an issue on the `bug tracker `_ if you have found a bug or have some suggestion in order to improve the library. Discussion list --------------- *aio-libs* google group: https://groups.google.com/forum/#!forum/aio-libs Feel free to post your questions and ideas here. Authors and License ------------------- The ``propcache`` package is derived from ``yarl`` which is written by Andrew Svetlov. It's *Apache 2* licensed and freely available. .. _GitHub: https://github.com/aio-libs/propcache ========= Changelog ========= .. You should *NOT* be adding new change log entries to this file, this file is managed by towncrier. You *may* edit previous change logs to fix problems like typo corrections or such. To add a new change log entry, please see https://pip.pypa.io/en/latest/development/#adding-a-news-entry we named the news folder "changes". WARNING: Don't drop the next directive! .. towncrier release notes start 0.3.1 ===== *(2025-03-25)* Bug fixes --------- - Improved typing annotations, fixing some type errors under correct usage and improving typing robustness generally -- by `@Dreamsorcerer `__. *Related issues and pull requests on GitHub:* `#103 `__. ---- 0.3.0 ===== *(2025-02-20)* Features -------- - Implemented support for the free-threaded build of CPython 3.13 -- by `@lysnikolaou `__. *Related issues and pull requests on GitHub:* `#84 `__. Packaging updates and notes for downstreams ------------------------------------------- - Started building wheels for the free-threaded build of CPython 3.13 -- by `@lysnikolaou `__. *Related issues and pull requests on GitHub:* `#84 `__. Contributor-facing changes -------------------------- - GitHub Actions CI/CD is now configured to manage caching pip-ecosystem dependencies using `re-actors/cache-python-deps`_ -- an action by `@webknjaz `__ that takes into account ABI stability and the exact version of Python runtime. .. _`re-actors/cache-python-deps`: https://github.com/marketplace/actions/cache-python-deps *Related issues and pull requests on GitHub:* `#93 `__. ---- 0.2.1 ===== *(2024-12-01)* Bug fixes --------- - Stopped implicitly allowing the use of Cython pre-release versions when building the distribution package -- by `@ajsanchezsanz `__ and `@markgreene74 `__. *Related commits on GitHub:* `64df0a6 `__. - Fixed ``wrapped`` and ``func`` not being accessible in the Cython versions of ``propcache.api.cached_property`` and ``propcache.api.under_cached_property`` decorators -- by `@bdraco `__. *Related issues and pull requests on GitHub:* `#72 `__. Removals and backward incompatible breaking changes --------------------------------------------------- - Removed support for Python 3.8 as it has reached end of life -- by `@bdraco `__. *Related issues and pull requests on GitHub:* `#57 `__. Packaging updates and notes for downstreams ------------------------------------------- - Stopped implicitly allowing the use of Cython pre-release versions when building the distribution package -- by `@ajsanchezsanz `__ and `@markgreene74 `__. *Related commits on GitHub:* `64df0a6 `__. ---- 0.2.0 ===== *(2024-10-07)* Bug fixes --------- - Fixed loading the C-extensions on Python 3.8 -- by `@bdraco `__. *Related issues and pull requests on GitHub:* `#26 `__. Features -------- - Improved typing for the ``propcache.api.under_cached_property`` decorator -- by `@bdraco `__. *Related issues and pull requests on GitHub:* `#38 `__. Improved documentation ---------------------- - Added API documentation for the ``propcache.api.cached_property`` and ``propcache.api.under_cached_property`` decorators -- by `@bdraco `__. *Related issues and pull requests on GitHub:* `#16 `__. Packaging updates and notes for downstreams ------------------------------------------- - Moved ``propcache.api.under_cached_property`` and ``propcache.api.cached_property`` to `propcache.api` -- by `@bdraco `__. Both decorators remain importable from the top-level package, however importing from `propcache.api` is now the recommended way to use them. *Related issues and pull requests on GitHub:* `#19 `__, `#24 `__, `#32 `__. - Converted project to use a src layout -- by `@bdraco `__. *Related issues and pull requests on GitHub:* `#22 `__, `#29 `__, `#37 `__. ---- 0.1.0 ===== *(2024-10-03)* Features -------- - Added ``armv7l`` wheels -- by `@bdraco `__. *Related issues and pull requests on GitHub:* `#5 `__. ---- 0.0.0 ===== *(2024-10-02)* - Initial release. propcache-0.3.1/README.rst0000644000175000017500000000630714770661556017325 0ustar billchenchinabillchenchinapropcache ========= The module provides a fast implementation of cached properties for Python 3.9+. .. image:: https://github.com/aio-libs/propcache/actions/workflows/ci-cd.yml/badge.svg :target: https://github.com/aio-libs/propcache/actions?query=workflow%3ACI :align: right .. image:: https://codecov.io/gh/aio-libs/propcache/branch/master/graph/badge.svg :target: https://codecov.io/gh/aio-libs/propcache .. image:: https://badge.fury.io/py/propcache.svg :target: https://badge.fury.io/py/propcache .. image:: https://readthedocs.org/projects/propcache/badge/?version=latest :target: https://propcache.readthedocs.io .. image:: https://img.shields.io/pypi/pyversions/propcache.svg :target: https://pypi.python.org/pypi/propcache .. image:: https://img.shields.io/matrix/aio-libs:matrix.org?label=Discuss%20on%20Matrix%20at%20%23aio-libs%3Amatrix.org&logo=matrix&server_fqdn=matrix.org&style=flat :target: https://matrix.to/#/%23aio-libs:matrix.org :alt: Matrix Room — #aio-libs:matrix.org .. image:: https://img.shields.io/matrix/aio-libs-space:matrix.org?label=Discuss%20on%20Matrix%20at%20%23aio-libs-space%3Amatrix.org&logo=matrix&server_fqdn=matrix.org&style=flat :target: https://matrix.to/#/%23aio-libs-space:matrix.org :alt: Matrix Space — #aio-libs-space:matrix.org Introduction ------------ The API is designed to be nearly identical to the built-in ``functools.cached_property`` class, except for the additional ``under_cached_property`` class which uses ``self._cache`` instead of ``self.__dict__`` to store the cached values and prevents ``__set__`` from being called. For full documentation please read https://propcache.readthedocs.io. Installation ------------ :: $ pip install propcache The library is Python 3 only! PyPI contains binary wheels for Linux, Windows and MacOS. If you want to install ``propcache`` on another operating system where wheels are not provided, the the tarball will be used to compile the library from the source code. It requires a C compiler and and Python headers installed. To skip the compilation you must explicitly opt-in by using a PEP 517 configuration setting ``pure-python``, or setting the ``PROPCACHE_NO_EXTENSIONS`` environment variable to a non-empty value, e.g.: .. code-block:: console $ pip install propcache --config-settings=pure-python=false Please note that the pure-Python (uncompiled) version is much slower. However, PyPy always uses a pure-Python implementation, and, as such, it is unaffected by this variable. API documentation ------------------ The documentation is located at https://propcache.readthedocs.io. Source code ----------- The project is hosted on GitHub_ Please file an issue on the `bug tracker `_ if you have found a bug or have some suggestion in order to improve the library. Discussion list --------------- *aio-libs* google group: https://groups.google.com/forum/#!forum/aio-libs Feel free to post your questions and ideas here. Authors and License ------------------- The ``propcache`` package is derived from ``yarl`` which is written by Andrew Svetlov. It's *Apache 2* licensed and freely available. .. _GitHub: https://github.com/aio-libs/propcache propcache-0.3.1/CHANGES.rst0000644000175000017500000001023114770661556017427 0ustar billchenchinabillchenchina========= Changelog ========= .. You should *NOT* be adding new change log entries to this file, this file is managed by towncrier. You *may* edit previous change logs to fix problems like typo corrections or such. To add a new change log entry, please see https://pip.pypa.io/en/latest/development/#adding-a-news-entry we named the news folder "changes". WARNING: Don't drop the next directive! .. towncrier release notes start 0.3.1 ===== *(2025-03-25)* Bug fixes --------- - Improved typing annotations, fixing some type errors under correct usage and improving typing robustness generally -- by :user:`Dreamsorcerer`. *Related issues and pull requests on GitHub:* :issue:`103`. ---- 0.3.0 ===== *(2025-02-20)* Features -------- - Implemented support for the free-threaded build of CPython 3.13 -- by :user:`lysnikolaou`. *Related issues and pull requests on GitHub:* :issue:`84`. Packaging updates and notes for downstreams ------------------------------------------- - Started building wheels for the free-threaded build of CPython 3.13 -- by :user:`lysnikolaou`. *Related issues and pull requests on GitHub:* :issue:`84`. Contributor-facing changes -------------------------- - GitHub Actions CI/CD is now configured to manage caching pip-ecosystem dependencies using `re-actors/cache-python-deps`_ -- an action by :user:`webknjaz` that takes into account ABI stability and the exact version of Python runtime. .. _`re-actors/cache-python-deps`: https://github.com/marketplace/actions/cache-python-deps *Related issues and pull requests on GitHub:* :issue:`93`. ---- 0.2.1 ===== *(2024-12-01)* Bug fixes --------- - Stopped implicitly allowing the use of Cython pre-release versions when building the distribution package -- by :user:`ajsanchezsanz` and :user:`markgreene74`. *Related commits on GitHub:* :commit:`64df0a6`. - Fixed ``wrapped`` and ``func`` not being accessible in the Cython versions of :func:`propcache.api.cached_property` and :func:`propcache.api.under_cached_property` decorators -- by :user:`bdraco`. *Related issues and pull requests on GitHub:* :issue:`72`. Removals and backward incompatible breaking changes --------------------------------------------------- - Removed support for Python 3.8 as it has reached end of life -- by :user:`bdraco`. *Related issues and pull requests on GitHub:* :issue:`57`. Packaging updates and notes for downstreams ------------------------------------------- - Stopped implicitly allowing the use of Cython pre-release versions when building the distribution package -- by :user:`ajsanchezsanz` and :user:`markgreene74`. *Related commits on GitHub:* :commit:`64df0a6`. ---- 0.2.0 ===== *(2024-10-07)* Bug fixes --------- - Fixed loading the C-extensions on Python 3.8 -- by :user:`bdraco`. *Related issues and pull requests on GitHub:* :issue:`26`. Features -------- - Improved typing for the :func:`propcache.api.under_cached_property` decorator -- by :user:`bdraco`. *Related issues and pull requests on GitHub:* :issue:`38`. Improved documentation ---------------------- - Added API documentation for the :func:`propcache.api.cached_property` and :func:`propcache.api.under_cached_property` decorators -- by :user:`bdraco`. *Related issues and pull requests on GitHub:* :issue:`16`. Packaging updates and notes for downstreams ------------------------------------------- - Moved :func:`propcache.api.under_cached_property` and :func:`propcache.api.cached_property` to `propcache.api` -- by :user:`bdraco`. Both decorators remain importable from the top-level package, however importing from `propcache.api` is now the recommended way to use them. *Related issues and pull requests on GitHub:* :issue:`19`, :issue:`24`, :issue:`32`. - Converted project to use a src layout -- by :user:`bdraco`. *Related issues and pull requests on GitHub:* :issue:`22`, :issue:`29`, :issue:`37`. ---- 0.1.0 ===== *(2024-10-03)* Features -------- - Added ``armv7l`` wheels -- by :user:`bdraco`. *Related issues and pull requests on GitHub:* :issue:`5`. ---- 0.0.0 ===== *(2024-10-02)* - Initial release. propcache-0.3.1/MANIFEST.in0000644000175000017500000000063714770661556017374 0ustar billchenchinabillchenchinainclude .coveragerc include pyproject.toml include pytest.ini include towncrier.toml include LICENSE include NOTICE include CHANGES.rst include README.rst graft propcache graft packaging graft docs graft CHANGES graft requirements graft tests global-exclude *.pyc global-exclude *.cache exclude src/propcache/*.c exclude src/propcache/*.html exclude src/propcache/*.so exclude src/propcache/*.pyd prune docs/_build propcache-0.3.1/requirements/0000755000175000017500000000000014770661563020351 5ustar billchenchinabillchenchinapropcache-0.3.1/requirements/doc.txt0000644000175000017500000000011514770661556021656 0ustar billchenchinabillchenchina-r towncrier.txt myst-parser >= 0.10.0 sphinx==8.2.3 sphinxcontrib-towncrier propcache-0.3.1/requirements/dev.txt0000644000175000017500000000004114770661556021665 0ustar billchenchinabillchenchina-r codspeed.txt -r towncrier.txt propcache-0.3.1/requirements/test-pure.txt0000644000175000017500000000007114770661556023042 0ustar billchenchinabillchenchinacovdefaults pytest==8.3.5 pytest-cov>=2.3.1 pytest-xdist propcache-0.3.1/requirements/test-freethreading.txt0000644000175000017500000000005514770661556024700 0ustar billchenchinabillchenchina-r cython-freethreading.txt -r test-pure.txt propcache-0.3.1/requirements/cython-freethreading.txt0000644000175000017500000000002014770661556025215 0ustar billchenchinabillchenchinacython==3.1.0a1 propcache-0.3.1/requirements/lint.txt0000644000175000017500000000002214770661556022054 0ustar billchenchinabillchenchinapre-commit==4.2.0 propcache-0.3.1/requirements/cython.txt0000644000175000017500000000001714770661556022416 0ustar billchenchinabillchenchinacython==3.0.12 propcache-0.3.1/requirements/codspeed.txt0000644000175000017500000000004314770661556022677 0ustar billchenchinabillchenchina-r test.txt pytest-codspeed==3.2.0 propcache-0.3.1/requirements/towncrier.txt0000644000175000017500000000002314770661556023123 0ustar billchenchinabillchenchinatowncrier==23.11.0 propcache-0.3.1/requirements/doc-spelling.txt0000644000175000017500000000014314770661556023472 0ustar billchenchinabillchenchina-r doc.txt sphinxcontrib-spelling==8.0.1; platform_system!="Windows" # We only use it in Azure CI propcache-0.3.1/requirements/test.txt0000644000175000017500000000003714770661556022073 0ustar billchenchinabillchenchina-r cython.txt -r test-pure.txt propcache-0.3.1/pytest.ini0000644000175000017500000000442014770661556017661 0ustar billchenchinabillchenchina[pytest] addopts = # `pytest-xdist`: --numprocesses=auto # NOTE: the plugin disabled because it's slower with so few tests --numprocesses=0 # Show 10 slowest invocations: --durations=10 # Report all the things == -rxXs: -ra # Show values of the local vars in errors/tracebacks: --showlocals # Autocollect and invoke the doctests from all modules: # https://docs.pytest.org/en/stable/doctest.html --doctest-modules # Pre-load the `pytest-cov` plugin early: -p pytest_cov # `pytest-cov`: --cov --cov-config=.coveragerc --cov-context=test --no-cov-on-fail # Fail on config parsing warnings: # --strict-config # Fail on non-existing markers: # * Deprecated since v6.2.0 but may be reintroduced later covering a # broader scope: # --strict # * Exists since v4.5.0 (advised to be used instead of `--strict`): --strict-markers doctest_optionflags = ALLOW_UNICODE ELLIPSIS # Marks tests with an empty parameterset as xfail(run=False) empty_parameter_set_mark = xfail faulthandler_timeout = 30 filterwarnings = error # FIXME: drop this once `pytest-cov` is updated. # Ref: https://github.com/pytest-dev/pytest-cov/issues/557 ignore:The --rsyncdir command line argument and rsyncdirs config variable are deprecated.:DeprecationWarning # https://github.com/pytest-dev/pytest/issues/10977 and https://github.com/pytest-dev/pytest/pull/10894 ignore:ast\.(Num|NameConstant|Str) is deprecated and will be removed in Python 3\.14; use ast\.Constant instead:DeprecationWarning:_pytest ignore:Attribute s is deprecated and will be removed in Python 3\.14; use value instead:DeprecationWarning:_pytest # https://docs.pytest.org/en/stable/usage.html#creating-junitxml-format-files junit_duration_report = call # xunit1 contains more metadata than xunit2 so it's better for CI UIs: junit_family = xunit1 junit_logging = all junit_log_passing_tests = true junit_suite_name = propcache_test_suite # A mapping of markers to their descriptions allowed in strict mode: markers = minversion = 3.8.2 # Optimize pytest's lookup by restricting potentially deep dir tree scan: norecursedirs = build dist docs requirements venv virtualenv propcache.egg-info .cache .eggs .git .github .tox *.egg testpaths = tests/ xfail_strict = true propcache-0.3.1/towncrier.toml0000644000175000017500000000427714770661556020553 0ustar billchenchinabillchenchina[tool.towncrier] package = "propcache" filename = "CHANGES.rst" directory = "CHANGES/" title_format = "v{version}" template = "CHANGES/.TEMPLATE.rst" issue_format = "{issue}" # NOTE: The types are declared because: # NOTE: - there is no mechanism to override just the value of # NOTE: `tool.towncrier.type.misc.showcontent`; # NOTE: - and, we want to declare extra non-default types for # NOTE: clarity and flexibility. [[tool.towncrier.section]] path = "" [[tool.towncrier.type]] # Something we deemed an improper undesired behavior that got corrected # in the release to match pre-agreed expectations. directory = "bugfix" name = "Bug fixes" showcontent = true [[tool.towncrier.type]] # New behaviors, public APIs. That sort of stuff. directory = "feature" name = "Features" showcontent = true [[tool.towncrier.type]] # Declarations of future API removals and breaking changes in behavior. directory = "deprecation" name = "Deprecations (removal in next major release)" showcontent = true [[tool.towncrier.type]] # When something public gets removed in a breaking way. Could be # deprecated in an earlier release. directory = "breaking" name = "Removals and backward incompatible breaking changes" showcontent = true [[tool.towncrier.type]] # Notable updates to the documentation structure or build process. directory = "doc" name = "Improved documentation" showcontent = true [[tool.towncrier.type]] # Notes for downstreams about unobvious side effects and tooling. Changes # in the test invocation considerations and runtime assumptions. directory = "packaging" name = "Packaging updates and notes for downstreams" showcontent = true [[tool.towncrier.type]] # Stuff that affects the contributor experience. e.g. Running tests, # building the docs, setting up the development environment. directory = "contrib" name = "Contributor-facing changes" showcontent = true [[tool.towncrier.type]] # Changes that are hard to assign to any of the above categories. directory = "misc" name = "Miscellaneous internal changes" showcontent = true propcache-0.3.1/.coveragerc0000644000175000017500000000134014770661556017747 0ustar billchenchinabillchenchina[html] show_contexts = true skip_covered = false [paths] _site-packages-to-src-mapping = src */src *\src */lib/pypy*/site-packages */lib/python*/site-packages *\Lib\site-packages [report] exclude_also = if TYPE_CHECKING assert False : \.\.\.(\s*#.*)?$ ^ +\.\.\.$ # small library, don't fail when running without C-extension fail_under = 50.00 skip_covered = true skip_empty = true show_missing = true [run] branch = true cover_pylib = false # https://coverage.rtfd.io/en/latest/contexts.html#dynamic-contexts # dynamic_context = test_function # conflicts with `pytest-cov` if set here parallel = true plugins = covdefaults Cython.Coverage relative_files = true source = . source_pkgs = propcache propcache-0.3.1/packaging/0000755000175000017500000000000014770661563017552 5ustar billchenchinabillchenchinapropcache-0.3.1/packaging/pep517_backend/0000755000175000017500000000000014770661563022242 5ustar billchenchinabillchenchinapropcache-0.3.1/packaging/pep517_backend/_backend.py0000644000175000017500000003235414770661556024353 0ustar billchenchinabillchenchina# fmt: off """PEP 517 build backend wrapper for pre-building Cython for wheel.""" from __future__ import annotations import os import sysconfig import typing as t from collections.abc import Iterator from contextlib import contextmanager, nullcontext, suppress from functools import partial from pathlib import Path from shutil import copytree from sys import implementation as _system_implementation from sys import stderr as _standard_error_stream from tempfile import TemporaryDirectory from warnings import warn as _warn_that from setuptools.build_meta import build_sdist as _setuptools_build_sdist from setuptools.build_meta import build_wheel as _setuptools_build_wheel from setuptools.build_meta import ( get_requires_for_build_wheel as _setuptools_get_requires_for_build_wheel, ) from setuptools.build_meta import ( prepare_metadata_for_build_wheel as _setuptools_prepare_metadata_for_build_wheel, ) try: from setuptools.build_meta import build_editable as _setuptools_build_editable except ImportError: _setuptools_build_editable = None # type: ignore[assignment] # isort: split from distutils.command.install import install as _distutils_install_cmd from distutils.core import Distribution as _DistutilsDistribution from distutils.dist import DistributionMetadata as _DistutilsDistributionMetadata with suppress(ImportError): # NOTE: Only available for wheel builds that bundle C-extensions. Declared # NOTE: by `get_requires_for_build_wheel()` and # NOTE: `get_requires_for_build_editable()`, when `pure-python` # NOTE: is not passed. from Cython.Build.Cythonize import main as _cythonize_cli_cmd from ._compat import chdir_cm from ._cython_configuration import get_local_cython_config as _get_local_cython_config from ._cython_configuration import ( make_cythonize_cli_args_from_config as _make_cythonize_cli_args_from_config, ) from ._cython_configuration import patched_env as _patched_cython_env from ._transformers import sanitize_rst_roles __all__ = ( # noqa: WPS410 'build_sdist', 'build_wheel', 'get_requires_for_build_wheel', 'prepare_metadata_for_build_wheel', *( () if _setuptools_build_editable is None # type: ignore[redundant-expr] else ( 'build_editable', 'get_requires_for_build_editable', 'prepare_metadata_for_build_editable', ) ), ) _ConfigDict = t.Dict[str, t.Union[str, t.List[str], None]] CYTHON_TRACING_CONFIG_SETTING = 'with-cython-tracing' """Config setting name toggle to include line tracing to C-exts.""" CYTHON_TRACING_ENV_VAR = 'PROPCACHE_CYTHON_TRACING' """Environment variable name toggle used to opt out of making C-exts.""" PURE_PYTHON_CONFIG_SETTING = 'pure-python' """Config setting name toggle that is used to opt out of making C-exts.""" PURE_PYTHON_ENV_VAR = 'PROPCACHE_NO_EXTENSIONS' """Environment variable name toggle used to opt out of making C-exts.""" IS_CPYTHON = _system_implementation.name == "cpython" """A flag meaning that the current interpreter implementation is CPython.""" PURE_PYTHON_MODE_CLI_FALLBACK = not IS_CPYTHON """A fallback for ``pure-python`` is not set.""" def _is_truthy_setting_value(setting_value: str) -> bool: truthy_values = {'', None, 'true', '1', 'on'} return setting_value.lower() in truthy_values def _get_setting_value( config_settings: _ConfigDict | None = None, config_setting_name: str | None = None, env_var_name: str | None = None, *, default: bool = False, ) -> bool: user_provided_setting_sources = ( (config_settings, config_setting_name, (KeyError, TypeError)), (os.environ, env_var_name, KeyError), ) for src_mapping, src_key, lookup_errors in user_provided_setting_sources: if src_key is None: continue with suppress(lookup_errors): # type: ignore[arg-type] return _is_truthy_setting_value(src_mapping[src_key]) # type: ignore[arg-type,index] return default def _make_pure_python(config_settings: _ConfigDict | None = None) -> bool: return _get_setting_value( config_settings, PURE_PYTHON_CONFIG_SETTING, PURE_PYTHON_ENV_VAR, default=PURE_PYTHON_MODE_CLI_FALLBACK, ) def _include_cython_line_tracing( config_settings: _ConfigDict | None = None, *, default: bool = False, ) -> bool: return _get_setting_value( config_settings, CYTHON_TRACING_CONFIG_SETTING, CYTHON_TRACING_ENV_VAR, default=default, ) @contextmanager def patched_distutils_cmd_install() -> Iterator[None]: """Make `install_lib` of `install` cmd always use `platlib`. :yields: None """ # Without this, build_lib puts stuff under `*.data/purelib/` folder orig_finalize = _distutils_install_cmd.finalize_options def new_finalize_options(self: _distutils_install_cmd) -> None: self.install_lib = self.install_platlib orig_finalize(self) _distutils_install_cmd.finalize_options = new_finalize_options # type: ignore[method-assign] try: yield finally: _distutils_install_cmd.finalize_options = orig_finalize # type: ignore[method-assign] @contextmanager def patched_dist_has_ext_modules() -> Iterator[None]: """Make `has_ext_modules` of `Distribution` always return `True`. :yields: None """ # Without this, build_lib puts stuff under `*.data/platlib/` folder orig_func = _DistutilsDistribution.has_ext_modules _DistutilsDistribution.has_ext_modules = lambda *args, **kwargs: True # type: ignore[method-assign] try: yield finally: _DistutilsDistribution.has_ext_modules = orig_func # type: ignore[method-assign] @contextmanager def patched_dist_get_long_description() -> Iterator[None]: """Make `has_ext_modules` of `Distribution` always return `True`. :yields: None """ # Without this, build_lib puts stuff under `*.data/platlib/` folder _orig_func = _DistutilsDistributionMetadata.get_long_description def _get_sanitized_long_description(self: _DistutilsDistributionMetadata) -> str: assert self.long_description is not None return sanitize_rst_roles(self.long_description) _DistutilsDistributionMetadata.get_long_description = ( # type: ignore[method-assign] _get_sanitized_long_description ) try: yield finally: _DistutilsDistributionMetadata.get_long_description = _orig_func # type: ignore[method-assign] def _exclude_dir_path( excluded_dir_path: Path, visited_directory: str, _visited_dir_contents: list[str], ) -> list[str]: """Prevent recursive directory traversal.""" # This stops the temporary directory from being copied # into self recursively forever. # Ref: https://github.com/aio-libs/yarl/issues/992 visited_directory_subdirs_to_ignore = [ subdir for subdir in _visited_dir_contents if excluded_dir_path == Path(visited_directory) / subdir ] if visited_directory_subdirs_to_ignore: print( f'Preventing `{excluded_dir_path !s}` from being ' 'copied into itself recursively...', file=_standard_error_stream, ) return visited_directory_subdirs_to_ignore @contextmanager def _in_temporary_directory(src_dir: Path) -> t.Iterator[None]: with TemporaryDirectory(prefix='.tmp-propcache-pep517-') as tmp_dir: tmp_dir_path = Path(tmp_dir) root_tmp_dir_path = tmp_dir_path.parent _exclude_tmpdir_parent = partial(_exclude_dir_path, root_tmp_dir_path) with chdir_cm(tmp_dir): tmp_src_dir = tmp_dir_path / 'src' copytree( src_dir, tmp_src_dir, ignore=_exclude_tmpdir_parent, symlinks=True, ) os.chdir(tmp_src_dir) yield @contextmanager def maybe_prebuild_c_extensions( line_trace_cython_when_unset: bool = False, build_inplace: bool = False, config_settings: _ConfigDict | None = None, ) -> t.Generator[None, t.Any, t.Any]: """Pre-build C-extensions in a temporary directory, when needed. This context manager also patches metadata, setuptools and distutils. :param build_inplace: Whether to copy and chdir to a temporary location. :param config_settings: :pep:`517` config settings mapping. """ cython_line_tracing_requested = _include_cython_line_tracing( config_settings, default=line_trace_cython_when_unset, ) is_pure_python_build = _make_pure_python(config_settings) if is_pure_python_build: print("*********************", file=_standard_error_stream) print("* Pure Python build *", file=_standard_error_stream) print("*********************", file=_standard_error_stream) if cython_line_tracing_requested: _warn_that( f'The `{CYTHON_TRACING_CONFIG_SETTING !s}` setting requesting ' 'Cython line tracing is set, but building C-extensions is not. ' 'This option will not have any effect for in the pure-python ' 'build mode.', RuntimeWarning, stacklevel=999, ) yield return print("**********************", file=_standard_error_stream) print("* Accelerated build *", file=_standard_error_stream) print("**********************", file=_standard_error_stream) if not IS_CPYTHON: _warn_that( 'Building C-extensions under the runtimes other than CPython is ' 'unsupported and will likely fail. Consider passing the ' f'`{PURE_PYTHON_CONFIG_SETTING !s}` PEP 517 config setting.', RuntimeWarning, stacklevel=999, ) build_dir_ctx = ( nullcontext() if build_inplace else _in_temporary_directory(src_dir=Path.cwd().resolve()) ) with build_dir_ctx: config = _get_local_cython_config() cythonize_args = _make_cythonize_cli_args_from_config(config) with _patched_cython_env(config['env'], cython_line_tracing_requested): _cythonize_cli_cmd(cythonize_args) # type: ignore[no-untyped-call] with patched_distutils_cmd_install(): with patched_dist_has_ext_modules(): yield @patched_dist_get_long_description() def build_wheel( wheel_directory: str, config_settings: _ConfigDict | None = None, metadata_directory: str | None = None, ) -> str: """Produce a built wheel. This wraps the corresponding ``setuptools``' build backend hook. :param wheel_directory: Directory to put the resulting wheel in. :param config_settings: :pep:`517` config settings mapping. :param metadata_directory: :file:`.dist-info` directory path. """ with maybe_prebuild_c_extensions( line_trace_cython_when_unset=False, build_inplace=False, config_settings=config_settings, ): return _setuptools_build_wheel( wheel_directory=wheel_directory, config_settings=config_settings, metadata_directory=metadata_directory, ) @patched_dist_get_long_description() def build_editable( wheel_directory: str, config_settings: _ConfigDict | None = None, metadata_directory: str | None = None, ) -> str: """Produce a built wheel for editable installs. This wraps the corresponding ``setuptools``' build backend hook. :param wheel_directory: Directory to put the resulting wheel in. :param config_settings: :pep:`517` config settings mapping. :param metadata_directory: :file:`.dist-info` directory path. """ with maybe_prebuild_c_extensions( line_trace_cython_when_unset=True, build_inplace=True, config_settings=config_settings, ): return _setuptools_build_editable( wheel_directory=wheel_directory, config_settings=config_settings, metadata_directory=metadata_directory, ) def get_requires_for_build_wheel( config_settings: _ConfigDict | None = None, ) -> list[str]: """Determine additional requirements for building wheels. :param config_settings: :pep:`517` config settings mapping. """ is_pure_python_build = _make_pure_python(config_settings) if not is_pure_python_build and not IS_CPYTHON: _warn_that( 'Building C-extensions under the runtimes other than CPython is ' 'unsupported and will likely fail. Consider passing the ' f'`{PURE_PYTHON_CONFIG_SETTING !s}` PEP 517 config setting.', RuntimeWarning, stacklevel=999, ) if is_pure_python_build: c_ext_build_deps = [] elif sysconfig.get_config_var('Py_GIL_DISABLED'): c_ext_build_deps = ['Cython ~= 3.1.0a1'] else: c_ext_build_deps = ['Cython ~= 3.0.12'] return _setuptools_get_requires_for_build_wheel( config_settings=config_settings, ) + c_ext_build_deps build_sdist = patched_dist_get_long_description()(_setuptools_build_sdist) get_requires_for_build_editable = get_requires_for_build_wheel prepare_metadata_for_build_wheel = patched_dist_get_long_description()( _setuptools_prepare_metadata_for_build_wheel, ) prepare_metadata_for_build_editable = prepare_metadata_for_build_wheel propcache-0.3.1/packaging/pep517_backend/_cython_configuration.py0000644000175000017500000000721014770661556027210 0ustar billchenchinabillchenchina# fmt: off from __future__ import annotations import os from collections.abc import Iterator from contextlib import contextmanager from pathlib import Path from sys import version_info as _python_version_tuple from typing import TypedDict from expandvars import expandvars from ._compat import load_toml_from_string from ._transformers import get_cli_kwargs_from_config, get_enabled_cli_flags_from_config class Config(TypedDict): env: dict[str, str] flags: dict[str, bool] kwargs: dict[str, str] src: list[str] def get_local_cython_config() -> Config: """Grab optional build dependencies from pyproject.toml config. :returns: config section from ``pyproject.toml`` :rtype: dict This basically reads entries from:: [tool.local.cythonize] # Env vars provisioned during cythonize call src = ["src/**/*.pyx"] [tool.local.cythonize.env] # Env vars provisioned during cythonize call LDFLAGS = "-lssh" [tool.local.cythonize.flags] # This section can contain the following booleans: # * annotate — generate annotated HTML page for source files # * build — build extension modules using distutils # * inplace — build extension modules in place using distutils (implies -b) # * force — force recompilation # * quiet — be less verbose during compilation # * lenient — increase Python compat by ignoring some compile time errors # * keep-going — compile as much as possible, ignore compilation failures annotate = false build = false inplace = true force = true quiet = false lenient = false keep-going = false [tool.local.cythonize.kwargs] # This section can contain args that have values: # * exclude=PATTERN exclude certain file patterns from the compilation # * parallel=N run builds in N parallel jobs (default: calculated per system) exclude = "**.py" parallel = 12 [tool.local.cythonize.kwargs.directives] # This section can contain compiler directives # NAME = "VALUE" [tool.local.cythonize.kwargs.compile-time-env] # This section can contain compile time env vars # NAME = "VALUE" [tool.local.cythonize.kwargs.options] # This section can contain cythonize options # NAME = "VALUE" """ config_toml_txt = (Path.cwd().resolve() / 'pyproject.toml').read_text() config_mapping = load_toml_from_string(config_toml_txt) return config_mapping['tool']['local']['cythonize'] # type: ignore[no-any-return] def make_cythonize_cli_args_from_config(config: Config) -> list[str]: py_ver_arg = f'-{_python_version_tuple.major!s}' cli_flags = get_enabled_cli_flags_from_config(config['flags']) cli_kwargs = get_cli_kwargs_from_config(config['kwargs']) return cli_flags + [py_ver_arg] + cli_kwargs + ['--'] + config['src'] @contextmanager def patched_env(env: dict[str, str], cython_line_tracing_requested: bool) -> Iterator[None]: """Temporary set given env vars. :param env: tmp env vars to set :type env: dict :yields: None """ orig_env = os.environ.copy() expanded_env = {name: expandvars(var_val) for name, var_val in env.items()} # type: ignore[no-untyped-call] os.environ.update(expanded_env) if cython_line_tracing_requested: os.environ['CFLAGS'] = ' '.join(( os.getenv('CFLAGS', ''), '-DCYTHON_TRACE_NOGIL=1', # Implies CYTHON_TRACE=1 )).strip() try: yield finally: os.environ.clear() os.environ.update(orig_env) propcache-0.3.1/packaging/pep517_backend/_transformers.py0000644000175000017500000000710414770661556025504 0ustar billchenchinabillchenchina"""Data conversion helpers for the in-tree PEP 517 build backend.""" from collections.abc import Iterable, Iterator, Mapping from itertools import chain from re import sub as _substitute_with_regexp from typing import Union def _emit_opt_pairs(opt_pair: tuple[str, Union[dict[str, str], str]]) -> Iterator[str]: flag, flag_value = opt_pair flag_opt = f"--{flag!s}" if isinstance(flag_value, dict): sub_pairs: Iterable[tuple[str, ...]] = flag_value.items() else: sub_pairs = ((flag_value,),) yield from ("=".join(map(str, (flag_opt,) + pair)) for pair in sub_pairs) def get_cli_kwargs_from_config(kwargs_map: dict[str, str]) -> list[str]: """Make a list of options with values from config.""" return list(chain.from_iterable(map(_emit_opt_pairs, kwargs_map.items()))) def get_enabled_cli_flags_from_config(flags_map: Mapping[str, bool]) -> list[str]: """Make a list of enabled boolean flags from config.""" return [f"--{flag}" for flag, is_enabled in flags_map.items() if is_enabled] def sanitize_rst_roles(rst_source_text: str) -> str: """Replace RST roles with inline highlighting.""" pep_role_regex = r"""(?x) :pep:`(?P\d+)` """ pep_substitution_pattern = ( r"`PEP \g >`__" ) user_role_regex = r"""(?x) :user:`(?P[^`]+)(?:\s+(.*))?` """ user_substitution_pattern = ( r"`@\g " r">`__" ) issue_role_regex = r"""(?x) :issue:`(?P[^`]+)(?:\s+(.*))?` """ issue_substitution_pattern = ( r"`#\g " r">`__" ) pr_role_regex = r"""(?x) :pr:`(?P[^`]+)(?:\s+(.*))?` """ pr_substitution_pattern = ( r"`PR #\g " r">`__" ) commit_role_regex = r"""(?x) :commit:`(?P[^`]+)(?:\s+(.*))?` """ commit_substitution_pattern = ( r"`\g " r">`__" ) gh_role_regex = r"""(?x) :gh:`(?P[^`<]+)(?:\s+([^`]*))?` """ gh_substitution_pattern = r"GitHub: ``\g``" meth_role_regex = r"""(?x) (?::py)?:meth:`~?(?P[^`<]+)(?:\s+([^`]*))?` """ meth_substitution_pattern = r"``\g()``" role_regex = r"""(?x) (?::\w+)?:\w+:`(?P[^`<]+)(?:\s+([^`]*))?` """ substitution_pattern = r"``\g``" project_substitution_regex = r"\|project\|" project_substitution_pattern = "propcache" substitutions = ( (pep_role_regex, pep_substitution_pattern), (user_role_regex, user_substitution_pattern), (issue_role_regex, issue_substitution_pattern), (pr_role_regex, pr_substitution_pattern), (commit_role_regex, commit_substitution_pattern), (gh_role_regex, gh_substitution_pattern), (meth_role_regex, meth_substitution_pattern), (role_regex, substitution_pattern), (project_substitution_regex, project_substitution_pattern), ) rst_source_normalized_text = rst_source_text for regex, substitution in substitutions: rst_source_normalized_text = _substitute_with_regexp( regex, substitution, rst_source_normalized_text, ) return rst_source_normalized_text propcache-0.3.1/packaging/pep517_backend/cli.py0000644000175000017500000000335114770661556023367 0ustar billchenchinabillchenchina# fmt: off from __future__ import annotations import sys from collections.abc import Sequence from itertools import chain from pathlib import Path from Cython.Compiler.CmdLine import parse_command_line as _split_cython_cli_args from Cython.Compiler.Main import compile as _translate_cython_cli_cmd from ._cython_configuration import get_local_cython_config as _get_local_cython_config from ._cython_configuration import ( make_cythonize_cli_args_from_config as _make_cythonize_cli_args_from_config, ) from ._cython_configuration import patched_env as _patched_cython_env _PROJECT_PATH = Path(__file__).parents[2] def run_main_program(argv: Sequence[str]) -> int | str: """Invoke ``translate-cython`` or fail.""" if len(argv) != 2: return 'This program only accepts one argument -- "translate-cython"' if argv[1] != 'translate-cython': return 'This program only implements the "translate-cython" subcommand' config = _get_local_cython_config() config['flags'] = {'keep-going': config['flags']['keep-going']} config['src'] = list( map( str, chain.from_iterable( map(_PROJECT_PATH.glob, config['src']), ), ), ) translate_cython_cli_args = _make_cythonize_cli_args_from_config(config) cython_options, cython_sources = _split_cython_cli_args( # type: ignore[no-untyped-call] translate_cython_cli_args, ) with _patched_cython_env(config['env'], cython_line_tracing_requested=True): return _translate_cython_cli_cmd( # type: ignore[no-untyped-call,no-any-return] cython_sources, cython_options, ).num_errors if __name__ == '__main__': sys.exit(run_main_program(argv=sys.argv)) propcache-0.3.1/packaging/pep517_backend/hooks.py0000644000175000017500000000133414770661556023742 0ustar billchenchinabillchenchina"""PEP 517 build backend for optionally pre-building Cython.""" from contextlib import suppress as _suppress from setuptools.build_meta import * # Re-exporting PEP 517 hooks # pylint: disable=unused-wildcard-import,wildcard-import # noqa: F401, F403 # Re-exporting PEP 517 hooks from ._backend import ( # type: ignore[assignment] build_sdist, build_wheel, get_requires_for_build_wheel, prepare_metadata_for_build_wheel, ) with _suppress(ImportError): # Only succeeds w/ setuptools implementing PEP 660 # Re-exporting PEP 660 hooks from ._backend import ( # type: ignore[assignment] build_editable, get_requires_for_build_editable, prepare_metadata_for_build_editable, ) propcache-0.3.1/packaging/pep517_backend/__main__.py0000644000175000017500000000015414770661556024336 0ustar billchenchinabillchenchinaimport sys from . import cli if __name__ == "__main__": sys.exit(cli.run_main_program(argv=sys.argv)) propcache-0.3.1/packaging/pep517_backend/__init__.py0000644000175000017500000000010014770661556024344 0ustar billchenchinabillchenchina"""PEP 517 build backend for optionally pre-building Cython.""" propcache-0.3.1/packaging/pep517_backend/_compat.py0000644000175000017500000000133014770661556024235 0ustar billchenchinabillchenchina"""Cross-python stdlib shims.""" import os import sys from collections.abc import Iterator from contextlib import contextmanager from pathlib import Path # isort: off if sys.version_info >= (3, 11): from contextlib import chdir as chdir_cm from tomllib import loads as load_toml_from_string else: from tomli import loads as load_toml_from_string @contextmanager def chdir_cm(path: os.PathLike) -> Iterator[None]: """Temporarily change the current directory, recovering on exit.""" original_wd = Path.cwd() os.chdir(path) try: yield finally: os.chdir(original_wd) # isort: on __all__ = ("chdir_cm", "load_toml_from_string") # noqa: WPS410 propcache-0.3.1/packaging/README.md0000644000175000017500000000070514770661556021035 0ustar billchenchinabillchenchina# `pep517_backend` in-tree build backend The `pep517_backend.hooks` importable exposes callables declared by PEP 517 and PEP 660 and is integrated into `pyproject.toml`'s `[build-system].build-backend` through `[build-system].backend-path`. # Design considerations `__init__.py` is to remain empty, leaving `hooks.py` the only entrypoint exposing the callables. The logic is contained in private modules. This is to prevent import-time side effects. propcache-0.3.1/tests/0000755000175000017500000000000014770661563016770 5ustar billchenchinabillchenchinapropcache-0.3.1/tests/test_api.py0000644000175000017500000000056714770661556021164 0ustar billchenchinabillchenchina"""Test we do not break the public API.""" from propcache import _helpers, api def test_api() -> None: """Verify the public API is accessible.""" assert api.cached_property is not None assert api.under_cached_property is not None assert api.cached_property is _helpers.cached_property assert api.under_cached_property is _helpers.under_cached_property propcache-0.3.1/tests/test_cached_property.py0000644000175000017500000000674014770661556023565 0ustar billchenchinabillchenchinaimport sys from collections.abc import Callable from operator import not_ from typing import TYPE_CHECKING, Any, Protocol, TypeVar import pytest from propcache.api import cached_property if sys.version_info >= (3, 11): from typing import assert_type _T_co = TypeVar("_T_co", covariant=True) class APIProtocol(Protocol): def cached_property( self, func: Callable[[Any], _T_co] ) -> cached_property[_T_co]: ... def test_cached_property(propcache_module: APIProtocol) -> None: class A: def __init__(self) -> None: """Init.""" @propcache_module.cached_property def prop(self) -> int: return 1 a = A() if sys.version_info >= (3, 11): assert_type(a.prop, int) assert a.prop == 1 def test_cached_property_without_cache(propcache_module: APIProtocol) -> None: class A: __slots__ = () def __init__(self) -> None: pass @propcache_module.cached_property def prop(self) -> None: """Mock property.""" a = A() with pytest.raises(AttributeError): a.prop = 123 # type: ignore[assignment] def test_cached_property_check_without_cache(propcache_module: APIProtocol) -> None: class A: __slots__ = () def __init__(self) -> None: """Init.""" @propcache_module.cached_property def prop(self) -> None: """Mock property.""" a = A() with pytest.raises((TypeError, AttributeError)): assert a.prop == 1 def test_cached_property_caching(propcache_module: APIProtocol) -> None: class A: def __init__(self) -> None: """Init.""" @propcache_module.cached_property def prop(self) -> int: """Docstring.""" return 1 a = A() assert a.prop == 1 def test_cached_property_class_docstring(propcache_module: APIProtocol) -> None: class A: def __init__(self) -> None: """Init.""" @propcache_module.cached_property def prop(self) -> None: """Docstring.""" if TYPE_CHECKING: assert isinstance(A.prop, cached_property) else: assert isinstance(A.prop, propcache_module.cached_property) assert "Docstring." == A.prop.__doc__ def test_set_name(propcache_module: APIProtocol) -> None: """Test that the __set_name__ method is called and checked.""" class A: @propcache_module.cached_property def prop(self) -> None: """Docstring.""" A.prop.__set_name__(A, "prop") match = r"Cannot assign the same cached_property to two " with pytest.raises(TypeError, match=match): A.prop.__set_name__(A, "something_else") def test_get_without_set_name(propcache_module: APIProtocol) -> None: """Test that get without __set_name__ fails.""" cp = propcache_module.cached_property(not_) class A: """A class.""" A.cp = cp # type: ignore[attr-defined] match = r"Cannot use cached_property instance " with pytest.raises(TypeError, match=match): _ = A().cp # type: ignore[attr-defined] def test_ensured_wrapped_function_is_accessible(propcache_module: APIProtocol) -> None: """Test that the wrapped function can be accessed from python.""" class A: def __init__(self) -> None: """Init.""" @propcache_module.cached_property def prop(self) -> int: """Docstring.""" return 1 a = A() assert A.prop.func(a) == 1 propcache-0.3.1/tests/test_benchmarks.py0000644000175000017500000000423714770661556022526 0ustar billchenchinabillchenchina"""codspeed benchmarks for propcache.""" import pytest try: from pytest_codspeed import BenchmarkFixture except ImportError: pytestmark = pytest.mark.skip("pytest_codspeed needs to be installed") from propcache import cached_property, under_cached_property def test_under_cached_property_cache_hit(benchmark: "BenchmarkFixture") -> None: """Benchmark for under_cached_property cache hit.""" class Test: def __init__(self) -> None: self._cache = {"prop": 42} @under_cached_property def prop(self) -> int: """Return the value of the property.""" raise NotImplementedError t = Test() @benchmark def _run() -> None: for _ in range(100): t.prop def test_cached_property_cache_hit(benchmark: "BenchmarkFixture") -> None: """Benchmark for cached_property cache hit.""" class Test: def __init__(self) -> None: self.__dict__["prop"] = 42 @cached_property def prop(self) -> int: """Return the value of the property.""" raise NotImplementedError t = Test() @benchmark def _run() -> None: for _ in range(100): t.prop def test_under_cached_property_cache_miss(benchmark: "BenchmarkFixture") -> None: """Benchmark for under_cached_property cache miss.""" class Test: def __init__(self) -> None: self._cache: dict[str, int] = {} @under_cached_property def prop(self) -> int: """Return the value of the property.""" return 42 t = Test() cache = t._cache @benchmark def _run() -> None: for _ in range(100): cache.pop("prop", None) t.prop def test_cached_property_cache_miss(benchmark: "BenchmarkFixture") -> None: """Benchmark for cached_property cache miss.""" class Test: @cached_property def prop(self) -> int: """Return the value of the property.""" return 42 t = Test() cache = t.__dict__ @benchmark def _run() -> None: for _ in range(100): cache.pop("prop", None) t.prop propcache-0.3.1/tests/test_init.py0000644000175000017500000000265614770661556021357 0ustar billchenchinabillchenchina"""Test imports can happen from top-level.""" import pytest import propcache from propcache import _helpers def test_api_at_top_level() -> None: """Verify the public API is accessible at top-level.""" assert propcache.cached_property is not None assert propcache.under_cached_property is not None assert propcache.cached_property is _helpers.cached_property assert propcache.under_cached_property is _helpers.under_cached_property @pytest.mark.parametrize( "prop_name", ("cached_property", "under_cached_property"), ) def test_public_api_is_discoverable_in_dir(prop_name: str) -> None: """Verify the public API is discoverable programmatically.""" assert prop_name in dir(propcache) def test_importing_invalid_attr_raises() -> None: """Verify importing an invalid attribute raises an AttributeError.""" match = r"^module 'propcache' has no attribute 'invalid_attr'$" with pytest.raises(AttributeError, match=match): propcache.invalid_attr def test_import_error_invalid_attr() -> None: """Verify importing an invalid attribute raises an ImportError.""" # No match here because the error is raised by the import system # and may vary between Python versions. with pytest.raises(ImportError): from propcache import invalid_attr # noqa: F401 def test_no_wildcard_imports() -> None: """Verify wildcard imports are prohibited.""" assert not propcache.__all__ propcache-0.3.1/tests/test_under_cached_property.py0000644000175000017500000001067614770661556024765 0ustar billchenchinabillchenchinaimport sys from collections.abc import Callable from typing import TYPE_CHECKING, Any, Protocol, TypedDict, TypeVar import pytest from propcache.api import under_cached_property if sys.version_info >= (3, 11): from typing import assert_type _T_co = TypeVar("_T_co", covariant=True) class APIProtocol(Protocol): def under_cached_property( self, func: Callable[[Any], _T_co] ) -> under_cached_property[_T_co]: ... def test_under_cached_property(propcache_module: APIProtocol) -> None: class A: def __init__(self) -> None: self._cache: dict[str, int] = {} @propcache_module.under_cached_property def prop(self) -> int: return 1 @propcache_module.under_cached_property def prop2(self) -> str: return "foo" a = A() if sys.version_info >= (3, 11): assert_type(a.prop, int) assert a.prop == 1 if sys.version_info >= (3, 11): assert_type(a.prop2, str) assert a.prop2 == "foo" def test_under_cached_property_typeddict(propcache_module: APIProtocol) -> None: """Test static typing passes with TypedDict.""" class _Cache(TypedDict, total=False): prop: int prop2: str class A: def __init__(self) -> None: self._cache: _Cache = {} @propcache_module.under_cached_property def prop(self) -> int: return 1 @propcache_module.under_cached_property def prop2(self) -> str: return "foo" a = A() if sys.version_info >= (3, 11): assert_type(a.prop, int) assert a.prop == 1 if sys.version_info >= (3, 11): assert_type(a.prop2, str) assert a.prop2 == "foo" def test_under_cached_property_assignment(propcache_module: APIProtocol) -> None: class A: def __init__(self) -> None: self._cache: dict[str, Any] = {} @propcache_module.under_cached_property def prop(self) -> None: """Mock property.""" a = A() with pytest.raises(AttributeError): a.prop = 123 # type: ignore[assignment] def test_under_cached_property_without_cache(propcache_module: APIProtocol) -> None: class A: def __init__(self) -> None: """Init.""" self._cache: dict[str, int] = {} @propcache_module.under_cached_property def prop(self) -> None: """Mock property.""" a = A() with pytest.raises(AttributeError): a.prop = 123 # type: ignore[assignment] def test_under_cached_property_check_without_cache( propcache_module: APIProtocol, ) -> None: class A: def __init__(self) -> None: """Init.""" # Note that self._cache is intentionally missing # here to verify AttributeError @propcache_module.under_cached_property def prop(self) -> None: """Mock property.""" a = A() with pytest.raises(AttributeError): _ = a.prop # type: ignore[call-overload] def test_under_cached_property_caching(propcache_module: APIProtocol) -> None: class A: def __init__(self) -> None: self._cache: dict[str, int] = {} @propcache_module.under_cached_property def prop(self) -> int: """Docstring.""" return 1 a = A() assert a.prop == 1 def test_under_cached_property_class_docstring(propcache_module: APIProtocol) -> None: class A: def __init__(self) -> None: """Init.""" @propcache_module.under_cached_property def prop(self) -> None: """Docstring.""" if TYPE_CHECKING: # At type checking, the fixture doesn't represent the real module, so # we use the global-level imported module to verify the isinstance() check here # matches the behaviour users would see in real code. assert isinstance(A.prop, under_cached_property) else: assert isinstance(A.prop, propcache_module.under_cached_property) assert "Docstring." == A.prop.__doc__ def test_ensured_wrapped_function_is_accessible(propcache_module: APIProtocol) -> None: """Test that the wrapped function can be accessed from python.""" class A: def __init__(self) -> None: """Init.""" self._cache: dict[str, int] = {} @propcache_module.under_cached_property def prop(self) -> int: """Docstring.""" return 1 a = A() assert A.prop.wrapped(a) == 1 propcache-0.3.1/tests/conftest.py0000644000175000017500000000676114770661556021203 0ustar billchenchinabillchenchinaimport argparse from dataclasses import dataclass from functools import cached_property from importlib import import_module from types import ModuleType import pytest C_EXT_MARK = pytest.mark.c_extension @dataclass(frozen=True) class PropcacheImplementation: """A facade for accessing importable propcache module variants. An instance essentially represents a c-extension or a pure-python module. The actual underlying module is accessed dynamically through a property and is cached. It also has a text tag depending on what variant it is, and a string representation suitable for use in Pytest's test IDs via parametrization. """ is_pure_python: bool """A flag showing whether this is a pure-python module or a C-extension.""" @cached_property def tag(self) -> str: """Return a text representation of the pure-python attribute.""" return "pure-python" if self.is_pure_python else "c-extension" @cached_property def imported_module(self) -> ModuleType: """Return a loaded importable containing a propcache variant.""" importable_module = "_helpers_py" if self.is_pure_python else "_helpers_c" return import_module(f"propcache.{importable_module}") def __str__(self) -> str: """Render the implementation facade instance as a string.""" return f"{self.tag}-module" @pytest.fixture( scope="session", params=( pytest.param( PropcacheImplementation(is_pure_python=False), marks=C_EXT_MARK, ), PropcacheImplementation(is_pure_python=True), ), ids=str, ) def propcache_implementation(request: pytest.FixtureRequest) -> PropcacheImplementation: """Return a propcache variant facade.""" return request.param # type: ignore[no-any-return] @pytest.fixture(scope="session") def propcache_module( propcache_implementation: PropcacheImplementation, ) -> ModuleType: """Return a pre-imported module containing a propcache variant.""" return propcache_implementation.imported_module def pytest_addoption( parser: pytest.Parser, pluginmanager: pytest.PytestPluginManager, ) -> None: """Define a new ``--c-extensions`` flag. This lets the callers deselect tests executed against the C-extension version of the ``propcache`` implementation. """ del pluginmanager parser.addoption( "--c-extensions", # disabled with `--no-c-extensions` action=argparse.BooleanOptionalAction, default=True, dest="c_extensions", help="Test C-extensions (on by default)", ) def pytest_collection_modifyitems( session: pytest.Session, config: pytest.Config, items: list[pytest.Item], ) -> None: """Deselect tests against C-extensions when requested via CLI.""" test_c_extensions = config.getoption("--c-extensions") is True if test_c_extensions: return selected_tests: list[pytest.Item] = [] deselected_tests: list[pytest.Item] = [] for item in items: c_ext = item.get_closest_marker(C_EXT_MARK.name) is not None target_items_list = deselected_tests if c_ext else selected_tests target_items_list.append(item) config.hook.pytest_deselected(items=deselected_tests) items[:] = selected_tests def pytest_configure(config: pytest.Config) -> None: """Declare the C-extension marker in config.""" config.addinivalue_line( "markers", f"{C_EXT_MARK.name}: tests running against the C-extension implementation.", )