METADATA 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. Metadata-Version: 2.2
  2. Name: Deprecated
  3. Version: 1.2.18
  4. Summary: Python @deprecated decorator to deprecate old python classes, functions or methods.
  5. Home-page: https://github.com/laurent-laporte-pro/deprecated
  6. Author: Laurent LAPORTE
  7. Author-email: laurent.laporte.pro@gmail.com
  8. License: MIT
  9. Project-URL: Documentation, https://deprecated.readthedocs.io/en/latest/
  10. Project-URL: Source, https://github.com/laurent-laporte-pro/deprecated
  11. Project-URL: Bug Tracker, https://github.com/laurent-laporte-pro/deprecated/issues
  12. Keywords: deprecate,deprecated,deprecation,warning,warn,decorator
  13. Platform: any
  14. Classifier: Development Status :: 5 - Production/Stable
  15. Classifier: Environment :: Web Environment
  16. Classifier: Intended Audience :: Developers
  17. Classifier: License :: OSI Approved :: MIT License
  18. Classifier: Operating System :: OS Independent
  19. Classifier: Programming Language :: Python
  20. Classifier: Programming Language :: Python :: 2
  21. Classifier: Programming Language :: Python :: 2.7
  22. Classifier: Programming Language :: Python :: 3
  23. Classifier: Programming Language :: Python :: 3.4
  24. Classifier: Programming Language :: Python :: 3.5
  25. Classifier: Programming Language :: Python :: 3.6
  26. Classifier: Programming Language :: Python :: 3.7
  27. Classifier: Programming Language :: Python :: 3.8
  28. Classifier: Programming Language :: Python :: 3.9
  29. Classifier: Programming Language :: Python :: 3.10
  30. Classifier: Programming Language :: Python :: 3.11
  31. Classifier: Programming Language :: Python :: 3.12
  32. Classifier: Topic :: Software Development :: Libraries :: Python Modules
  33. Requires-Python: >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*
  34. Description-Content-Type: text/x-rst
  35. License-File: LICENSE.rst
  36. Requires-Dist: wrapt<2,>=1.10
  37. Provides-Extra: dev
  38. Requires-Dist: tox; extra == "dev"
  39. Requires-Dist: PyTest; extra == "dev"
  40. Requires-Dist: PyTest-Cov; extra == "dev"
  41. Requires-Dist: bump2version<1; extra == "dev"
  42. Requires-Dist: setuptools; python_version >= "3.12" and extra == "dev"
  43. Dynamic: author
  44. Dynamic: author-email
  45. Dynamic: classifier
  46. Dynamic: description
  47. Dynamic: description-content-type
  48. Dynamic: home-page
  49. Dynamic: keywords
  50. Dynamic: license
  51. Dynamic: platform
  52. Dynamic: project-url
  53. Dynamic: provides-extra
  54. Dynamic: requires-dist
  55. Dynamic: requires-python
  56. Dynamic: summary
  57. Deprecated Library
  58. ------------------
  59. Deprecated is Easy to Use
  60. `````````````````````````
  61. If you need to mark a function or a method as deprecated,
  62. you can use the ``@deprecated`` decorator:
  63. Save in a hello.py:
  64. .. code:: python
  65. from deprecated import deprecated
  66. @deprecated(version='1.2.1', reason="You should use another function")
  67. def some_old_function(x, y):
  68. return x + y
  69. class SomeClass(object):
  70. @deprecated(version='1.3.0', reason="This method is deprecated")
  71. def some_old_method(self, x, y):
  72. return x + y
  73. some_old_function(12, 34)
  74. obj = SomeClass()
  75. obj.some_old_method(5, 8)
  76. And Easy to Setup
  77. `````````````````
  78. And run it:
  79. .. code:: bash
  80. $ pip install Deprecated
  81. $ python hello.py
  82. hello.py:15: DeprecationWarning: Call to deprecated function (or staticmethod) some_old_function.
  83. (You should use another function) -- Deprecated since version 1.2.0.
  84. some_old_function(12, 34)
  85. hello.py:17: DeprecationWarning: Call to deprecated method some_old_method.
  86. (This method is deprecated) -- Deprecated since version 1.3.0.
  87. obj.some_old_method(5, 8)
  88. You can document your code
  89. ``````````````````````````
  90. Have you ever wonder how to document that some functions, classes, methods, etc. are deprecated?
  91. This is now possible with the integrated Sphinx directives:
  92. For instance, in hello_sphinx.py:
  93. .. code:: python
  94. from deprecated.sphinx import deprecated
  95. from deprecated.sphinx import versionadded
  96. from deprecated.sphinx import versionchanged
  97. @versionadded(version='1.0', reason="This function is new")
  98. def function_one():
  99. '''This is the function one'''
  100. @versionchanged(version='1.0', reason="This function is modified")
  101. def function_two():
  102. '''This is the function two'''
  103. @deprecated(version='1.0', reason="This function will be removed soon")
  104. def function_three():
  105. '''This is the function three'''
  106. function_one()
  107. function_two()
  108. function_three() # warns
  109. help(function_one)
  110. help(function_two)
  111. help(function_three)
  112. The result it immediate
  113. ```````````````````````
  114. Run it:
  115. .. code:: bash
  116. $ python hello_sphinx.py
  117. hello_sphinx.py:23: DeprecationWarning: Call to deprecated function (or staticmethod) function_three.
  118. (This function will be removed soon) -- Deprecated since version 1.0.
  119. function_three() # warns
  120. Help on function function_one in module __main__:
  121. function_one()
  122. This is the function one
  123. .. versionadded:: 1.0
  124. This function is new
  125. Help on function function_two in module __main__:
  126. function_two()
  127. This is the function two
  128. .. versionchanged:: 1.0
  129. This function is modified
  130. Help on function function_three in module __main__:
  131. function_three()
  132. This is the function three
  133. .. deprecated:: 1.0
  134. This function will be removed soon
  135. Links
  136. `````
  137. * `Python package index (PyPi) <https://pypi.org/project/Deprecated/>`_
  138. * `GitHub website <https://github.com/laurent-laporte-pro/deprecated>`_
  139. * `Read The Docs <https://readthedocs.org/projects/deprecated>`_
  140. * `EBook on Lulu.com <http://www.lulu.com/commerce/index.php?fBuyContent=21305117>`_
  141. * `StackOverFlow Q&A <https://stackoverflow.com/a/40301488/1513933>`_
  142. * `Development version
  143. <https://github.com/laurent-laporte-pro/deprecated/zipball/master#egg=Deprecated-dev>`_