Commit Graph

41 Commits

Author SHA1 Message Date
Stephen Finucane a6b46c5f01 Remove references to Python 2 objects
These are no longer necessary in a Python 3-only world.

Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
Change-Id: Ia3eda6d451b673f3eafba1aa3ecd2e51b7038f1f
2022-02-11 17:25:03 +00:00
Stephen Finucane 2d4025b002 Remove unnecessary 'coding' lines
Everything is unicode in Python 3. No need for these anymore.

Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
Change-Id: I722095c41c8e014b38bfbb16aaecae0023fcf3a8
2021-11-04 10:45:02 +00:00
Stephen Finucane d0b61a66b5 Remove six
debtcollector is one of the few remaining OpenStack libraries still
using six. Like the other libraries that have since removed it,
debtcollector no longer actually needs this since it only supports
Python 3. Remove the library.

Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
Change-Id: Ia16572985a46afe39b53a199ebabb695cd05ae2d
2021-11-04 10:43:07 +00:00
Takashi Kajinami 0bf5bf5f2a Replace deprecated inspect.getargspec
inspect.getargspec was deprecated since Python 3.0 and
inspect.getfullargspec is its replacement with correct handling of
function annotations and keyword-only parameters[1].

[1] https://docs.python.org/3/library/inspect.html#inspect.getargspec

Change-Id: Ifc98b578c4cb6f917e1fc62177fd09ff4d25b6d4
2021-07-15 20:52:57 +09:00
Dmitry Tantsur 75487624e7 Remove runtime dependency on pbr
Pbr is a very heavy package to depend on. It requires git-core, which is
16 MiB on my Fedora. We only use it to detect the version, which can be
done without pbr using a much lighter importlib_metadata.

Copied from https://review.opendev.org/c/openstack/osprofiler/+/739379

Change-Id: Ib10180732042bda254b058b94c9ff41f5c31c3cb
2021-04-26 09:25:23 +02:00
Hervé Beraud 17ab8c01a8 Stop to use the __future__ module.
The __future__ module [1] was used in this context to ensure compatibility
between python 2 and python 3.

We previously dropped the support of python 2.7 [2] and now we only support
python 3 so we don't need to continue to use this module and the imports
listed below.

Imports commonly used and their related PEPs:
- `division` is related to PEP 238 [3]
- `print_function` is related to PEP 3105 [4]
- `unicode_literals` is related to PEP 3112 [5]
- `with_statement` is related to PEP 343 [6]
- `absolute_import` is related to PEP 328 [7]

[1] https://docs.python.org/3/library/__future__.html
[2] https://governance.openstack.org/tc/goals/selected/ussuri/drop-py27.html
[3] https://www.python.org/dev/peps/pep-0238
[4] https://www.python.org/dev/peps/pep-3105
[5] https://www.python.org/dev/peps/pep-3112
[6] https://www.python.org/dev/peps/pep-0343
[7] https://www.python.org/dev/peps/pep-0328

Change-Id: I2b2f006e0ec145730bec843add4147345797b920
2020-06-02 20:09:50 +02:00
Andreas Jaeger 266192b11b Switch to Victoria tests
This repo has been using train tests and thus was missed by the bot to
update from ussuri to victoria, update manually.

See also the PTI in governance [1].

Fix pep8 failure in debtcollector/updating.py and remove six from the
file.

[1]: https://governance.openstack.org/tc/reference/project-testing-interface.html

Change-Id: I9d07da7c5729f7ed33cc25f27cf70a7a41d1214c
2020-05-09 14:39:58 +02:00
Thomas Bechtold da416d64e2 Do not require oslotest for testing
oslotest itself depends on debtcollector and debtcollector depends
on oslotest. That's a cycle dependency which makes bootstrapping the whole
module chain more difficult.
Instead of using oslotest, just use the standard unittest.TestCase class
as base to break the dependency cycle.

Change-Id: Idcbe727883fe2742d62d463bb9a195592aeaba09
2017-05-22 17:04:30 +02:00
Pierre-André MOREY 25c360187c Fix a typo in comment
Change-Id: I11bc4bc60932b22d852ea633bdee9b8344a2c3e5
2016-08-26 13:42:51 +02:00
Brant Knudson fe22a47e95 Fix renamed_kwarg to preserve argspec
renamed_kwarg is fixed so that the function reports the original
argspec.

Change-Id: I0ef289c27c6f754afc16985164aa90a4a04867b3
2016-04-14 20:48:34 -05:00
Brant Knudson 1f5816ad02 Add tests for decorated argspec preservation
Tests are added that show that several of the decorators, when
used on functions, lose the argspec. This causes the documentation
to be generated incorrectly since the args aren't shown for
decorated functions.

The tests show that some of the decorators work as expected.

Change-Id: Id024f5110082a88c30e71e991764320b3aed07aa
2016-04-14 16:00:33 -05:00
Graham Hayes 35601ed1b4 Add updated_kwarg_default_value decorator
Change-Id: I472aee4ee945b16bed48e86136a2e861fd50bb9f
2016-01-07 14:36:52 +00:00
Jamie Lennox 2e00a99a7f Allow replacing a keyword argument
Specifying replace=True to renames.renamed_kwarg will substitute the
kwarg from the old to the new. This will allow for an argument to be
renamed and the positional argument still maintained in the case of a
direct rename.

Change-Id: Ibff3cc2bc3f35142f6415372f795890148898fa2
2016-01-06 12:20:09 +11:00
Joshua Harlow fc0304e2a6 Add 'removed_class' class decorator
To augment the problems with @remove on classes, see
bug #1520397 and bug #1500851 introduce a class decorator
that is specifically made for removing existing
classes (and it appears to work correctly even
under inheritance).

Related-Bug: #1520397

Related-Bug: #1500851

Change-Id: I91adbdacc9fc77511d3f0bfb66d558269c49f885
2015-12-30 21:30:30 -08:00
Jenkins 0132731a38 Merge "Add 'moved_read_only_property' descriptor" 2015-12-04 12:59:00 +00:00
Jenkins 34f4777298 Merge "Update get_class_name from olso.utils" 2015-12-02 20:25:22 +00:00
Joshua Harlow ca1481ab4c Add removals.remove note about metaclasses
Change-Id: Ie9264e1b33fd25760d40ae8fd5a2dbfb4b759a22
2015-11-30 16:57:48 -08:00
ChangBo Guo(gcb) 4a176c83e3 Update get_class_name from olso.utils
We recently Fixed get_class_name() in Python 3 in
7ef6a8fbf98a5da61c40989cc63c0c2261dca98e, sync this
to debtcollector.

Change-Id: I9d4031faa72bc2d464cb130bf82873d47c259a43
2015-11-19 20:27:15 +08:00
Joshua Harlow e0019806b1 Add 'moved_read_only_property' descriptor
For when a existing property (class property or
instance property) has been renamed it is quite
useful to be able to deprecate the old name/location
and let users that access that property know when
they read the property what the new location is.

This adds a new descriptor that emits such a
warning in a format that matches the rest of the
debtcollector functions/decorators/descriptors.

Change-Id: I9305ba512856e957c06996b637acb4a8c4fa5d04
2015-11-11 15:29:29 -08:00
Jenkins ee5c71197a Merge "Add ability to disable warnings being emitted" 2015-10-17 03:14:54 +00:00
Jenkins 09c7829f4d Merge "Add a 'removed_property' descriptor class" 2015-10-17 03:07:36 +00:00
Joshua Harlow 5fc9662d6c Add ability to disable warnings being emitted
Provide a helpful fixture that can be used
to disable warnings being output, for testing, or other
purporses.

Closes-Bug: #1503918

Change-Id: I2e1fd6f427ff6ee6d0b11b86ac2ff1b75dc0548c
2015-10-08 17:29:25 -07:00
Joshua Harlow 3ab532f175 Add a 'removed_property' descriptor class
Closes-Bug: #1478678

Change-Id: Ibc04e83b7d3b027471bb80de61ca27bb45aa18bf
2015-10-07 17:03:31 -07:00
Joshua Harlow f0f1fce2a2 Add a moved function helper
This is useful for moving functions to newer names
or newer modules/locations and retaining the old function
so that the old function proxies to the new function and
emits a deprecation warning when it is called.

Also fixes how the 'get_callable_name' needs to filter
for none, as it appears that when ran under sphinx the
'__module__' attribute is set to none and this causes
issues when joining into a string.

Change-Id: I290f1b71c141c6647da1750aec348ea590a8d9bd
2015-08-28 11:20:19 -07:00
Joshua Harlow 90799975b4 Expose a top level 'deprecate' function
To make it possible for easy usage of the message generating
formats that debtcollector uses, allow users to call into a
helper function that can be used to deprecate arbitrary things.

Closes-Bug: 1478676

Change-Id: I4d5b8fe44150ce2d6d5418a9f4e13812e6b558ce
2015-07-28 17:42:33 -07:00
Joshua Harlow 347369e758 Improve + test keyword argument @classmethod removal
Closes-Bug: 1478677

Change-Id: I61655c439e5e6f9878bedfef87518465482afc6d
2015-07-27 23:15:07 +00:00
Jamie Lennox 8f4100aac7 Remove oslo.utils dependency
There are two reasons to remove oslo.utils:

 * oslo.utils brings in a number of dependencies that are not required
   by any debtcollector code paths. This is a concern for having
   debtcollector be adopted by libraries that want to maintain minimal
   external requirements.

 * oslo.utils now has a dependency on debtcollector. While this doesn't
   seem to cause any problems with pip it is a weird circular dependency
   that is best to break.

Copy the required reflection methods from oslo.utils to debtcollector
and the associated tests and remove the oslo.utils dependency.

Change-Id: Id4d8f4f7466775d099ab1e82b38605e98e6d840d
2015-05-26 16:05:06 +10:00
Joshua Harlow aa2e0001b7 Ensure that the incoming 'new_class' is actually a class
Change-Id: If961874873a3407d3f5293dc5c5f38ae43abf190
2015-05-05 12:53:44 -07:00
Joshua Harlow 719ea2249a Allow providing the deprecation category
Instead of always using 'DeprecationWarning' it can be useful
to allow for 'PendingDeprecationWarning' to be used instead (or
other category); so enable this category passing and usage
by providing yet another keyword argument (that when not provided
defaults to 'DeprecationWarning').

Change-Id: I6719afd44bae99da31d09d429f8aa9402af194fc
2015-05-04 11:37:09 -07:00
Joshua Harlow 3afa86440f No longer need to workaround six issue/bug
Change-Id: If949f99ad23c49a70958c736949ee640346e60bd
2015-04-10 17:37:16 -07:00
Joshua Harlow f3ea4d40c5 Add a removed module deprecation helper
When a module will be removed in the future add a way
to emit a deprecation warning that this is occuring (with
the option to specify a replacement) for use-cases where
this is nice to provide.

Change-Id: Ibcb3657c8fa5d23494840d22de248938383415f5
2015-03-03 17:21:05 -08:00
Jenkins fa90ce615c Merge "Format the method/class removals messages like the others" 2015-03-04 00:55:15 +00:00
Jenkins fc4adca561 Merge "Add a 'removed_kwarg' function/method decorator" 2015-03-03 22:43:10 +00:00
Joe Gordon bab8a5b26a Move to hacking 0.10
Release notes:
http://lists.openstack.org/pipermail/openstack-dev/2015-January/054165.html

Remove deleted hacking rules from tox.ini (H803)

Change-Id: I5135a05cddd2fe185c0603e311b44ead3849e439
2015-02-12 16:01:44 -08:00
Joshua Harlow 3d9e38f750 Add a 'removed_kwarg' function/method decorator
It is quite often useful to deprecate a keyword argument
so that it can be either removed or replaced in the near
future; so a decorator that aids in this pattern can be
quite useful for others.

Change-Id: Ic57f93722b113c2aa900b2b92aa90174aadc7904
2015-02-12 14:24:42 -08:00
Joshua Harlow f4abeaeb41 Format the method/class removals messages like the others
To be more consistent with the moved messages in that module
have function/method messages that are decoratored end in () and
have the thing being decorated name be in single quotes.

Change-Id: Ia3ba4c426d47bd36eb76f7f9df7144f5db821582
2015-02-11 16:28:12 -08:00
Matthew Treinish 497c1b47be Add a removal decorator
This commit adds a new decorator to mark a function/class as
deprecated in preparation for it's removal.

Change-Id: I4c3cf3ff9abdd7faefeae907a8b73608123fb09d
2015-02-09 22:54:57 +00:00
Joshua Harlow 31733373e1 Add a moved *instance* method deprecation pattern
When an instance method has moved to a better location (for
whatever reason) it is nice to provide the old instance method
under the previous name for a deprecation cycle. To enable
this kind of pattern use/modify/extend the existing moved decorator
to not just work for properties but also work for instance methods.

Change-Id: Ie002d9255d9e5127011c5308c7f5ce16d0b44821
2015-01-28 18:55:59 +00:00
Joshua Harlow b833207aaa Initial import of renames/moves + tests
This adds the initial import (and adjustments to requirements
and code) that was initially targeted to land into oslo.utils
but now lands in this project from the following:

https://review.openstack.org/#/c/140119

This forms the basis of the debtcollector functionality (with
more to come as/when needed).

Change-Id: Icd62622a728525fab48ba4de7ee746d0add73b9b
2015-01-28 10:55:10 -08:00
Joshua Harlow 493c200a05 Add a .gitreview file with correct values
Also fixes some pep8/flake8 errors so that
this will merge correctly.

Change-Id: I516badbf8890f8231469f54af929f40af7d81afe
2015-01-20 10:33:53 -08:00
Joshua Harlow 2c4e7d58dd Initial commit 2014-12-12 22:26:59 -08:00