././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1736956434.6359076 zope_deprecation-5.1/0000755000076600000240000000000014741755023014424 5ustar00m.howitzstaff././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1736956433.0 zope_deprecation-5.1/.pre-commit-config.yaml0000644000076600000240000000132714741755021020706 0ustar00m.howitzstaff# Generated from: # https://github.com/zopefoundation/meta/tree/master/config/pure-python minimum_pre_commit_version: '3.6' repos: - repo: https://github.com/pycqa/isort rev: "5.13.2" hooks: - id: isort - repo: https://github.com/hhatto/autopep8 rev: "v2.3.1" hooks: - id: autopep8 args: [--in-place, --aggressive, --aggressive] - repo: https://github.com/asottile/pyupgrade rev: v3.19.0 hooks: - id: pyupgrade args: [--py39-plus] - repo: https://github.com/isidentical/teyit rev: 0.4.3 hooks: - id: teyit - repo: https://github.com/PyCQA/flake8 rev: "7.1.1" hooks: - id: flake8 additional_dependencies: - flake8-debugger == 4.1.2 ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1736956433.0 zope_deprecation-5.1/.readthedocs.yaml0000644000076600000240000000123514741755021017652 0ustar00m.howitzstaff# Generated from: # https://github.com/zopefoundation/meta/tree/master/config/pure-python # Read the Docs configuration file # See https://docs.readthedocs.io/en/stable/config-file/v2.html for details # Required version: 2 # Set the version of Python and other tools you might need build: os: ubuntu-22.04 tools: python: "3.11" # Build documentation in the docs/ directory with Sphinx sphinx: configuration: docs/conf.py # We recommend specifying your dependencies to enable reproducible builds: # https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html python: install: - requirements: docs/requirements.txt - method: pip path: . ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1736956433.0 zope_deprecation-5.1/CHANGES.rst0000644000076600000240000000544514741755021016234 0ustar00m.howitzstaff================================ ``zope.deprecation`` Changelog ================================ 5.1 (2025-01-15) ================ - Add support for Python 3.12, 3.13. - Drop support for Python 3.7, 3.8. 5.0 (2023-03-29) ================ - Drop support for Python 2.7, 3.4, 3.5, 3.6. - Drop support for deprecated ``python setup.py test``. - Add support for Python 3.8, 3.9, 3.10, 3.11. 4.4.0 (2018-12-03) ================== - Add support for Python 3.7. 4.3.0 (2017-08-07) ================== - Allow custom warning classes to be specified to override the default ``DeprecationWarning``. See https://github.com/zopefoundation/zope.deprecation/pull/7 - Add support for Python 3.6. - Drop support for Python 3.3. 4.2.0 (2016-11-07) ================== - Drop support for Python 2.6 and 3.2. - Add support for Python 3.5. 4.1.2 (2015-01-13) ================== - Do not require a ``self`` parameter for deprecated functions. See: https://github.com/zopefoundation/zope.deprecation/pull/1 4.1.1 (2014-03-19) ================== - Added explicit support for Python 3.4. 4.1.0 (2013-12-20) ================== - Added a ``Suppressor`` context manager, allowing scoped suppression of deprecation warnings. - Updated ``boostrap.py`` to version 2.2. 4.0.2 (2012-12-31) ================== - Fleshed out PyPI Trove classifiers. 4.0.1 (2012-11-21) ================== - Added support for Python 3.3. 4.0.0 (2012-05-16) ================== - Automated build of Sphinx HTML docs and running doctest snippets via tox. - Added Sphinx documentation: - API docs moved from package-data README into ``docs/api.rst``. - Snippets can be tested by running 'make doctest'. - Updated support for continuous integration using ``tox`` and ``jenkins``. - 100% unit test coverage. - Added ``setup.py dev`` alias (runs ``setup.py develop`` plus installs ``nose`` and ``coverage``). - Added ``setup.py docs`` alias (installs ``Sphinx`` and dependencies). - Removed spurious dependency on ``zope.testing``. - Dropped explicit support for Python 2.4 / 2.5 / 3.1. 3.5.1 (2012-03-15) ================== - Revert a move of `README.txt` to unbreak ``zope.app.apidoc``. 3.5.0 (2011-09-05) ================== - Replaced doctesting with unit testing. - Python 3 compatibility. 3.4.1 (2011-06-07) ================== - Removed import cycle for ``__show__`` by defining it in the ``zope.deprecation.deprecation`` module. - Added support to bootstrap on Jython. - Fix ``zope.deprecation.warn()`` to make the signature identical to ``warnings.warn()`` and to check for .pyc and .pyo files. 3.4.0 (2007-07-19) ================== - Release 3.4 final, corresponding to Zope 3.4. 3.3.0 (2007-02-18) ================== - Corresponds to the version of the ``zope.deprecation`` package shipped as part of the Zope 3.3.0 release. ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1736956433.0 zope_deprecation-5.1/CONTRIBUTING.md0000644000076600000240000000144414741755021016656 0ustar00m.howitzstaff # Contributing to zopefoundation projects The projects under the zopefoundation GitHub organization are open source and welcome contributions in different forms: * bug reports * code improvements and bug fixes * documentation improvements * pull request reviews For any changes in the repository besides trivial typo fixes you are required to sign the contributor agreement. See https://www.zope.dev/developer/becoming-a-committer.html for details. Please visit our [Developer Guidelines](https://www.zope.dev/developer/guidelines.html) if you'd like to contribute code changes and our [guidelines for reporting bugs](https://www.zope.dev/developer/reporting-bugs.html) if you want to file a bug report. ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1736956433.0 zope_deprecation-5.1/COPYRIGHT.txt0000644000076600000240000000004014741755021016525 0ustar00m.howitzstaffZope Foundation and Contributors././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1736956433.0 zope_deprecation-5.1/LICENSE.txt0000644000076600000240000000402614741755021016247 0ustar00m.howitzstaffZope Public License (ZPL) Version 2.1 A copyright notice accompanies this license document that identifies the copyright holders. This license has been certified as open source. It has also been designated as GPL compatible by the Free Software Foundation (FSF). Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions in source code must retain the accompanying copyright notice, this list of conditions, and the following disclaimer. 2. Redistributions in binary form must reproduce the accompanying copyright notice, this list of conditions, and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Names of the copyright holders must not be used to endorse or promote products derived from this software without prior written permission from the copyright holders. 4. The right to distribute this software or to use it for any purpose does not give you the right to use Servicemarks (sm) or Trademarks (tm) of the copyright holders. Use of them is covered by separate agreement with the copyright holders. 5. If any files are modified, you must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. Disclaimer THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1736956433.0 zope_deprecation-5.1/MANIFEST.in0000644000076600000240000000060714741755021016163 0ustar00m.howitzstaff# Generated from: # https://github.com/zopefoundation/meta/tree/master/config/pure-python include *.md include *.rst include *.txt include buildout.cfg include tox.ini include .pre-commit-config.yaml recursive-include docs *.py recursive-include docs *.rst recursive-include docs *.txt recursive-include docs Makefile recursive-include src *.py include *.yaml recursive-include docs *.bat ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1736956434.6358352 zope_deprecation-5.1/PKG-INFO0000644000076600000240000001206614741755023015526 0ustar00m.howitzstaffMetadata-Version: 2.1 Name: zope.deprecation Version: 5.1 Summary: Zope Deprecation Infrastructure Home-page: https://github.com/zopefoundation/zope.deprecation Author: Zope Corporation and Contributors Author-email: zope-dev@zope.org License: ZPL 2.1 Keywords: deprecation,deprecated,warning Classifier: Intended Audience :: Developers Classifier: License :: OSI Approved :: Zope Public License 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: Programming Language :: Python :: Implementation :: CPython Classifier: Programming Language :: Python :: Implementation :: PyPy Classifier: Framework :: Zope :: 3 Requires-Python: >= 3.9 License-File: LICENSE.txt Requires-Dist: setuptools Provides-Extra: docs Requires-Dist: Sphinx; extra == "docs" Provides-Extra: test Requires-Dist: zope.testrunner; extra == "test" ====================== ``zope.deprecation`` ====================== .. image:: https://img.shields.io/pypi/v/zope.deprecation.svg :target: https://pypi.python.org/pypi/zope.deprecation/ :alt: Latest release .. image:: https://img.shields.io/pypi/pyversions/zope.deprecation.svg :target: https://pypi.org/project/zope.deprecation/ :alt: Supported Python versions .. image:: https://github.com/zopefoundation/zope.deprecation/actions/workflows/tests.yml/badge.svg :target: https://github.com/zopefoundation/zope.deprecation/actions/workflows/tests.yml .. image:: https://coveralls.io/repos/github/zopefoundation/zope.deprecation/badge.svg?branch=master :target: https://coveralls.io/github/zopefoundation/zope.deprecation?branch=master .. image:: https://readthedocs.org/projects/zopedeprecation/badge/?version=latest :target: https://zopedeprecation.readthedocs.io/en/latest/ :alt: Documentation Status This package provides a simple function called ``deprecated(names, reason)`` to mark deprecated modules, classes, functions, methods and properties. Please see https://zopedeprecation.readthedocs.io for the documentation. ================================ ``zope.deprecation`` Changelog ================================ 5.1 (2025-01-15) ================ - Add support for Python 3.12, 3.13. - Drop support for Python 3.7, 3.8. 5.0 (2023-03-29) ================ - Drop support for Python 2.7, 3.4, 3.5, 3.6. - Drop support for deprecated ``python setup.py test``. - Add support for Python 3.8, 3.9, 3.10, 3.11. 4.4.0 (2018-12-03) ================== - Add support for Python 3.7. 4.3.0 (2017-08-07) ================== - Allow custom warning classes to be specified to override the default ``DeprecationWarning``. See https://github.com/zopefoundation/zope.deprecation/pull/7 - Add support for Python 3.6. - Drop support for Python 3.3. 4.2.0 (2016-11-07) ================== - Drop support for Python 2.6 and 3.2. - Add support for Python 3.5. 4.1.2 (2015-01-13) ================== - Do not require a ``self`` parameter for deprecated functions. See: https://github.com/zopefoundation/zope.deprecation/pull/1 4.1.1 (2014-03-19) ================== - Added explicit support for Python 3.4. 4.1.0 (2013-12-20) ================== - Added a ``Suppressor`` context manager, allowing scoped suppression of deprecation warnings. - Updated ``boostrap.py`` to version 2.2. 4.0.2 (2012-12-31) ================== - Fleshed out PyPI Trove classifiers. 4.0.1 (2012-11-21) ================== - Added support for Python 3.3. 4.0.0 (2012-05-16) ================== - Automated build of Sphinx HTML docs and running doctest snippets via tox. - Added Sphinx documentation: - API docs moved from package-data README into ``docs/api.rst``. - Snippets can be tested by running 'make doctest'. - Updated support for continuous integration using ``tox`` and ``jenkins``. - 100% unit test coverage. - Added ``setup.py dev`` alias (runs ``setup.py develop`` plus installs ``nose`` and ``coverage``). - Added ``setup.py docs`` alias (installs ``Sphinx`` and dependencies). - Removed spurious dependency on ``zope.testing``. - Dropped explicit support for Python 2.4 / 2.5 / 3.1. 3.5.1 (2012-03-15) ================== - Revert a move of `README.txt` to unbreak ``zope.app.apidoc``. 3.5.0 (2011-09-05) ================== - Replaced doctesting with unit testing. - Python 3 compatibility. 3.4.1 (2011-06-07) ================== - Removed import cycle for ``__show__`` by defining it in the ``zope.deprecation.deprecation`` module. - Added support to bootstrap on Jython. - Fix ``zope.deprecation.warn()`` to make the signature identical to ``warnings.warn()`` and to check for .pyc and .pyo files. 3.4.0 (2007-07-19) ================== - Release 3.4 final, corresponding to Zope 3.4. 3.3.0 (2007-02-18) ================== - Corresponds to the version of the ``zope.deprecation`` package shipped as part of the Zope 3.3.0 release. ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1736956433.0 zope_deprecation-5.1/README.rst0000644000076600000240000000225414741755021016114 0ustar00m.howitzstaff====================== ``zope.deprecation`` ====================== .. image:: https://img.shields.io/pypi/v/zope.deprecation.svg :target: https://pypi.python.org/pypi/zope.deprecation/ :alt: Latest release .. image:: https://img.shields.io/pypi/pyversions/zope.deprecation.svg :target: https://pypi.org/project/zope.deprecation/ :alt: Supported Python versions .. image:: https://github.com/zopefoundation/zope.deprecation/actions/workflows/tests.yml/badge.svg :target: https://github.com/zopefoundation/zope.deprecation/actions/workflows/tests.yml .. image:: https://coveralls.io/repos/github/zopefoundation/zope.deprecation/badge.svg?branch=master :target: https://coveralls.io/github/zopefoundation/zope.deprecation?branch=master .. image:: https://readthedocs.org/projects/zopedeprecation/badge/?version=latest :target: https://zopedeprecation.readthedocs.io/en/latest/ :alt: Documentation Status This package provides a simple function called ``deprecated(names, reason)`` to mark deprecated modules, classes, functions, methods and properties. Please see https://zopedeprecation.readthedocs.io for the documentation. ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1736956433.0 zope_deprecation-5.1/buildout.cfg0000644000076600000240000000014414741755021016731 0ustar00m.howitzstaff[buildout] parts = test develop = . [test] recipe = zc.recipe.testrunner eggs = zope.deprecation ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1736956434.6339197 zope_deprecation-5.1/docs/0000755000076600000240000000000014741755023015354 5ustar00m.howitzstaff././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1736956433.0 zope_deprecation-5.1/docs/Makefile0000644000076600000240000001274014741755021017016 0ustar00m.howitzstaff# 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 clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext 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 " 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 " 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 " linkcheck to check all external links for integrity" @echo " doctest to run all doctests embedded in the documentation (if enabled)" clean: -rm -rf $(BUILDDIR)/* html: $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html @echo @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." dirhtml: $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml @echo @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." singlehtml: $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml @echo @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." pickle: $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle @echo @echo "Build finished; now you can process the pickle files." json: $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json @echo @echo "Build finished; now you can process the JSON files." 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." 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/zopedeprecation.qhcp" @echo "To view the help file:" @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/zopedeprecation.qhc" devhelp: $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp @echo @echo "Build finished." @echo "To view the help file:" @echo "# mkdir -p $$HOME/.local/share/devhelp/zopedeprecation" @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/zopedeprecation" @echo "# devhelp" epub: $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub @echo @echo "Build finished. The epub file is in $(BUILDDIR)/epub." 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)." 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." text: $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text @echo @echo "Build finished. The text files are in $(BUILDDIR)/text." man: $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man @echo @echo "Build finished. The manual pages are in $(BUILDDIR)/man." 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)." 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." gettext: $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale @echo @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale." changes: $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes @echo @echo "The overview file is in $(BUILDDIR)/changes." 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." doctest: $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest @echo "Testing of doctests in the sources finished, look at the " \ "results in $(BUILDDIR)/doctest/output.txt." ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1736956433.0 zope_deprecation-5.1/docs/api.rst0000644000076600000240000003267214741755021016667 0ustar00m.howitzstaff============================= :mod:`zope.deprecation` API ============================= Deprecating objects inside a module =================================== Let's start with a demonstration of deprecating any name inside a module. To demonstrate the functionality, First, let's set up an example module containing fixtures we will use: .. doctest:: >>> import os >>> import tempfile >>> import zope.deprecation >>> tmp_d = tempfile.mkdtemp('deprecation') >>> zope.deprecation.__path__.append(tmp_d) >>> doctest_ex = '''\ ... from . import deprecated ... ... def demo1(): ... return 1 ... deprecated('demo1', 'demo1 is no more.') ... ... def demo2(): ... return 2 ... deprecated('demo2', 'demo2 is no more.') ... ... def demo3(): ... return 3 ... deprecated('demo3', 'demo3 is no more.') ... ... def demo4(): ... return 4 ... def deprecatedemo4(): ... """Demonstrate that deprecated() also works in a local scope.""" ... deprecated('demo4', 'demo4 is no more.') ... ''' >>> with open(os.path.join(tmp_d, 'doctest_ex.py'), 'w') as f: ... _ = f.write(doctest_ex) The first argument to the ``deprecated()`` function is a list of names that should be declared deprecated. If the first argument is a string, it is interpreted as one name. The second argument is the reason the particular name has been deprecated. It is good practice to also list the version in which the name will be removed completely. Let's now see how the deprecation warnings are displayed. .. doctest:: >>> import warnings >>> from zope.deprecation import doctest_ex >>> with warnings.catch_warnings(record=True) as log: ... del warnings.filters[:] ... doctest_ex.demo1() 1 >>> print(log[0].category.__name__) DeprecationWarning >>> print(log[0].message) demo1: demo1 is no more. >>> import zope.deprecation.doctest_ex >>> with warnings.catch_warnings(record=True) as log: ... del warnings.filters[:] ... zope.deprecation.doctest_ex.demo2() 2 >>> print(log[0].message) demo2: demo2 is no more. You can see that merely importing the affected module or one of its parents does not cause a deprecation warning. Only when we try to access the name in the module, we get a deprecation warning. On the other hand, if we import the name directly, the deprecation warning will be raised immediately. .. doctest:: >>> with warnings.catch_warnings(record=True) as log: ... del warnings.filters[:] ... from zope.deprecation.doctest_ex import demo3 >>> print(log[0].message) demo3: demo3 is no more. Deprecation can also happen inside a function. When we first access ``demo4``, it can be accessed without problems, then we call a function that sets the deprecation message and we get the message upon the next access: .. doctest:: >>> with warnings.catch_warnings(record=True) as log: ... del warnings.filters[:] ... doctest_ex.demo4() 4 >>> len(log) 0 >>> doctest_ex.deprecatedemo4() >>> with warnings.catch_warnings(record=True) as log: ... del warnings.filters[:] ... doctest_ex.demo4() 4 >>> print(log[0].message) demo4: demo4 is no more. Deprecating methods and properties ================================== New let's see how properties and methods can be deprecated. We are going to use the same function as before, except that this time, we do not pass in names as first argument, but the method or attribute itself. The function then returns a wrapper that sends out a deprecation warning when the attribute or method is accessed. .. doctest:: >>> from zope.deprecation import deprecation >>> class MyComponent(object): ... foo = property(lambda self: 1) ... foo = deprecation.deprecated(foo, 'foo is no more.') ... ... bar = 2 ... ... def blah(self): ... return 3 ... blah = deprecation.deprecated(blah, 'blah() is no more.') ... ... def splat(self): ... return 4 ... ... @deprecation.deprecate("clap() is no more.") ... def clap(self): ... return 5 And here is the result: .. doctest:: >>> my = MyComponent() >>> with warnings.catch_warnings(record=True) as log: ... del warnings.filters[:] ... my.foo 1 >>> print(log[0].message) foo is no more. >>> with warnings.catch_warnings(record=True) as log: ... del warnings.filters[:] ... my.bar 2 >>> len(log) 0 >>> with warnings.catch_warnings(record=True) as log: ... del warnings.filters[:] ... my.blah() 3 >>> print(log[0].message) blah() is no more. >>> with warnings.catch_warnings(record=True) as log: ... del warnings.filters[:] ... my.splat() 4 >>> len(log) 0 >>> with warnings.catch_warnings(record=True) as log: ... del warnings.filters[:] ... my.clap() 5 >>> print(log[0].message) clap() is no more. Deprecating modules =================== It is also possible to deprecate whole modules. This is useful when creating module aliases for backward compatibility. Let's imagine, the ``zope.deprecation`` module used to be called ``zope.wanda`` and we'd like to retain backward compatibility: .. doctest:: >>> import sys >>> sys.modules['zope.wanda'] = deprecation.deprecated( ... zope.deprecation, 'A module called Wanda is now zope.deprecation.') Now we can import ``wanda``, but when accessing things from it, we get our deprecation message as expected: .. doctest:: >>> with warnings.catch_warnings(record=True) as log: ... del warnings.filters[:] ... from zope.wanda import deprecated >>> print(log[0].message) A module called Wanda is now zope.deprecation. Before we move on, we should clean up: .. doctest:: >>> del deprecated >>> del sys.modules['zope.wanda'] Moving modules ============== When a module is moved, you often want to support importing from the old location for a while, generating a deprecation warning when someone uses the old location. This can be done using the moved function. To see how this works, we'll use a helper function to create two fake modules in the zope.deprecation package. First will create a module in the "old" location that used the moved function to indicate the a module on the new location should be used: .. doctest:: >>> import os >>> created_modules = [] >>> def create_module(modules=(), **kw): #** highlightfail ... modules = dict(modules) ... modules.update(kw) ... for name, src in sorted(modules.items()): ... pname = name.split('.') ... if pname[-1] == '__init__': ... os.mkdir(os.path.join(tmp_d, *pname[:-1])) #* highlightfail ... name = '.'.join(pname[:-1]) ... with open(os.path.join(tmp_d, *pname) + '.py', 'w') as f: ... f.write(src) #* hf ... created_modules.append(name) ... import importlib ... if hasattr(importlib, 'invalidate_caches'): ... importlib.invalidate_caches() >>> create_module(old_location= ... ''' ... import zope.deprecation ... zope.deprecation.moved('zope.deprecation.new_location', 'version 2') ... ''') and we define the module in the new location: .. doctest:: >>> create_module(new_location= ... '''\ ... print("new module imported") ... x = 42 ... ''') Now, if we import the old location, we'll see the output of importing the old location: .. doctest:: >>> with warnings.catch_warnings(record=True) as log: ... del warnings.filters[:] ... import zope.deprecation.old_location new module imported >>> print(log[0].message) ... # doctest: +NORMALIZE_WHITESPACE zope.deprecation.old_location has moved to zope.deprecation.new_location. Import of zope.deprecation.old_location will become unsupported in version 2 >>> zope.deprecation.old_location.x 42 Moving packages =============== When moving packages, you need to leave placeholders for each module. Let's look at an example: .. doctest:: >>> create_module({ ... 'new_package.__init__': '''\ ... print(__name__ + ' imported') ... x=0 ... ''', ... 'new_package.m1': '''\ ... print(__name__ + ' imported') ... x=1 ... ''', ... 'new_package.m2': '''\ ... print(__name__ + ' imported') ... def x(): ... pass ... ''', ... 'new_package.m3': '''\ ... print(__name__ + ' imported') ... x=3 ... ''', ... 'old_package.__init__': '''\ ... import zope.deprecation ... zope.deprecation.moved('zope.deprecation.new_package', 'version 2') ... ''', ... 'old_package.m1': '''\ ... import zope.deprecation ... zope.deprecation.moved('zope.deprecation.new_package.m1', 'version 2') ... ''', ... 'old_package.m2': '''\ ... import zope.deprecation ... zope.deprecation.moved('zope.deprecation.new_package.m2', 'version 2') ... ''', ... }) Now, if we import the old modules, we'll get warnings: .. doctest:: >>> with warnings.catch_warnings(record=True) as log: ... del warnings.filters[:] ... import zope.deprecation.old_package zope.deprecation.new_package imported >>> print(log[0].message) ... # doctest: +NORMALIZE_WHITESPACE zope.deprecation.old_package has moved to zope.deprecation.new_package. Import of zope.deprecation.old_package will become unsupported in version 2 >>> zope.deprecation.old_package.x 0 >>> with warnings.catch_warnings(record=True) as log: ... del warnings.filters[:] ... import zope.deprecation.old_package.m1 zope.deprecation.new_package.m1 imported >>> print(log[0].message) ... # doctest: +NORMALIZE_WHITESPACE zope.deprecation.old_package.m1 has moved to zope.deprecation.new_package.m1. Import of zope.deprecation.old_package.m1 will become unsupported in version 2 >>> zope.deprecation.old_package.m1.x 1 >>> with warnings.catch_warnings(record=True) as log: ... del warnings.filters[:] ... import zope.deprecation.old_package.m2 zope.deprecation.new_package.m2 imported >>> print(log[0].message) ... # doctest: +NORMALIZE_WHITESPACE zope.deprecation.old_package.m2 has moved to zope.deprecation.new_package.m2. Import of zope.deprecation.old_package.m2 will become unsupported in version 2 >>> zope.deprecation.old_package.m2.x is zope.deprecation.new_package.m2.x True >>> (zope.deprecation.old_package.m2.x.__globals__ ... is zope.deprecation.new_package.m2.__dict__) True >>> zope.deprecation.old_package.m2.x.__module__ 'zope.deprecation.new_package.m2' We'll get an error if we try to import m3, because we didn't create a placeholder for it (Python 3.6 started raising ModuleNotFoundError, a subclass of ImportError with a different error message than earlier releases so we can't see that directly): .. doctest:: >>> try: ... import zope.deprecation.old_package.m3 ... except ImportError as e: ... print("No module named" in str(e)) ... print("m3" in str(e)) True True Before we move on, let's clean up the temporary modules / packages: .. doctest:: >>> zope.deprecation.__path__.remove(tmp_d) >>> import shutil >>> shutil.rmtree(tmp_d) Temporarily turning off deprecation warnings ============================================ In some cases it is desireable to turn off the deprecation warnings for a short time. To support such a feature, the ``zope.deprecation`` package provides a context manager class, :class:`zope.deprecation.Suppressor`. Code running inside the scope of a ``Suppressor`` will not emit deprecation warnings. .. doctest:: >>> from zope.deprecation import Suppressor >>> class Foo(object): ... bar = property(lambda self: 1) ... bar = deprecation.deprecated(bar, 'bar is no more.') ... blah = property(lambda self: 1) ... blah = deprecation.deprecated(blah, 'blah is no more.') >>> foo = Foo() >>> with Suppressor(): ... foo.blah 1 Note that no warning is emitted when ``foo.blah`` is accessed inside the suppressor's scope.: The suppressor is implemented in terms of a ``__show__`` object. One can ask for its status by calling it: .. doctest:: >>> from zope.deprecation import __show__ >>> __show__() True Inside a suppressor's scope, that status is always false: .. doctest:: >>> with Suppressor(): ... __show__() False .. doctest:: >>> with warnings.catch_warnings(record=True) as log: ... del warnings.filters[:] ... foo.bar 1 >>> print(log[0].message) bar is no more. If needed, your code can manage the depraction warnings manually using the ``on()`` and ``off()`` methods of the ``__show__`` object: .. doctest:: >>> __show__.off() >>> __show__() False >>> foo.blah 1 Now, you can also nest several turn-offs, so that calling ``off()`` multiple times is meaningful: .. doctest:: >>> __show__.stack [False] >>> __show__.off() >>> __show__.stack [False, False] >>> __show__.on() >>> __show__.stack [False] >>> __show__() False >>> __show__.on() >>> __show__.stack [] >>> __show__() True You can also reset ``__show__`` to ``True``: .. doctest:: >>> __show__.off() >>> __show__.off() >>> __show__() False >>> __show__.reset() >>> __show__() True Finally, you cannot call ``on()`` without having called ``off()`` before: .. doctest:: >>> __show__.on() Traceback (most recent call last): ... IndexError: pop from empty list ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1736956433.0 zope_deprecation-5.1/docs/conf.py0000644000076600000240000001744414741755021016663 0ustar00m.howitzstaff# # zope.deprecation documentation build configuration file, created by # sphinx-quickstart on Thu Apr 19 16:41:59 2012. # # 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. # sys.path.insert(0, os.path.abspath('.')) # -- General configuration ----------------------------------------------- # If your documentation needs a minimal Sphinx version, state it here. # needs_sphinx = '1.0' # Add any Sphinx extension module names here, as strings. They can be # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones. extensions = [ 'sphinx.ext.autodoc', 'sphinx.ext.doctest', 'sphinx.ext.viewcode'] # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] # The suffix of source filenames. source_suffix = '.rst' # The encoding of source files. # source_encoding = 'utf-8-sig' # The master toctree document. master_doc = 'index' # General information about the project. project = 'zope.deprecation' copyright = '2012, Zope Foundation Contributors' # 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 = '4.0' # The full version, including alpha/beta/rc tags. release = '4.0' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. # language = None # 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. exclude_patterns = ['_build'] # 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 = [] # -- 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 = 'default' # 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. If None, it defaults to # " v documentation". # html_title = None # 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 (within the static path) to use as 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'] # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, # using the given strftime format. # html_last_updated_fmt = '%b %d, %Y' # 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 = {} # 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 # Output file base name for HTML help builder. htmlhelp_basename = 'zopedeprecationdoc' # -- 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': '', } # Grouping the document tree into LaTeX files. List of tuples (source start # file, target name, title, author, documentclass [howto/manual]). latex_documents = [ ('index', 'zopedeprecation.tex', 'zope.deprecation Documentation', 'Zope Foundation Contributors', '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 = [] # 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 = [ ('index', 'zopedeprecation', 'zope.deprecation Documentation', ['Zope Foundation Contributors'], 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 = [ ('index', 'zopedeprecation', 'zope.deprecation Documentation', 'Zope Foundation Contributors', 'zopedeprecation', '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' ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1736956433.0 zope_deprecation-5.1/docs/hacking.rst0000644000076600000240000002112314741755021017507 0ustar00m.howitzstaffHacking on :mod:`zope.deprecation` ================================== Getting the Code ################ The main repository for :mod:`zope.deprecation` is in the Zope Foundation Github repository: https://github.com/zopefoundation/zope.deprecation You can get a read-only checkout from there: .. code-block:: sh $ git clone https://github.com/zopefoundation/zope.deprecation.git or fork it and get a writeable checkout of your fork: .. code-block:: sh $ git clone git@github.com/jrandom/zope.deprecation.git The project also mirrors the trunk from the Github repository as a Bazaar branch on Launchpad: https://code.launchpad.net/zope.deprecation You can branch the trunk from there using Bazaar: .. code-block:: sh $ bzr branch lp:zope.deprecation Working in a ``virtualenv`` ########################### Installing ---------- If you use the ``virtualenv`` package to create lightweight Python development environments, you can run the tests using nothing more than the ``python`` binary in a virtualenv. First, create a scratch environment: .. code-block:: sh $ /path/to/virtualenv --no-site-packages /tmp/hack-zope.deprecation Next, get this package registered as a "development egg" in the environment: .. code-block:: sh $ /tmp/hack-zope.deprecation/bin/python setup.py develop Running the tests ----------------- Run the tests using the build-in ``setuptools`` testrunner: .. code-block:: sh $ /tmp/hack-zope.deprecation/bin/python setup.py test running test .................................................... ---------------------------------------------------------------------- Ran 52 tests in 0.155s OK If you have the :mod:`nose` package installed in the virtualenv, you can use its testrunner too: .. code-block:: sh $ /tmp/hack-zope.deprecation/bin/easy_install nose ... $ /tmp/hack-zope.deprecation/bin/python setup.py nosetests running nosetests .................................................... ---------------------------------------------------------------------- Ran 52 tests in 0.155s OK or: .. code-block:: sh $ /tmp/hack-zope.deprecation/bin/nosetests .................................................... ---------------------------------------------------------------------- Ran 52 tests in 0.155s OK If you have the :mod:`coverage` pacakge installed in the virtualenv, you can see how well the tests cover the code: .. code-block:: sh $ /tmp/hack-zope.deprecation/bin/easy_install nose coverage ... $ /tmp/hack-zope.deprecation/bin/python setup.py nosetests \ --with coverage --cover-package=zope.deprecation running nosetests .................................................... Name Stmts Miss Cover Missing ------------------------------------------------------------ zope.deprecation 7 0 100% zope.deprecation.deprecation 127 0 100% zope.deprecation.fixture 1 0 100% ------------------------------------------------------------ TOTAL 135 0 100% ---------------------------------------------------------------------- Ran 52 tests in 0.155s OK Building the documentation -------------------------- :mod:`zope.deprecation` uses the nifty :mod:`Sphinx` documentation system for building its docs. Using the same virtualenv you set up to run the tests, you can build the docs: .. code-block:: sh $ /tmp/hack-zope.deprecation/bin/easy_install Sphinx ... $ bin/sphinx-build -b html -d docs/_build/doctrees docs docs/_build/html ... build succeeded. You can also test the code snippets in the documentation: .. code-block:: sh $ bin/sphinx-build -b doctest -d docs/_build/doctrees docs docs/_build/doctest ... Doctest summary =============== 89 tests 0 failures in tests 0 failures in setup code build succeeded. Testing of doctests in the sources finished, look at the \ results in _build/doctest/output.txt. Using :mod:`zc.buildout` ######################## Setting up the buildout ----------------------- :mod:`zope.deprecation` ships with its own :file:`buildout.cfg` file and :file:`bootstrap.py` for setting up a development buildout: .. code-block:: sh $ /path/to/python2.6 bootstrap.py ... Generated script '.../bin/buildout' $ bin/buildout Develop: '/home/jrandom/projects/Zope/BTK/deprecation/.' ... Generated script '.../bin/sphinx-quickstart'. Generated script '.../bin/sphinx-build'. Running the tests using ----------------------- Run the tests: .. code-block:: sh $ bin/test --all Running zope.testing.testrunner.layer.UnitTests tests: Set up zope.testing.testrunner.layer.UnitTests in 0.000 seconds. Ran 52 tests with 0 failures and 0 errors in 0.366 seconds. Tearing down left over layers: Tear down zope.testing.testrunner.layer.UnitTests in 0.000 seconds. Using :mod:`tox` ################ Running Tests on Multiple Python Versions ----------------------------------------- `tox `_ is a Python-based test automation tool designed to run tests against multiple Python versions. It creates a ``virtualenv`` for each configured version, installs the current package and configured dependencies into each ``virtualenv``, and then runs the configured commands. :mod:`zope.deprecation` configures the following :mod:`tox` environments via its ``tox.ini`` file: - The ``py26``, ``py27``, ``py33``, ``py34``, and ``pypy`` environments builds a ``virtualenv`` with ``pypy``, installs :mod:`zope.deprecation` and dependencies, and runs the tests via ``python setup.py test -q``. - The ``coverage`` environment builds a ``virtualenv`` with ``python2.6``, installs :mod:`zope.deprecation`, installs :mod:`nose` and :mod:`coverage`, and runs ``nosetests`` with statement coverage. - The ``docs`` environment builds a virtualenv with ``python2.6``, installs :mod:`zope.deprecation`, installs ``Sphinx`` and dependencies, and then builds the docs and exercises the doctest snippets. This example requires that you have a working ``python2.6`` on your path, as well as installing ``tox``: .. code-block:: sh $ tox -e py26 GLOB sdist-make: .../zope.interface/setup.py py26 sdist-reinst: .../zope.interface/.tox/dist/zope.interface-4.0.2dev.zip py26 runtests: commands[0] .......... ---------------------------------------------------------------------- Ran 52 tests in 0.155s OK ___________________________________ summary ____________________________________ py26: commands succeeded congratulations :) Running ``tox`` with no arguments runs all the configured environments, including building the docs and testing their snippets: .. code-block:: sh $ tox GLOB sdist-make: .../zope.interface/setup.py py26 sdist-reinst: .../zope.interface/.tox/dist/zope.interface-4.0.2dev.zip py26 runtests: commands[0] ... Doctest summary =============== 89 tests 0 failures in tests 0 failures in setup code 0 failures in cleanup code build succeeded. ___________________________________ summary ____________________________________ py26: commands succeeded py27: commands succeeded py32: commands succeeded pypy: commands succeeded coverage: commands succeeded docs: commands succeeded congratulations :) Contributing to :mod:`zope.deprecation` ####################################### Submitting a Bug Report ----------------------- :mod:`zope.deprecation` tracks its bugs on Github: https://github.com/zopefoundation/zope.deprecation/issues Please submit bug reports and feature requests there. Sharing Your Changes -------------------- .. note:: Please ensure that all tests are passing before you submit your code. If possible, your submission should include new tests for new features or bug fixes, although it is possible that you may have tested your new code by updating existing tests. If have made a change you would like to share, the best route is to fork the Githb repository, check out your fork, make your changes on a branch in your fork, and push it. You can then submit a pull request from your branch: https://github.com/zopefoundation/zope.deprecation/pulls If you branched the code from Launchpad using Bazaar, you have another option: you can "push" your branch to Launchpad: .. code-block:: sh $ bzr push lp:~jrandom/zope.deprecation/cool_feature After pushing your branch, you can link it to a bug report on Launchpad, or request that the maintainers merge your branch using the Launchpad "merge request" feature. ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1736956433.0 zope_deprecation-5.1/docs/index.rst0000644000076600000240000000034614741755021017216 0ustar00m.howitzstaff:mod:`zope.deprecation` Documentation ===================================== Contents: .. toctree:: :maxdepth: 2 api hacking Indices and tables ================== * :ref:`genindex` * :ref:`modindex` * :ref:`search` ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1736956433.0 zope_deprecation-5.1/docs/make.bat0000644000076600000240000001177214741755021016767 0ustar00m.howitzstaff@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. 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. linkcheck to check all external links for integrity echo. doctest to run all doctests embedded in the documentation if enabled goto end ) if "%1" == "clean" ( for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i del /q /s %BUILDDIR%\* goto end ) 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\zopedeprecation.qhcp echo.To view the help file: echo.^> assistant -collectionFile %BUILDDIR%\qthelp\zopedeprecation.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" == "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" == "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 ) :end ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1736956433.0 zope_deprecation-5.1/docs/requirements.txt0000644000076600000240000000000714741755021020633 0ustar00m.howitzstaffSphinx ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1736956433.0 zope_deprecation-5.1/pyproject.toml0000644000076600000240000000112114741755021017331 0ustar00m.howitzstaff# # Generated from: # https://github.com/zopefoundation/meta/tree/master/config/pure-python [build-system] requires = ["setuptools <= 75.6.0"] build-backend = "setuptools.build_meta" [tool.coverage.run] branch = true source = ["zope.deprecation"] [tool.coverage.report] fail_under = 99 precision = 2 ignore_errors = true show_missing = true exclude_lines = ["pragma: no cover", "pragma: nocover", "except ImportError:", "raise NotImplementedError", "if __name__ == '__main__':", "self.fail", "raise AssertionError", "raise unittest.Skip"] [tool.coverage.html] directory = "parts/htmlcov" ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1736956434.6361146 zope_deprecation-5.1/setup.cfg0000644000076600000240000000076514741755023016255 0ustar00m.howitzstaff[flake8] doctests = 1 per-file-ignores = src/zope/deprecation/__init__.py: F401 [check-manifest] ignore = .editorconfig .meta.toml docs/_build/html/_sources/* docs/_build/doctest/* [isort] force_single_line = True combine_as_imports = True sections = FUTURE,STDLIB,THIRDPARTY,ZOPE,FIRSTPARTY,LOCALFOLDER known_third_party = docutils, pkg_resources, pytz known_zope = known_first_party = default_section = ZOPE line_length = 79 lines_after_imports = 2 [egg_info] tag_build = tag_date = 0 ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1736956433.0 zope_deprecation-5.1/setup.py0000644000076600000240000000507314741755021016141 0ustar00m.howitzstaff############################################################################## # # Copyright (c) 2006 Zope Foundation and Contributors. # All Rights Reserved. # # This software is subject to the provisions of the Zope Public License, # Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # FOR A PARTICULAR PURPOSE. # ############################################################################## # This package is developed by the Zope Toolkit project, documented here: # http://docs.zope.org/zopetoolkit # When developing and releasing this package, please follow the documented # Zope Toolkit policies as described by this documentation. ############################################################################## """Setup for zope.deprecation package """ import os from setuptools import find_packages from setuptools import setup def read(*rnames): with open(os.path.join(os.path.dirname(__file__), *rnames)) as f: return f.read() setup( name='zope.deprecation', version='5.1', url='https://github.com/zopefoundation/zope.deprecation', license='ZPL 2.1', description='Zope Deprecation Infrastructure', author='Zope Corporation and Contributors', author_email='zope-dev@zope.org', long_description=( read('README.rst') + '\n\n' + read('CHANGES.rst') ), keywords=["deprecation", "deprecated", "warning"], classifiers=[ "Intended Audience :: Developers", "License :: OSI Approved :: Zope Public License", "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", "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: PyPy", "Framework :: Zope :: 3", ], package_dir={'': 'src'}, packages=find_packages('src'), namespace_packages=['zope', ], python_requires='>= 3.9', install_requires=[ 'setuptools', ], include_package_data=True, zip_safe=False, extras_require={ 'docs': ['Sphinx'], 'test': [ 'zope.testrunner', ], }, ) ././@PaxHeader0000000000000000000000000000003300000000000010211 xustar0027 mtime=1736956434.631304 zope_deprecation-5.1/src/0000755000076600000240000000000014741755023015213 5ustar00m.howitzstaff././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1736956434.6340282 zope_deprecation-5.1/src/zope/0000755000076600000240000000000014741755023016170 5ustar00m.howitzstaff././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1736956433.0 zope_deprecation-5.1/src/zope/__init__.py0000644000076600000240000000011414741755021020273 0ustar00m.howitzstaff__import__('pkg_resources').declare_namespace(__name__) # pragma: no cover ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1736956434.6353593 zope_deprecation-5.1/src/zope/deprecation/0000755000076600000240000000000014741755023020465 5ustar00m.howitzstaff././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1736956433.0 zope_deprecation-5.1/src/zope/deprecation/__init__.py0000644000076600000240000000176614741755021022606 0ustar00m.howitzstaff############################################################################## # # Copyright (c) 2005 Zope Foundation and Contributors. # All Rights Reserved. # # This software is subject to the provisions of the Zope Public License, # Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # FOR A PARTICULAR PURPOSE. # ############################################################################## """Deprecation of modules / APIs. """ __docformat__ = "reStructuredText" from zope.deprecation.deprecation import ShowSwitch from zope.deprecation.deprecation import Suppressor from zope.deprecation.deprecation import __show__ from zope.deprecation.deprecation import deprecate from zope.deprecation.deprecation import deprecated from zope.deprecation.deprecation import moved ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1736956433.0 zope_deprecation-5.1/src/zope/deprecation/deprecation.py0000644000076600000240000001566214741755021023344 0ustar00m.howitzstaff############################################################################## # # Copyright (c) 2005 Zope Foundation and Contributors. # All Rights Reserved. # # This software is subject to the provisions of the Zope Public License, # Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # FOR A PARTICULAR PURPOSE. # ############################################################################## """Deprecation Support This module provides utilities to ease the development of backward-compatible code. """ __docformat__ = "reStructuredText" import sys import types import warnings str_and_sequence_types = (str, list, tuple) class ShowSwitch: """Simple stack-based switch.""" def __init__(self): self.stack = [] def on(self): self.stack.pop() def off(self): self.stack.append(False) def reset(self): self.stack = [] def __call__(self): return self.stack == [] def __repr__(self): return '' % (self() and 'on' or 'off') # This attribute can be used to temporarily deactivate deprecation # warnings, so that backward-compatibility code can import other # backward-compatibility components without warnings being produced. __show__ = ShowSwitch() class Suppressor: def __enter__(self): __show__.off() def __exit__(self, *ignored): __show__.on() ogetattr = object.__getattribute__ class DeprecationProxy: def __init__(self, module): self.__original_module = module self.__deprecated = {} def deprecate(self, names, message, cls=DeprecationWarning): """Deprecate the given names.""" if not isinstance(names, (tuple, list)): names = (names,) for name in names: self.__deprecated[name] = (message, cls) def __getattribute__(self, name): if name == 'deprecate' or name.startswith('_DeprecationProxy__'): return ogetattr(self, name) if name == '__class__': return types.ModuleType if name in ogetattr(self, '_DeprecationProxy__deprecated'): if __show__(): msg, cls = self.__deprecated[name] warnings.warn(name + ': ' + msg, cls, 2) return getattr(ogetattr(self, '_DeprecationProxy__original_module'), name) def __setattr__(self, name, value): if name.startswith('_DeprecationProxy__'): return object.__setattr__(self, name, value) setattr(self.__original_module, name, value) def __delattr__(self, name): if name.startswith('_DeprecationProxy__'): return object.__delattr__(self, name) delattr(self.__original_module, name) class DeprecatedModule: def __init__(self, module, msg, cls=DeprecationWarning): self.__original_module = module self.__msg = msg self.__cls = cls def __getattribute__(self, name): if name.startswith('_DeprecatedModule__'): return ogetattr(self, name) if name == '__class__': return types.ModuleType if __show__(): warnings.warn(self.__msg, self.__cls, 2) return getattr(ogetattr(self, '_DeprecatedModule__original_module'), name) def __setattr__(self, name, value): if name.startswith('_DeprecatedModule__'): return object.__setattr__(self, name, value) setattr(self.__original_module, name, value) def __delattr__(self, name): if name.startswith('_DeprecatedModule__'): return object.__delattr__(self, name) delattr(self.__original_module, name) class DeprecatedGetProperty: def __init__(self, prop, message, cls=DeprecationWarning): self.message = message self.prop = prop self.cls = cls def __get__(self, inst, klass): if __show__(): warnings.warn(self.message, self.cls, 2) return self.prop.__get__(inst, klass) class DeprecatedGetSetProperty(DeprecatedGetProperty): def __set__(self, inst, prop): if __show__(): warnings.warn(self.message, self.cls, 2) self.prop.__set__(inst, prop) class DeprecatedGetSetDeleteProperty(DeprecatedGetSetProperty): def __delete__(self, inst): if __show__(): warnings.warn(self.message, self.cls, 2) self.prop.__delete__(inst) def DeprecatedMethod(method, message, cls=DeprecationWarning): def deprecated_method(*args, **kw): if __show__(): warnings.warn(message, cls, 2) return method(*args, **kw) return deprecated_method def deprecated(specifier, message, cls=DeprecationWarning): """Deprecate the given names.""" # A string specifier (or list of strings) means we're called # top-level in a module and are to deprecate things inside this # module if isinstance(specifier, str_and_sequence_types): globals = sys._getframe(1).f_globals modname = globals['__name__'] if not isinstance(sys.modules[modname], DeprecationProxy): sys.modules[modname] = DeprecationProxy(sys.modules[modname]) sys.modules[modname].deprecate(specifier, message, cls) # Anything else can mean the specifier is a function/method, # module, or just an attribute of a class elif isinstance(specifier, types.FunctionType): return DeprecatedMethod(specifier, message, cls) elif isinstance(specifier, types.ModuleType): return DeprecatedModule(specifier, message, cls) else: prop = specifier if hasattr(prop, '__get__') and hasattr(prop, '__set__') and \ hasattr(prop, '__delete__'): return DeprecatedGetSetDeleteProperty(prop, message, cls) elif hasattr(prop, '__get__') and hasattr(prop, '__set__'): return DeprecatedGetSetProperty(prop, message, cls) elif hasattr(prop, '__get__'): return DeprecatedGetProperty(prop, message, cls) class deprecate: """Deprecation decorator""" def __init__(self, msg, cls=DeprecationWarning): self.msg = msg self.cls = cls def __call__(self, func): return DeprecatedMethod(func, self.msg, self.cls) def moved(to_location, unsupported_in=None, cls=DeprecationWarning): old = sys._getframe(1).f_globals['__name__'] message = f'{old} has moved to {to_location}.' if unsupported_in: message += " Import of {} will become unsupported in {}".format( old, unsupported_in) warnings.warn(message, cls, 3) __import__(to_location) fromdict = sys.modules[to_location].__dict__ tomod = sys.modules[old] tomod.__doc__ = message for name, v in fromdict.items(): if name not in tomod.__dict__: setattr(tomod, name, v) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1736956433.0 zope_deprecation-5.1/src/zope/deprecation/fixture.py0000644000076600000240000000003114741755021022515 0ustar00m.howitzstaff# used by tests abc = 1 ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1736956433.0 zope_deprecation-5.1/src/zope/deprecation/tests.py0000644000076600000240000004774114741755021022214 0ustar00m.howitzstaffimport sys import types import unittest class TestShowSwitch(unittest.TestCase): def _makeOne(self): from zope.deprecation import ShowSwitch return ShowSwitch() def test_on(self): switch = self._makeOne() switch.stack.append(False) switch.on() self.assertEqual(switch.stack, []) def test_off(self): switch = self._makeOne() switch.off() self.assertEqual(switch.stack, [False]) def test_reset(self): switch = self._makeOne() switch.stack.append(False) switch.reset() self.assertEqual(switch.stack, []) def test_call_true(self): switch = self._makeOne() self.assertEqual(switch(), True) def test_call_false(self): switch = self._makeOne() switch.stack.append(False) self.assertEqual(switch(), False) def test_repr_on(self): switch = self._makeOne() self.assertEqual(repr(switch), '') def test_repr_off(self): switch = self._makeOne() switch.stack.append(False) self.assertEqual(repr(switch), '') def test___show__global(self): from zope.deprecation import __show__ self.assertEqual(self._makeOne().__class__, __show__.__class__) class TestSuppressor(unittest.TestCase): def _makeOne(self): from zope.deprecation import Suppressor return Suppressor() def test_it(self): from zope.deprecation import __show__ self.assertEqual(__show__.stack, []) with self._makeOne(): self.assertEqual(__show__.stack, [False]) self.assertEqual(__show__.stack, []) class WarningsSetupBase: def setUp(self): from zope.deprecation import deprecation self.oldwarnings = deprecation.warnings self.oldshow = deprecation.__show__ self.warnings = DummyWarningsModule() self.show = DummyShow() deprecation.warnings = self.warnings deprecation.__show__ = self.show def tearDown(self): from zope.deprecation import deprecation deprecation.warnings = self.oldwarnings deprecation.__show__ = self.oldshow class TestDeprecationProxy(WarningsSetupBase, unittest.TestCase): def _getTargetClass(self): from zope.deprecation.deprecation import DeprecationProxy return DeprecationProxy def _makeOne(self, module): cls = self._getTargetClass() return cls(module) def test_deprecate_and__getattribute__string(self): tests = _getTestsModule() proxy = self._makeOne(tests) proxy.deprecate('ClassFixture', 'hello') self.assertEqual(proxy.ClassFixture, ClassFixture) self.assertEqual( self.warnings.w, [('ClassFixture: hello', DeprecationWarning, 2)]) def test_deprecate_and__getattribute__string_with_custom_cls(self): tests = _getTestsModule() proxy = self._makeOne(tests) proxy.deprecate('ClassFixture', 'hello', DummyWarning) self.assertEqual(proxy.ClassFixture, ClassFixture) self.assertEqual( self.warnings.w, [('ClassFixture: hello', DummyWarning, 2)]) def test_deprecate_and__getattribute__sequence(self): tests = _getTestsModule() proxy = self._makeOne(tests) proxy.deprecate(('ClassFixture', 'ClassFixture2'), 'hello') self.assertEqual(proxy.ClassFixture, ClassFixture) self.assertEqual(proxy.ClassFixture2, ClassFixture2) self.assertEqual( self.warnings.w, [('ClassFixture: hello', DeprecationWarning, 2), ('ClassFixture2: hello', DeprecationWarning, 2)] ) def test_deprecate_and__getattribute__noshow(self): tests = _getTestsModule() proxy = self._makeOne(tests) proxy.deprecate('ClassFixture', 'hello') self.show.on = False self.assertEqual(proxy.ClassFixture, ClassFixture) self.assertEqual( self.warnings.w, []) def test___getattribute____class__(self): tests = _getTestsModule() proxy = self._makeOne(tests) self.assertEqual(proxy.__class__, types.ModuleType) def test___getattribute___deprecate(self): tests = _getTestsModule() proxy = self._makeOne(tests) self.assertEqual(type(proxy.deprecate), types.MethodType) def test___getattribute__missing(self): tests = _getTestsModule() proxy = self._makeOne(tests) self.assertRaises(AttributeError, getattr, proxy, 'wontbethere') def test___setattr__owned(self): tests = _getTestsModule() proxy = self._makeOne(tests) proxy._DeprecationProxy__deprecated = {'foo': 'bar'} self.assertEqual(proxy._DeprecationProxy__deprecated, {'foo': 'bar'}) def test___setattr__notowned(self): tests = _getTestsModule() proxy = self._makeOne(tests) try: proxy.foo = 'bar' self.assertEqual(tests.foo, 'bar') finally: del tests.foo def test___delattr__owned(self): tests = _getTestsModule() proxy = self._makeOne(tests) del proxy._DeprecationProxy__deprecated self.assertRaises(AttributeError, getattr, proxy, '_DeprecationProxy__deprecated') def test___delattr__notowned(self): tests = _getTestsModule() proxy = self._makeOne(tests) tests.foo = 'bar' del proxy.foo self.assertRaises(AttributeError, getattr, tests, 'foo') class TestDeprecatedModule(WarningsSetupBase, unittest.TestCase): def _getTargetClass(self): from zope.deprecation.deprecation import DeprecatedModule return DeprecatedModule def _makeOne(self, module, msg, *args): cls = self._getTargetClass() return cls(module, msg, *args) def test___getattribute____class__(self): tests = _getTestsModule() proxy = self._makeOne(tests, 'hello') self.assertEqual(proxy.__class__, types.ModuleType) def test___getattribute____owned__(self): tests = _getTestsModule() proxy = self._makeOne(tests, 'hello') self.assertEqual(proxy._DeprecatedModule__msg, 'hello') def test___getattribute___deprecated(self): tests = _getTestsModule() proxy = self._makeOne(tests, 'hello') self.assertEqual(proxy.ClassFixture, ClassFixture) self.assertEqual( self.warnings.w, [('hello', DeprecationWarning, 2)] ) def test___getattribute___deprecated_with_custom_cls(self): tests = _getTestsModule() proxy = self._makeOne(tests, 'hello', DummyWarning) self.assertEqual(proxy.ClassFixture, ClassFixture) self.assertEqual( self.warnings.w, [('hello', DummyWarning, 2)] ) def test___getattribute__missing(self): tests = _getTestsModule() proxy = self._makeOne(tests, 'hello') self.assertRaises(AttributeError, getattr, proxy, 'wontbethere') self.assertEqual( self.warnings.w, [('hello', DeprecationWarning, 2)] ) def test___getattribute___noshow(self): tests = _getTestsModule() self.show.on = False proxy = self._makeOne(tests, 'hello') self.assertEqual(proxy.ClassFixture, ClassFixture) self.assertEqual( self.warnings.w, []) def test___setattr__owned(self): tests = _getTestsModule() proxy = self._makeOne(tests, 'hello') proxy._DeprecatedModule__msg = 'foo' self.assertEqual(proxy._DeprecatedModule__msg, 'foo') def test___setattr__notowned(self): tests = _getTestsModule() proxy = self._makeOne(tests, 'hello') try: proxy.foo = 'bar' self.assertEqual(tests.foo, 'bar') finally: del tests.foo def test___delattr__owned(self): tests = _getTestsModule() proxy = self._makeOne(tests, 'hello') del proxy._DeprecatedModule__msg self.assertRaises(AttributeError, getattr, proxy, '_DeprecatedModule__msg') def test___delattr__notowned(self): tests = _getTestsModule() proxy = self._makeOne(tests, 'hello') tests.foo = 'bar' del proxy.foo self.assertRaises(AttributeError, getattr, tests, 'foo') class TestDeprecatedGetProperty(WarningsSetupBase, unittest.TestCase): def _getTargetClass(self): from zope.deprecation.deprecation import DeprecatedGetProperty return DeprecatedGetProperty def _makeOne(self, prop, msg, *args): cls = self._getTargetClass() return cls(prop, msg, *args) def test___get__(self): prop = DummyProperty() proxy = self._makeOne(prop, 'hello') self.assertEqual(proxy.__get__('inst', 'cls'), None) self.assertEqual(prop.inst, 'inst') self.assertEqual(prop.cls, 'cls') self.assertEqual( self.warnings.w, [('hello', DeprecationWarning, 2)] ) def test___get___with_custom_cls(self): prop = DummyProperty() proxy = self._makeOne(prop, 'hello', DummyWarning) self.assertEqual(proxy.__get__('inst', 'cls'), None) self.assertEqual(prop.inst, 'inst') self.assertEqual(prop.cls, 'cls') self.assertEqual( self.warnings.w, [('hello', DummyWarning, 2)] ) def test___get__noshow(self): prop = DummyProperty() self.show.on = False proxy = self._makeOne(prop, 'hello') self.assertEqual(proxy.__get__('inst', 'cls'), None) self.assertEqual(prop.inst, 'inst') self.assertEqual(prop.cls, 'cls') self.assertEqual(self.warnings.w, []) class TestDeprecatedGetSetProperty(TestDeprecatedGetProperty): def _getTargetClass(self): from zope.deprecation.deprecation import DeprecatedGetSetProperty return DeprecatedGetSetProperty def test___set__(self): prop = DummyProperty() proxy = self._makeOne(prop, 'hello') self.assertEqual(proxy.__set__('inst', 'prop'), None) self.assertEqual(prop.inst, 'inst') self.assertEqual(prop.prop, 'prop') self.assertEqual( self.warnings.w, [('hello', DeprecationWarning, 2)] ) def test___set___with_custom_cls(self): prop = DummyProperty() proxy = self._makeOne(prop, 'hello', DummyWarning) self.assertEqual(proxy.__set__('inst', 'prop'), None) self.assertEqual(prop.inst, 'inst') self.assertEqual(prop.prop, 'prop') self.assertEqual( self.warnings.w, [('hello', DummyWarning, 2)] ) def test___set__noshow(self): prop = DummyProperty() self.show.on = False proxy = self._makeOne(prop, 'hello') self.assertEqual(proxy.__set__('inst', 'prop'), None) self.assertEqual(prop.inst, 'inst') self.assertEqual(prop.prop, 'prop') self.assertEqual(self.warnings.w, []) class TestDeprecatedSetGetDeleteProperty(TestDeprecatedGetSetProperty): def _getTargetClass(self): from zope.deprecation.deprecation import DeprecatedGetSetDeleteProperty return DeprecatedGetSetDeleteProperty def test___delete__(self): prop = DummyProperty() proxy = self._makeOne(prop, 'hello') self.assertEqual(proxy.__delete__('inst'), None) self.assertEqual(prop.inst, 'inst') self.assertEqual( self.warnings.w, [('hello', DeprecationWarning, 2)] ) def test___delete___with_custom_cls(self): prop = DummyProperty() proxy = self._makeOne(prop, 'hello', DummyWarning) self.assertEqual(proxy.__delete__('inst'), None) self.assertEqual(prop.inst, 'inst') self.assertEqual( self.warnings.w, [('hello', DummyWarning, 2)] ) def test___delete__noshow(self): prop = DummyProperty() proxy = self._makeOne(prop, 'hello') self.assertEqual(proxy.__delete__('inst'), None) self.assertEqual(prop.inst, 'inst') self.assertEqual( self.warnings.w, [('hello', DeprecationWarning, 2)] ) class TestDeprecatedMethod(WarningsSetupBase, unittest.TestCase): def _callFUT(self, method, message, *args): from zope.deprecation.deprecation import DeprecatedMethod return DeprecatedMethod(method, message, *args) def fixture(self, a, b, c=1): return 'fixture' def test_it(self): result = self._callFUT(self.fixture, 'hello') self.assertEqual(result('a', 'b', c=2), 'fixture') self.assertEqual( self.warnings.w, [('hello', DeprecationWarning, 2)] ) def test_it_with_custom_cls(self): result = self._callFUT(self.fixture, 'hello', DummyWarning) self.assertEqual(result('a', 'b', c=2), 'fixture') self.assertEqual( self.warnings.w, [('hello', DummyWarning, 2)] ) def test_it_noshow(self): result = self._callFUT(self.fixture, 'hello') self.show.on = False self.assertEqual(result('a', 'b', c=2), 'fixture') self.assertEqual(self.warnings.w, []) class Test_deprecated(WarningsSetupBase, unittest.TestCase): def setUp(self): super().setUp() self.mod = _getTestsModule() def tearDown(self): super().tearDown() sys.modules['zope.deprecation.tests'] = self.mod def _callFUT(self, spec, message, *args): from zope.deprecation.deprecation import deprecated return deprecated(spec, message, *args) def test_string_specifier(self): self._callFUT('ClassFixture', 'hello') mod = _getTestsModule() self.assertNotEqual(mod, self.mod) self.assertEqual(mod.ClassFixture, ClassFixture) self.assertEqual( self.warnings.w, [('ClassFixture: hello', DeprecationWarning, 2)]) def test_string_specifier_with_custom_cls(self): self._callFUT('ClassFixture', 'hello', DummyWarning) mod = _getTestsModule() self.assertNotEqual(mod, self.mod) self.assertEqual(mod.ClassFixture, ClassFixture) self.assertEqual( self.warnings.w, [('ClassFixture: hello', DummyWarning, 2)]) def test_string_specifier_sys_modules_already_mutated(self): from zope.deprecation.deprecation import DeprecationProxy mod = _getTestsModule() new = sys.modules['zope.deprecation.tests'] = DeprecationProxy(mod) self._callFUT('ClassFixture', 'hello') self.assertEqual(new.ClassFixture, ClassFixture) self.assertEqual( self.warnings.w, [('ClassFixture: hello', DeprecationWarning, 2)]) def test_function_specifier(self): result = self._callFUT(functionfixture, 'hello') self.assertNotEqual(result, functionfixture) self.assertEqual(self.warnings.w, []) result() self.assertEqual( self.warnings.w, [('hello', DeprecationWarning, 2)]) def test_module_specifier(self): mod = _getTestsModule() result = self._callFUT(mod, 'hello') self.assertEqual(self.warnings.w, []) self.assertEqual(result.ClassFixture, ClassFixture) self.assertEqual( self.warnings.w, [('hello', DeprecationWarning, 2)]) def test_getproperty_specifier(self): prop = DummyGetProperty() result = self._callFUT(prop, 'hello') self.assertEqual(self.warnings.w, []) self.assertEqual(result.__get__('inst', 'cls'), None) self.assertEqual( self.warnings.w, [('hello', DeprecationWarning, 2)]) def test_getsetproperty_specifier(self): prop = DummyGetSetProperty() result = self._callFUT(prop, 'hello') self.assertEqual(self.warnings.w, []) self.assertEqual(result.__set__('inst', 'prop'), None) self.assertEqual( self.warnings.w, [('hello', DeprecationWarning, 2)]) def test_getsetdeleteproperty_specifier(self): prop = DummyGetSetDeleteProperty() result = self._callFUT(prop, 'hello') self.assertEqual(self.warnings.w, []) self.assertEqual(result.__delete__('inst'), None) self.assertEqual( self.warnings.w, [('hello', DeprecationWarning, 2)]) class Test_deprecate(WarningsSetupBase, unittest.TestCase): def _getTargetClass(self): from zope.deprecation.deprecation import deprecate return deprecate def _makeOne(self, msg, *args): cls = self._getTargetClass() return cls(msg, *args) def fixture(self): return 42 def test___call__(self): proxy = self._makeOne('hello') result = proxy(functionfixture) self.assertEqual(result(), None) self.assertEqual( self.warnings.w, [('hello', DeprecationWarning, 2)]) def test___call__method(self): proxy = self._makeOne('method') result = proxy(self.fixture) self.assertEqual(result(), 42) self.assertEqual( self.warnings.w, [('method', DeprecationWarning, 2)]) def test___call__with_custom_cls(self): proxy = self._makeOne('hello', DummyWarning) result = proxy(functionfixture) self.assertEqual(result(), None) self.assertEqual( self.warnings.w, [('hello', DummyWarning, 2)]) class Test_moved(WarningsSetupBase, unittest.TestCase): def setUp(self): super().setUp() def tearDown(self): super().tearDown() del _getTestsModule().__dict__['abc'] def _callFUT(self, to_location, unsupported_in, *args): from zope.deprecation.deprecation import moved return moved(to_location, unsupported_in, *args) def test_unsupported_None(self): self._callFUT('zope.deprecation.fixture', None) self.assertEqual( self.warnings.w, [('zope.deprecation.tests has moved to zope.deprecation.fixture.', DeprecationWarning, 3)]) def test_unsupported_None_with_custom_cls(self): self._callFUT('zope.deprecation.fixture', None, DummyWarning) self.assertEqual( self.warnings.w, [('zope.deprecation.tests has moved to zope.deprecation.fixture.', DummyWarning, 3)]) def test_unsupported_not_None(self): self._callFUT('zope.deprecation.fixture', '1.3') self.assertEqual( self.warnings.w, [('zope.deprecation.tests has moved to zope.deprecation.fixture. ' 'Import of zope.deprecation.tests will become unsupported in ' '1.3', DeprecationWarning, 3)]) class Test_import_aliases(unittest.TestCase): def test_it(self): for name in ('deprecated', 'deprecate', 'moved', 'ShowSwitch', '__show__'): real = getattr(sys.modules['zope.deprecation.deprecation'], name) alias = getattr(sys.modules['zope.deprecation'], name) self.assertEqual(real, alias, (real, alias)) class DummyWarningsModule: def __init__(self): self.w = [] def warn(self, msg, type, stacklevel): self.w.append((msg, type, stacklevel)) class DummyGetProperty: def __get__(self, inst, cls): self.inst = inst self.cls = cls class DummyGetSetProperty(DummyGetProperty): def __set__(self, inst, prop): self.inst = inst self.prop = prop class DummyGetSetDeleteProperty(DummyGetSetProperty): def __delete__(self, inst): self.inst = inst class DummyWarning(DeprecationWarning): pass DummyProperty = DummyGetSetDeleteProperty def _getTestsModule(): __import__('zope.deprecation.tests') return sys.modules['zope.deprecation.tests'] class DummyShow: def __init__(self): self.on = True def __call__(self): if self.on: return True return False class ClassFixture: pass class ClassFixture2: pass def functionfixture(): pass ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1736956434.6355498 zope_deprecation-5.1/src/zope.deprecation.egg-info/0000755000076600000240000000000014741755023022156 5ustar00m.howitzstaff././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1736956434.0 zope_deprecation-5.1/src/zope.deprecation.egg-info/PKG-INFO0000644000076600000240000001206614741755022023257 0ustar00m.howitzstaffMetadata-Version: 2.1 Name: zope.deprecation Version: 5.1 Summary: Zope Deprecation Infrastructure Home-page: https://github.com/zopefoundation/zope.deprecation Author: Zope Corporation and Contributors Author-email: zope-dev@zope.org License: ZPL 2.1 Keywords: deprecation,deprecated,warning Classifier: Intended Audience :: Developers Classifier: License :: OSI Approved :: Zope Public License 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: Programming Language :: Python :: Implementation :: CPython Classifier: Programming Language :: Python :: Implementation :: PyPy Classifier: Framework :: Zope :: 3 Requires-Python: >= 3.9 License-File: LICENSE.txt Requires-Dist: setuptools Provides-Extra: docs Requires-Dist: Sphinx; extra == "docs" Provides-Extra: test Requires-Dist: zope.testrunner; extra == "test" ====================== ``zope.deprecation`` ====================== .. image:: https://img.shields.io/pypi/v/zope.deprecation.svg :target: https://pypi.python.org/pypi/zope.deprecation/ :alt: Latest release .. image:: https://img.shields.io/pypi/pyversions/zope.deprecation.svg :target: https://pypi.org/project/zope.deprecation/ :alt: Supported Python versions .. image:: https://github.com/zopefoundation/zope.deprecation/actions/workflows/tests.yml/badge.svg :target: https://github.com/zopefoundation/zope.deprecation/actions/workflows/tests.yml .. image:: https://coveralls.io/repos/github/zopefoundation/zope.deprecation/badge.svg?branch=master :target: https://coveralls.io/github/zopefoundation/zope.deprecation?branch=master .. image:: https://readthedocs.org/projects/zopedeprecation/badge/?version=latest :target: https://zopedeprecation.readthedocs.io/en/latest/ :alt: Documentation Status This package provides a simple function called ``deprecated(names, reason)`` to mark deprecated modules, classes, functions, methods and properties. Please see https://zopedeprecation.readthedocs.io for the documentation. ================================ ``zope.deprecation`` Changelog ================================ 5.1 (2025-01-15) ================ - Add support for Python 3.12, 3.13. - Drop support for Python 3.7, 3.8. 5.0 (2023-03-29) ================ - Drop support for Python 2.7, 3.4, 3.5, 3.6. - Drop support for deprecated ``python setup.py test``. - Add support for Python 3.8, 3.9, 3.10, 3.11. 4.4.0 (2018-12-03) ================== - Add support for Python 3.7. 4.3.0 (2017-08-07) ================== - Allow custom warning classes to be specified to override the default ``DeprecationWarning``. See https://github.com/zopefoundation/zope.deprecation/pull/7 - Add support for Python 3.6. - Drop support for Python 3.3. 4.2.0 (2016-11-07) ================== - Drop support for Python 2.6 and 3.2. - Add support for Python 3.5. 4.1.2 (2015-01-13) ================== - Do not require a ``self`` parameter for deprecated functions. See: https://github.com/zopefoundation/zope.deprecation/pull/1 4.1.1 (2014-03-19) ================== - Added explicit support for Python 3.4. 4.1.0 (2013-12-20) ================== - Added a ``Suppressor`` context manager, allowing scoped suppression of deprecation warnings. - Updated ``boostrap.py`` to version 2.2. 4.0.2 (2012-12-31) ================== - Fleshed out PyPI Trove classifiers. 4.0.1 (2012-11-21) ================== - Added support for Python 3.3. 4.0.0 (2012-05-16) ================== - Automated build of Sphinx HTML docs and running doctest snippets via tox. - Added Sphinx documentation: - API docs moved from package-data README into ``docs/api.rst``. - Snippets can be tested by running 'make doctest'. - Updated support for continuous integration using ``tox`` and ``jenkins``. - 100% unit test coverage. - Added ``setup.py dev`` alias (runs ``setup.py develop`` plus installs ``nose`` and ``coverage``). - Added ``setup.py docs`` alias (installs ``Sphinx`` and dependencies). - Removed spurious dependency on ``zope.testing``. - Dropped explicit support for Python 2.4 / 2.5 / 3.1. 3.5.1 (2012-03-15) ================== - Revert a move of `README.txt` to unbreak ``zope.app.apidoc``. 3.5.0 (2011-09-05) ================== - Replaced doctesting with unit testing. - Python 3 compatibility. 3.4.1 (2011-06-07) ================== - Removed import cycle for ``__show__`` by defining it in the ``zope.deprecation.deprecation`` module. - Added support to bootstrap on Jython. - Fix ``zope.deprecation.warn()`` to make the signature identical to ``warnings.warn()`` and to check for .pyc and .pyo files. 3.4.0 (2007-07-19) ================== - Release 3.4 final, corresponding to Zope 3.4. 3.3.0 (2007-02-18) ================== - Corresponds to the version of the ``zope.deprecation`` package shipped as part of the Zope 3.3.0 release. ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1736956434.0 zope_deprecation-5.1/src/zope.deprecation.egg-info/SOURCES.txt0000644000076600000240000000135414741755022024044 0ustar00m.howitzstaff.pre-commit-config.yaml .readthedocs.yaml CHANGES.rst CONTRIBUTING.md COPYRIGHT.txt LICENSE.txt MANIFEST.in README.rst buildout.cfg pyproject.toml setup.cfg setup.py tox.ini docs/Makefile docs/api.rst docs/conf.py docs/hacking.rst docs/index.rst docs/make.bat docs/requirements.txt src/zope/__init__.py src/zope.deprecation.egg-info/PKG-INFO src/zope.deprecation.egg-info/SOURCES.txt src/zope.deprecation.egg-info/dependency_links.txt src/zope.deprecation.egg-info/namespace_packages.txt src/zope.deprecation.egg-info/not-zip-safe src/zope.deprecation.egg-info/requires.txt src/zope.deprecation.egg-info/top_level.txt src/zope/deprecation/__init__.py src/zope/deprecation/deprecation.py src/zope/deprecation/fixture.py src/zope/deprecation/tests.py././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1736956434.0 zope_deprecation-5.1/src/zope.deprecation.egg-info/dependency_links.txt0000644000076600000240000000000114741755022026223 0ustar00m.howitzstaff ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1736956434.0 zope_deprecation-5.1/src/zope.deprecation.egg-info/namespace_packages.txt0000644000076600000240000000000514741755022026503 0ustar00m.howitzstaffzope ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1736956434.0 zope_deprecation-5.1/src/zope.deprecation.egg-info/not-zip-safe0000644000076600000240000000000114741755022024403 0ustar00m.howitzstaff ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1736956434.0 zope_deprecation-5.1/src/zope.deprecation.egg-info/requires.txt0000644000076600000240000000006214741755022024553 0ustar00m.howitzstaffsetuptools [docs] Sphinx [test] zope.testrunner ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1736956434.0 zope_deprecation-5.1/src/zope.deprecation.egg-info/top_level.txt0000644000076600000240000000000514741755022024702 0ustar00m.howitzstaffzope ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1736956433.0 zope_deprecation-5.1/tox.ini0000644000076600000240000000353014741755021015736 0ustar00m.howitzstaff# Generated from: # https://github.com/zopefoundation/meta/tree/master/config/pure-python [tox] minversion = 3.18 envlist = release-check lint py39 py310 py311 py312 py313 pypy3 docs coverage [testenv] usedevelop = true package = wheel wheel_build_env = .pkg deps = setuptools <= 75.6.0 commands = zope-testrunner --test-path=src {posargs:-vc} sphinx-build -b doctest -d {envdir}/.cache/doctrees docs {envdir}/.cache/doctest extras = test docs [testenv:setuptools-latest] basepython = python3 deps = git+https://github.com/pypa/setuptools.git\#egg=setuptools [testenv:release-check] description = ensure that the distribution is ready to release basepython = python3 skip_install = true deps = setuptools <= 75.6.0 twine build check-manifest check-python-versions >= 0.20.0 wheel commands_pre = commands = check-manifest check-python-versions --only setup.py,tox.ini,.github/workflows/tests.yml python -m build --sdist --no-isolation twine check dist/* [testenv:lint] description = This env runs all linters configured in .pre-commit-config.yaml basepython = python3 skip_install = true deps = pre-commit commands_pre = commands = pre-commit run --all-files --show-diff-on-failure [testenv:docs] basepython = python3 skip_install = false commands_pre = commands = sphinx-build -b html -d docs/_build/doctrees docs docs/_build/html sphinx-build -b doctest -d docs/_build/doctrees docs docs/_build/doctest [testenv:coverage] basepython = python3 allowlist_externals = mkdir deps = coverage[toml] commands = mkdir -p {toxinidir}/parts/htmlcov coverage run -m zope.testrunner --test-path=src {posargs:-vc} coverage run -a -m sphinx -b doctest -d {envdir}/.cache/doctrees docs {envdir}/.cache/doctest coverage html coverage report