pax_global_header 0000666 0000000 0000000 00000000064 13562274214 0014520 g ustar 00root root 0000000 0000000 52 comment=da40253a7509e2c7291591119d38900e6978f522
deprecated-1.2.7/ 0000775 0000000 0000000 00000000000 13562274214 0013627 5 ustar 00root root 0000000 0000000 deprecated-1.2.7/.bumpversion.cfg 0000664 0000000 0000000 00000001076 13562274214 0016743 0 ustar 00root root 0000000 0000000 [bumpversion]
current_version = 1.2.7
commit = True
tag = False
message = Prepare next version {new_version} (unreleased)
[bumpversion:file:setup.py]
search = version='{current_version}'
replace = version='{new_version}'
[bumpversion:file:deprecated/__init__.py]
search = __version__ = "{current_version}"
replace = __version__ = "{new_version}"
[bumpversion:file:docs/source/conf.py]
search = release = "{current_version}"
replace = release = "{new_version}"
[bumpversion:file:python-deprecated.spec]
search = (?<=Version:\s+){current_version}
replace = {new_version}
deprecated-1.2.7/.editorconfig 0000664 0000000 0000000 00000000327 13562274214 0016306 0 ustar 00root root 0000000 0000000 # see http://editorconfig.org
root = true
[*]
end_of_line = lf
trim_trailing_whitespace = true
insert_final_newline = true
indent_style = space
indent_size = 4
charset = utf-8
[*.{bat,cmd,ps1}]
end_of_line = crlf
deprecated-1.2.7/.github/ 0000775 0000000 0000000 00000000000 13562274214 0015167 5 ustar 00root root 0000000 0000000 deprecated-1.2.7/.github/CODE_OF_CONDUCT.md 0000664 0000000 0000000 00000006324 13562274214 0017773 0 ustar 00root root 0000000 0000000 # Contributor Covenant Code of Conduct
## Our Pledge
In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, sex characteristics, gender identity and expression,
level of experience, education, socio-economic status, nationality, personal
appearance, race, religion, or sexual identity and orientation.
## Our Standards
Examples of behavior that contributes to creating a positive environment
include:
* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting
## Our Responsibilities
Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.
Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.
## Scope
This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community. Examples of
representing a project or community include using an official project e-mail
address, posting via an official social media account, or acting as an appointed
representative at an online or offline event. Representation of a project may be
further defined and clarified by project maintainers.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at [Tantale Solutions](mailto:tantale.solutions@gmail.com). All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.
Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
[homepage]: https://www.contributor-covenant.org
deprecated-1.2.7/.github/ISSUE_TEMPLATE.md 0000664 0000000 0000000 00000001505 13562274214 0017675 0 ustar 00root root 0000000 0000000 **This issue tracker is a tool to address bugs in Deprecated itself.
Please use Stack Overflow for general questions about using Deprecated
or issues not related to Deprecated Library.**
If you'd like to report a bug in Deprecated, fill out the template below. Provide
any extra information that may be useful/related to your problem.
Ideally, create an [Minimal, Complete, and Verifiable example](http://stackoverflow.com/help/mcve),
which helps us understand the problem and helps check that it is not caused by something in your code.
---
### Expected Behavior
Tell us what should happen.
```python
# Paste a minimal example that causes the problem.
```
### Actual Behavior
Tell us what happens instead.
```pytb
Paste the full traceback if there was an exception.
```
### Environment
* Python version:
* Deprecated version:
deprecated-1.2.7/.github/PULL_REQUEST_TEMPLATE.md 0000664 0000000 0000000 00000001000 13562274214 0020757 0 ustar 00root root 0000000 0000000 Describe what this patch does to fix the issue.
Link to any relevant issues or pull requests.
deprecated-1.2.7/.gitignore 0000664 0000000 0000000 00000007600 13562274214 0015622 0 ustar 00root root 0000000 0000000
# Created by https://www.gitignore.io/api/intellij,linux,osx,pycharm,python
### Intellij ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
# User-specific stuff:
.idea/
.idea/workspace.xml
.idea/tasks.xml
.idea/dictionaries
.idea/vcs.xml
.idea/jsLibraryMappings.xml
# Sensitive or high-churn files:
.idea/dataSources.ids
.idea/dataSources.xml
.idea/dataSources.local.xml
.idea/sqlDataSources.xml
.idea/dynamic.xml
.idea/uiDesigner.xml
# Gradle:
.idea/gradle.xml
.idea/libraries
# Mongo Explorer plugin:
.idea/mongoSettings.xml
## File-based project format:
*.iws
## Plugin-specific files:
# IntelliJ
/out/
# mpeltonen/sbt-idea plugin
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
### Intellij Patch ###
# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721
# *.iml
# modules.xml
# .idea/misc.xml
# *.ipr
### Linux ###
*~
# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*
# KDE directory preferences
.directory
# Linux trash folder which might appear on any partition or disk
.Trash-*
### OSX ###
*.DS_Store
.AppleDouble
.LSOverride
# Icon must end with two \r
Icon
# Thumbnails
._*
# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
### PyCharm ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
# User-specific stuff:
.idea/workspace.xml
.idea/tasks.xml
.idea/dictionaries
.idea/vcs.xml
.idea/jsLibraryMappings.xml
# Sensitive or high-churn files:
.idea/dataSources.ids
.idea/dataSources.xml
.idea/dataSources.local.xml
.idea/sqlDataSources.xml
.idea/dynamic.xml
.idea/uiDesigner.xml
# Gradle:
.idea/gradle.xml
.idea/libraries
# Mongo Explorer plugin:
.idea/mongoSettings.xml
## File-based project format:
*.iws
## Plugin-specific files:
# IntelliJ
/out/
# mpeltonen/sbt-idea plugin
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
### PyCharm Patch ###
# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721
# *.iml
# modules.xml
# .idea/misc.xml
# *.ipr
### Python ###
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
*.egg-info/
.installed.cfg
*.egg
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*,cover
.hypothesis/
# Translations
*.mo
*.pot
# Django stuff:
*.log
local_settings.py
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
target/
# IPython Notebook
.ipynb_checkpoints
# pyenv
.python-version
# celery beat schedule file
celerybeat-schedule
# dotenv
.env
# virtualenv
venv/
ENV/
# Spyder project settings
.spyderproject
# Rope project settings
.ropeproject
.pytest_cache/
deprecated-1.2.7/.packit.yaml 0000664 0000000 0000000 00000001112 13562274214 0016037 0 ustar 00root root 0000000 0000000 specfile_path: python-deprecated.spec
synced_files:
- python-deprecated.spec
- .packit.yaml
upstream_project_name: Deprecated
downstream_package_name: python-deprecated
create_pr: false
jobs:
- job: propose_downstream
trigger: release
metadata:
dist_git_branch: master
- job: propose_downstream
trigger: release
metadata:
dist_git_branch: f30
- job: propose_downstream
trigger: release
metadata:
dist_git_branch: f29
- job: copr_build
trigger: pull_request
metadata:
targets:
- fedora-30-x86_64
- fedora-29-x86_64
- fedora-rawhide-x86_64
deprecated-1.2.7/.travis.yml 0000664 0000000 0000000 00000000501 13562274214 0015734 0 ustar 00root root 0000000 0000000 language: python
python:
# Python **2.6** and **3.3** are no more supported
- "2.7"
- "3.4"
- "3.5"
- "3.6"
- "3.7"
- "3.8"
- "3.8-dev" # 3.8 development branch
# - "pypy" # some unit tests fail
install:
- pip install tox-travis
- pip install coveralls
script:
tox
after_success:
coveralls
deprecated-1.2.7/CHANGELOG.rst 0000664 0000000 0000000 00000017150 13562274214 0015654 0 ustar 00root root 0000000 0000000 =========
Changelog
=========
All notable changes to this project will be documented in this file.
The format is based on `Keep a Changelog `_
and this project adheres to `Semantic Versioning `_.
.. note::
The library **"Python-Deprecated"** was renamed **"Deprecated"**, simply!
This project is more consistent because now, the name of the library is the same as the name of the Python package.
- In your ``setup.py``, you can replace the "Python-Deprecated" dependency with "Deprecated".
- In your source code, nothing has changed, you will always use ``import deprecated``, as before.
- I decided to keep the same version number because there is really no change in the source code
(only in comment or documentation).
v1.2.7 (2019-11-11)
===================
Bug fix release
Fix
---
- Warning displays the correct filename and line number when decorating a function if wrapt
does not have the compiled c extension.
Other
-----
- Support packit for Pull Request tests and sync to Fedora (thanks to Petr Hráček).
Supported since v1.2.6.
- Add `Black `_ configuration file.
v1.2.6 (2019-07-06)
===================
Bug fix release
Fix
---
- Fix #9: Change the project's configuration: reinforce the constraint to the Wrapt requirement.
Other
-----
- Upgrade project configuration (``setup.py``) to add the *project_urls* property:
Documentation, Source and Bug Tracker URLs.
- Change the Tox configuration to test the library against different Wrapt versions.
- Fix an issue with the AppVeyor build: upgrade setuptools version in ``appveyor.yml``,
change the Tox configuration: set ``py27,py34,py35: pip >= 9.0.3, < 19.2``.
v1.2.5 (2019-02-28)
===================
Bug fix release
Fix
---
- Fix #6: Use :func:`inspect.isroutine` to check if the wrapped object is a user-defined or built-in function or method.
Other
-----
- Upgrade Tox configuration to add support for Python 3.7.
Also, fix PyTest version for Python 2.7 and 3.4 (limited support).
Remove dependency 'requests[security]': useless to build documentation.
- Upgrade project configuration (``setup.py``) to add support for Python 3.7.
v1.2.4 (2018-11-03)
===================
Bug fix release
Fix
---
- Fix #4: Correct the class :class:`~deprecated.classic.ClassicAdapter`:
Don't pass arguments to :meth:`object.__new__` (other than *cls*).
Other
-----
- Add missing docstring to the classes :class:`~deprecated.classic.ClassicAdapter`
and :class:`~deprecated.sphinx.SphinxAdapter`.
- Change the configuration for TravisCI and AppVeyor:
drop configuration for Python **2.6** and **3.3**.
add configuration for Python **3.7** (if available).
.. note::
Deprecated is no more tested with Python **2.6** and **3.3**.
Those Python versions are EOL for some time now and incur incompatibilities
with Continuous Integration tools like TravisCI and AppVeyor.
However, this library should still work perfectly...
v1.2.3 (2018-09-12)
===================
Bug fix release
Fix
---
- Fix #3: ``deprecated.sphinx`` decorators don't update the docstring.
v1.2.2 (2018-09-04)
===================
Bug fix release
Fix
---
- Fix #2: a deprecated class is a class (not a function). Any subclass of a deprecated class is also deprecated.
- Minor fix: add missing documentation in :mod:`deprecated.sphinx` module.
v1.2.1 (2018-08-27)
===================
Bug fix release
Fix
---
- Add a ``MANIFEST.in`` file to package additional files like "LICENSE.rst" in the source distribution.
v1.2.0 (2018-04-02)
===================
Minor release
Added
-----
- Add decorators for Sphinx directive integration: ``versionadded``, ``versionchanged``, ``deprecated``.
That way, the developer can document the changes.
Changed
-------
- Add the ``version`` parameter to the ``@deprecated`` decorator:
used to specify the starting version number of the deprecation.
- Add a way to choose a ``DeprecationWarning`` subclass.
Removed
-------
- Deprecated no longer supports Python **2.6** and **3.3**. Those Python versions
are EOL for some time now and incur maintenance and compatibility costs on
the Deprecated core team, and following up with the rest of the community we
decided that they will no longer be supported starting on this version. Users
which still require those versions should pin Deprecated to ``< 1.2``.
v1.1.5 (2019-02-28)
===================
Bug fix release
Fix
---
- Fix #6: Use :func:`inspect.isroutine` to check if the wrapped object is a user-defined or built-in function or method.
Other
-----
- Upgrade Tox configuration to add support for Python 3.7.
Also, fix PyTest version for Python 2.7 and 3.4 (limited support).
Remove dependency 'requests[security]': useless to build documentation.
- Upgrade project configuration (``setup.py``) to add support for Python 3.7.
v1.1.4 (2018-11-03)
===================
Bug fix release
Fix
---
- Fix #4: Correct the function :func:`~deprecated.deprecated`:
Don't pass arguments to :meth:`object.__new__` (other than *cls*).
Other
-----
- Change the configuration for TravisCI and AppVeyor:
drop configuration for Python **2.6** and **3.3**.
add configuration for Python **3.7**.
.. note::
Deprecated is no more tested with Python **2.6** and **3.3**.
Those Python versions are EOL for some time now and incur incompatibilities
with Continuous Integration tools like TravisCI and AppVeyor.
However, this library should still work perfectly...
v1.1.3 (2018-09-03)
===================
Bug fix release
Fix
---
- Fix #2: a deprecated class is a class (not a function). Any subclass of a deprecated class is also deprecated.
v1.1.2 (2018-08-27)
===================
Bug fix release
Fix
---
- Add a ``MANIFEST.in`` file to package additional files like "LICENSE.rst" in the source distribution.
v1.1.1 (2018-04-02)
===================
Bug fix release
Fix
---
- Minor correction in ``CONTRIBUTING.rst`` for Sphinx builds: add the ``-d`` option to put apart the ``doctrees``
from the generated documentation and avoid warnings with epub generator.
- Fix in documentation configuration: remove hyphens in ``epub_identifier`` (ISBN number has no hyphens).
- Fix in Tox configuration: set the versions interval of each dependency.
Other
-----
- Change in documentation: improve sentence phrasing in the Tutorial.
- Restore the epub title to "Python Deprecated Library v1.1 Documentation" (required for Lulu.com).
v1.1.0 (2017-11-06)
===================
Minor release
Added
-----
- Change in :func:`deprecated.deprecated` decorator: you can give a "reason" message
to help the developer choose another class, function or method.
- Add support for Universal Wheel (Python versions 2.6, 2.7, 3.3, 3.4, 3.5, 3.6 and PyPy).
- Add missing ``__doc__`` and ``__version__`` attributes to :mod:`deprecated` module.
- Add an extensive documentation of Deprecated Library.
Other
-----
- Improve `Travis `_ configuration file (compatibility from Python 2.6 to 3.7-dev, and PyPy).
- Add `AppVeyor `_ configuration file.
- Add `Tox `_ configuration file.
- Add `BumpVersion `_ configuration file.
- Improve project settings: add a long description for the project.
Set the **license** and the **development status** in the classifiers property.
- Add the :file:`CONTRIBUTING.rst` file: "How to contribute to Deprecated Library".
v1.0.0 (2016-08-30)
===================
Major release
Added
-----
- **deprecated**: Created **@deprecated** decorator
deprecated-1.2.7/CONTRIBUTING.rst 0000664 0000000 0000000 00000012311 13562274214 0016266 0 ustar 00root root 0000000 0000000 How to contribute to Deprecated Library
=======================================
Thank you for considering contributing to Deprecated!
Support questions
-----------------
Please, don't use the issue tracker for this. Use one of the following
resources for questions about your own code:
* Ask on `Stack Overflow`_. Search with Google first using:
``site:stackoverflow.com deprecated decorator {search term, exception message, etc.}``
.. _Stack Overflow: https://stackoverflow.com/search?q=python+deprecated+decorator
Reporting issues
----------------
- Describe what you expected to happen.
- If possible, include a `minimal, complete, and verifiable example`_ to help
us identify the issue. This also helps check that the issue is not with your
own code.
- Describe what actually happened. Include the full traceback if there was an
exception.
- List your Python, Deprecated versions. If possible, check if this
issue is already fixed in the repository.
.. _minimal, complete, and verifiable example: https://stackoverflow.com/help/mcve
Submitting patches
------------------
- Include tests if your patch is supposed to solve a bug, and explain
clearly under which circumstances the bug happens. Make sure the test fails
without your patch.
- Try to follow `PEP8`_, but you may ignore the line length limit if following
it would make the code uglier.
First time setup
~~~~~~~~~~~~~~~~
- Download and install the `latest version of git`_.
- Configure git with your `username`_ and `email`_::
git config --global user.name 'your name'
git config --global user.email 'your email'
- Make sure you have a `GitHub account`_.
- Fork Deprecated to your GitHub account by clicking the `Fork`_ button.
- `Clone`_ your GitHub fork locally::
git clone https://github.com/{username}/deprecated.git
cd deprecated
- Add the main repository as a remote to update later::
git remote add tantale https://github.com/tantale/deprecated.git
git fetch tantale
- Create a virtualenv::
python3 -m venv env
. env/bin/activate
# or "env\Scripts\activate" on Windows
- Install Deprecated in editable mode with development dependencies::
pip install -e ".[dev]"
.. _GitHub account: https://github.com/join
.. _latest version of git: https://git-scm.com/downloads
.. _username: https://help.github.com/articles/setting-your-username-in-git/
.. _email: https://help.github.com/articles/setting-your-commit-email-address-in-git/
.. _Fork: https://github.com/tantale/deprecated#fork-destination-box
.. _Clone: https://help.github.com/articles/fork-a-repo/#step-2-create-a-local-clone-of-your-fork
Start coding
~~~~~~~~~~~~
- Create a branch to identify the issue you would like to work on (e.g.
``2287-dry-test-suite``)
- Using your favorite editor, make your changes, `committing as you go`_.
- Try to follow `PEP8`_, but you may ignore the line length limit if following
it would make the code uglier.
- Include tests that cover any code changes you make. Make sure the test fails
without your patch. `Running the tests`_.
- Push your commits to GitHub and `create a pull request`_.
- Celebrate 🎉
.. _committing as you go: http://dont-be-afraid-to-commit.readthedocs.io/en/latest/git/commandlinegit.html#commit-your-changes
.. _PEP8: https://pep8.org/
.. _create a pull request: https://help.github.com/articles/creating-a-pull-request/
Running the tests
~~~~~~~~~~~~~~~~~
Run the basic test suite with::
pytest tests/
This only runs the tests for the current environment. Whether this is relevant
depends on which part of Deprecated you're working on. Travis-CI will run the full
suite when you submit your pull request.
The full test suite takes a long time to run because it tests multiple
combinations of Python and dependencies. You need to have Python 2.7,
3.4, 3.5, 3.6, and PyPy 2.7 installed to run all of the environments (notice
that Python **2.6** and **3.3** are no more supported). Then run::
tox
Running test coverage
~~~~~~~~~~~~~~~~~~~~~
Generating a report of lines that do not have test coverage can indicate
where to start contributing. Run ``pytest`` using ``coverage`` and generate a
report on the terminal and as an interactive HTML document::
pytest --cov-report term-missing --cov-report html --cov=deprecated tests/
# then open htmlcov/index.html
Read more about `coverage `_.
Running the full test suite with ``tox`` will combine the coverage reports
from all runs.
``make`` targets
~~~~~~~~~~~~~~~~
Deprecated provides a ``Makefile`` with various shortcuts. They will ensure that
all dependencies are installed.
- ``make test`` runs the basic test suite with ``pytest``
- ``make cov`` runs the basic test suite with ``coverage``
- ``make test-all`` runs the full test suite with ``tox``
Generating the documentation
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The documentation is automatically generated with ReadTheDocs for each git push on master.
You can also generate it manually using Sphinx.
To generate the HTML documentation, run::
sphinx-build -b html -d dist/docs/doctrees docs/source/ dist/docs/html/
To generate the epub v2 documentation, run::
sphinx-build -b epub -d dist/docs/doctrees docs/source/ dist/docs/epub/
deprecated-1.2.7/LICENSE.rst 0000664 0000000 0000000 00000002071 13562274214 0015443 0 ustar 00root root 0000000 0000000 The MIT License (MIT)
Copyright (c) 2017 Laurent LAPORTE
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE. deprecated-1.2.7/MANIFEST.in 0000664 0000000 0000000 00000000365 13562274214 0015371 0 ustar 00root root 0000000 0000000 graft docs
graft deprecated
graft tests
graft .github
include .bumpversion.cfg
include .coveragerc
include .editorconfig
include *.rst
include *.yml
include Makefile
include tox.ini
global-exclude *.py[cod] __pycache__ *.so *.dylib .DS_Store
deprecated-1.2.7/Makefile 0000664 0000000 0000000 00000001415 13562274214 0015270 0 ustar 00root root 0000000 0000000 .PHONY: all install-dev test coverage cov test-all tox release-minor release-patch upload-minor upload-patch clean-pyc
all: test
install-dev:
pip install -q -e .[dev]
test: clean-pyc install-dev
pytest tests/
coverage: clean-pyc install-dev
pytest --cov-report term-missing --cov-report html --cov=deprecated tests/
cov: coverage
test-all: install-dev
tox
tox: test-all
release-minor:
bumpversion minor
python setup.py release
release-patch:
bumpversion patch
python setup.py release
upload-minor: release-minor
python setup.py upload
git push origin --tags
upload-patch: release-patch
python setup.py upload
git push origin --tags
clean-pyc:
find . -name '*.pyc' -exec rm -f {} +
find . -name '*.pyo' -exec rm -f {} +
find . -name '*~' -exec rm -f {} +
deprecated-1.2.7/README.md 0000664 0000000 0000000 00000004136 13562274214 0015112 0 ustar 00root root 0000000 0000000 # Deprecated Decorator
Python ``@deprecated`` decorator to deprecate old python classes, functions or methods.
[](https://travis-ci.org/tantale/deprecated)
[](https://ci.appveyor.com/project/tantale/deprecated)
[](https://coveralls.io/github/tantale/deprecated?branch=master)
[](https://badge.fury.io/gh/tantale%2Fdeprecated)
[](https://raw.githubusercontent.com/tantale/deprecated/master/LICENSE.rst)
[](http://deprecated.readthedocs.io/en/latest/?badge=latest)
## Installation
```shell
pip install Deprecated
```
## Usage
To use this, decorate your deprecated function with **@deprecated** decorator:
```python
from deprecated import deprecated
@deprecated
def some_old_function(x, y):
return x + y
```
You can also decorate a class or a method:
```python
from deprecated import deprecated
class SomeClass(object):
@deprecated
def some_old_method(self, x, y):
return x + y
@deprecated
class SomeOldClass(object):
pass
```
You can give a "reason" message to help the developer to choose another function/class:
```python
from deprecated import deprecated
@deprecated(reason="use another function")
def some_old_function(x, y):
return x + y
```
## Authors
The authors of this library are:
[Marcos CARDOSO](https://github.com/tantale), and
[Laurent LAPORTE](https://github.com/tantale).
The original code was made in [this StackOverflow post](https://stackoverflow.com/questions/2536307) by
[Leandro REGUEIRO](https://stackoverflow.com/users/1336250/leandro-regueiro),
[Patrizio BERTONI](https://stackoverflow.com/users/1315480/patrizio-bertoni), and
[Eric WIESER](https://stackoverflow.com/users/102441/eric).
deprecated-1.2.7/appveyor.yml 0000664 0000000 0000000 00000002631 13562274214 0016221 0 ustar 00root root 0000000 0000000 # What Python version is installed where:
# http://www.appveyor.com/docs/installed-software#python
environment:
matrix:
# Python **2.6** and **3.3** are no more supported
- PYTHON: "C:\\Python27"
TOX_ENV: "py27"
- PYTHON: "C:\\Python27-x64"
TOX_ENV: "py27"
- PYTHON: "C:\\Python34"
TOX_ENV: "py34"
- PYTHON: "C:\\Python34-x64"
TOX_ENV: "py34"
- PYTHON: "C:\\Python35"
TOX_ENV: "py35"
- PYTHON: "C:\\Python35-x64"
TOX_ENV: "py35"
- PYTHON: "C:\\Python36"
TOX_ENV: "py36"
- PYTHON: "C:\\Python36-x64"
TOX_ENV: "py36"
- PYTHON: "C:\\Python37"
TOX_ENV: "py37"
- PYTHON: "C:\\Python37-x64"
TOX_ENV: "py37"
init:
- set PATH=%PYTHON%;%PYTHON%\Scripts;C:\MinGW\msys\1.0\bin;%PATH%
- "git config --system http.sslcainfo \"C:\\Program Files\\Git\\mingw64\\ssl\\certs\\ca-bundle.crt\""
- "%PYTHON%/python -V"
- "%PYTHON%/python -c \"import struct;print(8 * struct.calcsize(\'P\'))\""
install:
- "%PYTHON%/Scripts/easy_install -U pip"
- "%PYTHON%/Scripts/pip install -U setuptools"
- "%PYTHON%/Scripts/pip install tox"
- "%PYTHON%/Scripts/pip install wheel"
build: off # Not a C# project, build stuff at the test step instead.
test_script:
- "%PYTHON%/Scripts/tox -e %TOX_ENV%"
after_test:
- "%PYTHON%/python setup.py --command-packages wheel bdist_wheel"
- ps: "ls dist"
artifacts:
- path: dist\*
deprecated-1.2.7/deprecated/ 0000775 0000000 0000000 00000000000 13562274214 0015727 5 ustar 00root root 0000000 0000000 deprecated-1.2.7/deprecated/__init__.py 0000664 0000000 0000000 00000000470 13562274214 0020041 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*-
"""
Deprecated Library
==================
Python ``@deprecated`` decorator to deprecate old python classes, functions or methods.
"""
#: Module Version Number, see `PEP 396 `_.
__version__ = "1.2.7"
from deprecated.classic import deprecated
deprecated-1.2.7/deprecated/classic.py 0000664 0000000 0000000 00000017763 13562274214 0017740 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*-
"""
Classic deprecation warning
===========================
Classic ``@deprecated`` decorator to deprecate old python classes, functions or methods.
"""
import functools
import inspect
import warnings
import wrapt
try:
# If the c extension for wrapt was compiled and wrapt/_wrappers.pyd exists, then the
# stack level that should be passed to warnings.warn should be 2. However, if using
# a pure python wrapt, a extra stacklevel is required.
import wrapt._wrappers
_stacklevel = 2
except ImportError:
_stacklevel = 3
string_types = (type(b''), type(u''))
class ClassicAdapter(wrapt.AdapterFactory):
"""
Classic adapter -- *for advanced usage only*
This adapter is used to get the deprecation message according to the wrapped object type:
class, function, standard method, static method, or class method.
This is the base class of the :class:`~deprecated.sphinx.SphinxAdapter` class
which is used to update the wrapped object docstring.
You can also inherit this class to change the deprecation message.
In the following example, we change the message into "The ... is deprecated.":
.. code-block:: python
import inspect
from deprecated.classic import ClassicAdapter
from deprecated.classic import deprecated
class MyClassicAdapter(ClassicAdapter):
def get_deprecated_msg(self, wrapped, instance):
if instance is None:
if inspect.isclass(wrapped):
fmt = "The class {name} is deprecated."
else:
fmt = "The function {name} is deprecated."
else:
if inspect.isclass(instance):
fmt = "The class method {name} is deprecated."
else:
fmt = "The method {name} is deprecated."
if self.reason:
fmt += " ({reason})"
if self.version:
fmt += " -- Deprecated since version {version}."
return fmt.format(name=wrapped.__name__,
reason=self.reason or "",
version=self.version or "")
Then, you can use your ``MyClassicAdapter`` class like this in your source code:
.. code-block:: python
@deprecated(reason="use another function", adapter_cls=MyClassicAdapter)
def some_old_function(x, y):
return x + y
"""
def __init__(self, reason="", version="", action='always', category=DeprecationWarning):
"""
Construct a wrapper adapter.
:type reason: str
:param reason:
Reason message which documents the deprecation in your library (can be omitted).
:type version: str
:param version:
Version of your project which deprecates this feature.
If you follow the `Semantic Versioning `_,
the version number has the format "MAJOR.MINOR.PATCH".
:type action: str
:param action:
A warning filter used to activate or not the deprecation warning.
Can be one of "error", "ignore", "always", "default", "module", or "once".
By default the deprecation warning is always emitted (the value is "always").
:type category: type
:param category:
The warning category to use for the deprecation warning.
By default, the category class is :class:`~DeprecationWarning`,
you can inherit this class to define your own deprecation warning category.
"""
self.reason = reason or ""
self.version = version or ""
self.action = action
self.category = category
super(ClassicAdapter, self).__init__()
def get_deprecated_msg(self, wrapped, instance):
"""
Get the deprecation warning message for the user.
:param wrapped: Wrapped class or function.
:param instance: The object to which the wrapped function was bound when it was called.
:return: The warning message.
"""
if instance is None:
if inspect.isclass(wrapped):
fmt = "Call to deprecated class {name}."
else:
fmt = "Call to deprecated function (or staticmethod) {name}."
else:
if inspect.isclass(instance):
fmt = "Call to deprecated class method {name}."
else:
fmt = "Call to deprecated method {name}."
if self.reason:
fmt += " ({reason})"
if self.version:
fmt += " -- Deprecated since version {version}."
return fmt.format(name=wrapped.__name__, reason=self.reason or "", version=self.version or "")
def __call__(self, wrapped):
"""
Decorate your class or function.
:param wrapped: Wrapped class or function.
:return: the decorated class or function.
.. versionchanged:: 1.2.4
Don't pass arguments to :meth:`object.__new__` (other than *cls*).
"""
if inspect.isclass(wrapped):
old_new1 = wrapped.__new__
def wrapped_cls(cls, *args, **kwargs):
msg = self.get_deprecated_msg(wrapped, None)
with warnings.catch_warnings():
warnings.simplefilter(self.action, self.category)
warnings.warn(msg, category=self.category, stacklevel=2)
if old_new1 is object.__new__:
return old_new1(cls)
# actually, we don't know the real signature of *old_new1*
return old_new1(*args, **kwargs)
wrapped.__new__ = classmethod(wrapped_cls)
return wrapped
def deprecated(*args, **kwargs):
"""
This is a decorator which can be used to mark functions
as deprecated. It will result in a warning being emitted
when the function is used.
**Classic usage:**
To use this, decorate your deprecated function with **@deprecated** decorator:
.. code-block:: python
from deprecated import deprecated
@deprecated
def some_old_function(x, y):
return x + y
You can also decorate a class or a method:
.. code-block:: python
from deprecated import deprecated
class SomeClass(object):
@deprecated
def some_old_method(self, x, y):
return x + y
@deprecated
class SomeOldClass(object):
pass
You can give a "reason" message to help the developer to choose another function/class,
and a "version" number to specify the starting version number of the deprecation.
.. code-block:: python
from deprecated import deprecated
@deprecated(reason="use another function", version='1.2.0')
def some_old_function(x, y):
return x + y
"""
if args and isinstance(args[0], string_types):
kwargs['reason'] = args[0]
args = args[1:]
if args and not callable(args[0]):
raise TypeError(repr(type(args[0])))
if args:
action = kwargs.get('action', 'always')
category = kwargs.get('category', DeprecationWarning)
adapter_cls = kwargs.pop('adapter_cls', ClassicAdapter)
adapter = adapter_cls(**kwargs)
wrapped = args[0]
if inspect.isclass(wrapped):
wrapped = adapter(wrapped)
return wrapped
elif inspect.isroutine(wrapped):
@wrapt.decorator(adapter=adapter)
def wrapper_function(wrapped_, instance_, args_, kwargs_):
msg = adapter.get_deprecated_msg(wrapped_, instance_)
with warnings.catch_warnings():
warnings.simplefilter(action, category)
warnings.warn(msg, category=category, stacklevel=_stacklevel)
return wrapped_(*args_, **kwargs_)
return wrapper_function(wrapped)
else:
raise TypeError(repr(type(wrapped)))
return functools.partial(deprecated, **kwargs)
deprecated-1.2.7/deprecated/sphinx.py 0000664 0000000 0000000 00000016104 13562274214 0017614 0 ustar 00root root 0000000 0000000 # coding: utf-8
"""
Sphinx directive integration
============================
We usually need to document the life-cycle of functions and classes:
when they are created, modified or deprecated.
To do that, `Sphinx `_ has a set
of `Paragraph-level markups `_:
- ``versionadded``: to document the version of the project which added the described feature to the library,
- ``versionchanged``: to document changes of a feature,
- ``deprecated``: to document a deprecated feature.
The purpose of this module is to defined decorators which adds this Sphinx directives
to the docstring of your function and classes.
Of course, the ``@deprecated`` decorator will emit a deprecation warning
when the function/method is called or the class is constructed.
"""
import textwrap
import wrapt
from deprecated.classic import ClassicAdapter
from deprecated.classic import deprecated as _classic_deprecated
class SphinxAdapter(ClassicAdapter):
"""
Sphinx adapter -- *for advanced usage only*
This adapter override the :class:`~deprecated.classic.ClassicAdapter`
in order to add the Sphinx directives to the end of the function/class docstring.
Such a directive is a `Paragraph-level markup `_
- The directive can be one of "versionadded", "versionchanged" or "deprecated".
- The version number is added if provided.
- The reason message is obviously added in the directive block if not empty.
"""
def __init__(self, directive, reason="", version="", action='always', category=DeprecationWarning):
"""
Construct a wrapper adapter.
:type directive: str
:param directive:
Sphinx directive: can be one of "versionadded", "versionchanged" or "deprecated".
:type reason: str
:param reason:
Reason message which documents the deprecation in your library (can be omitted).
:type version: str
:param version:
Version of your project which deprecates this feature.
If you follow the `Semantic Versioning `_,
the version number has the format "MAJOR.MINOR.PATCH".
:type action: str
:param action:
A warning filter used to activate or not the deprecation warning.
Can be one of "error", "ignore", "always", "default", "module", or "once".
By default the deprecation warning is always emitted (the value is "always").
:type category: type
:param category:
The warning category to use for the deprecation warning.
By default, the category class is :class:`~DeprecationWarning`,
you can inherit this class to define your own deprecation warning category.
"""
self.directive = directive
super(SphinxAdapter, self).__init__(reason=reason, version=version, action=action, category=category)
def __call__(self, wrapped):
"""
Add the Sphinx directive to your class or function.
:param wrapped: Wrapped class or function.
:return: the decorated class or function.
"""
reason = textwrap.dedent(self.reason).strip()
reason = '\n'.join(
textwrap.fill(line, width=70, initial_indent=' ', subsequent_indent=' ') for line in reason.splitlines()
).strip()
docstring = textwrap.dedent(wrapped.__doc__ or "")
if docstring:
docstring += "\n\n"
if self.version:
docstring += ".. {directive}:: {version}\n".format(directive=self.directive, version=self.version)
else:
docstring += ".. {directive}::\n".format(directive=self.directive)
if reason:
docstring += " {reason}\n".format(reason=reason)
wrapped.__doc__ = docstring
return super(SphinxAdapter, self).__call__(wrapped)
def versionadded(reason="", version=""):
"""
This decorator can be used to insert a "versionadded" directive
in your function/class docstring in order to documents the
version of the project which adds this new functionality in your library.
:param str reason:
Reason message which documents the addition in your library (can be omitted).
:param str version:
Version of your project which adds this feature.
If you follow the `Semantic Versioning `_,
the version number has the format "MAJOR.MINOR.PATCH", and,
in the case of a new functionality, the "PATCH" component should be "0".
:return: the decorated function.
"""
adapter = SphinxAdapter('versionadded', reason=reason, version=version)
# noinspection PyUnusedLocal
@wrapt.decorator(adapter=adapter)
def wrapper(wrapped, instance, args, kwargs):
return wrapped(*args, **kwargs)
return wrapper
def versionchanged(reason="", version=""):
"""
This decorator can be used to insert a "versionchanged" directive
in your function/class docstring in order to documents the
version of the project which modifies this functionality in your library.
:param str reason:
Reason message which documents the modification in your library (can be omitted).
:param str version:
Version of your project which modifies this feature.
If you follow the `Semantic Versioning `_,
the version number has the format "MAJOR.MINOR.PATCH".
:return: the decorated function.
"""
adapter = SphinxAdapter('versionchanged', reason=reason, version=version)
# noinspection PyUnusedLocal
@wrapt.decorator(adapter=adapter)
def wrapper(wrapped, instance, args, kwargs):
return wrapped(*args, **kwargs)
return wrapper
def deprecated(*args, **kwargs):
"""
This decorator can be used to insert a "deprecated" directive
in your function/class docstring in order to documents the
version of the project which deprecates this functionality in your library.
Keyword arguments can be:
- "reason":
Reason message which documents the deprecation in your library (can be omitted).
- "version":
Version of your project which deprecates this feature.
If you follow the `Semantic Versioning `_,
the version number has the format "MAJOR.MINOR.PATCH".
- "action":
A warning filter used to activate or not the deprecation warning.
Can be one of "error", "ignore", "always", "default", "module", or "once".
By default the deprecation warning is always emitted (the value is "always").
- "category":
The warning category to use for the deprecation warning.
By default, the category class is :class:`~DeprecationWarning`,
you can inherit this class to define your own deprecation warning category.
:return: the decorated function.
"""
directive = kwargs.pop('directive', 'deprecated')
adapter_cls = kwargs.pop('adapter_cls', SphinxAdapter)
return _classic_deprecated(*args, directive=directive, adapter_cls=adapter_cls, **kwargs)
deprecated-1.2.7/docs/ 0000775 0000000 0000000 00000000000 13562274214 0014557 5 ustar 00root root 0000000 0000000 deprecated-1.2.7/docs/blurb.rst 0000664 0000000 0000000 00000000773 13562274214 0016426 0 ustar 00root root 0000000 0000000 If you need to mark a function, a class or a method as deprecated, you can use the @deprecated decorator.
This documentation explains how to install and use the Deprecated Library.
It includes a detailed tutorial and simple use cases.
You will also have all the keys to contribute to the source code development.
Why should you pay for this documentation? This a way to donate to the Deprecated Library project.
Your gratitude and financial help will be motivating to continue the project’s development.
deprecated-1.2.7/docs/cover/ 0000775 0000000 0000000 00000000000 13562274214 0015675 5 ustar 00root root 0000000 0000000 deprecated-1.2.7/docs/cover/paper_10.jpeg 0000664 0000000 0000000 00010647637 13562274214 0020203 0 ustar 00root root 0000000 0000000 JFIF H H #rExif II* z ( 2 i $# Canon Canon EOS DIGITAL REBEL XS H H 2017:08:22 23:42:25 : B " ' 0221 J ^
r z
| \ ! 06 06 06 0100 0
# " " <