Commit Graph

283 Commits

Author SHA1 Message Date
Zuul 7f363061e8 Merge "Replace usage of pytz" 2024-03-13 03:58:59 +00:00
Takashi Kajinami 84dacbe8df Replace usage of pytz
The current usage can be replaced by built-in datatime module.

pytz is not currently in test requirements and it is no longer required
by oslo.utils in Python 3.11.

Change-Id: Ib490f5aebc5c84daf28edc3698694d70a74a4715
2024-03-12 22:58:21 +09:00
Takashi Kajinami 4c15915051 Bump hacking
hacking 3.1.x is too old.

Change-Id: I40369a5eef87cb6a356e059e005eb417ec67bb84
2024-01-26 01:21:59 +09:00
Hervé Beraud f78601fd8e Bump bandit and make oslo.versionedobjects compatible with latest rules
Change-Id: I3da9745c8f9f4b5832f41933af6f177b0f876bb5
2023-07-12 10:32:07 +00:00
Cyril Roelandt 2b1202938a Python3.11: Do not use inspect.ArgSpec
Python3.11 will remove inspect.ArgSpec and cause test failures on the
CI.

Closes-Bug: #1982851
Change-Id: I4bc4ab6cfeb3d15072145aa093d3407f35ddf41e
2022-07-26 16:40:16 +02:00
songwenping d901c42655 Remove unnecessary unicode prefixes
Change-Id: If5bc9397a87cc8d4260e50b793ed352dbd012c0c
2022-04-19 19:36:41 +08:00
Takashi Kajinami 07fd2f2c47 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: I29478df88665ee5311e3ba308ab645c47e5b0fc8
2021-07-19 09:58:51 +09:00
Takashi Kajinami 63cdc14853 Do not patch inspect.argspec directly
This fixes the leftover of c1933306dd
and makes the get_method_spec method patched instead of inspect.argspec
because now the method wraps call to inspect.argspec.

Change-Id: Id3c18d151a6f239f7ceff4e0b24f4006963827ea
2021-07-16 11:29:59 +09:00
Ade Lee 9f0f31eb8b Replace md5 with oslo version
md5 is not an approved algorithm in FIPS mode, and trying to
instantiate a hashlib.md5() will fail when the system is running in
FIPS mode.

md5 is allowed when in a non-security context.  There is a plan to
add a keyword parameter (usedforsecurity) to hashlib.md5() to annotate
whether or not the instance is being used in a security context.

In the case where it is not, the instantiation of md5 will be allowed.
See https://bugs.python.org/issue9216 for more details.

Some downstream python versions already support this parameter.  To
support these versions, a new encapsulation of md5() has been added to
oslo_utils.  See https://review.opendev.org/#/c/750031/

This patch is to replace the instances of hashlib.md5() with this new
encapsulation, adding an annotation indicating whether the usage is
a security context or not.

In this case, md5 is computed as one of the object hashes for the
purposes of object versioning.

Change-Id: Idf36897d690a20d23123950618643d0b9e085f6c
Depends-On: https://review.opendev.org/#/c/760160
2020-10-29 13:30:07 -04:00
Zuul 8db6962883 Merge "[goal] Migrate testing to ubuntu focal" 2020-09-11 01:42:51 +00:00
Ghanshyam Mann acc0b29605 [goal] Migrate testing to ubuntu focal
As per victoria cycle testing runtime and community goal[1]
we need to migrate upstream CI/CD to Ubuntu Focal(20.04).

Fixing:
- bug#1886298
Bump the lower constraints for required deps which added python3.8 support
in their later version.

- add noqa for F811 error


Story: #2007865
Task: #40207

Closes-Bug: #1886298

[1] https://governance.openstack.org/tc/goals/selected/victoria/migrate-ci-cd-jobs-to-ubuntu-focal.h>

Change-Id: I700c395f63921bf03c80e67c149dd980d0848163
2020-09-06 00:52:10 +00:00
Moisés Guimarães de Medeiros 90e0c5b045 Bump bandit version
This patch bumps bandit allowed version to >=1.6.0,<1.7.0 in order to
avoid the errors detailed here https://github.com/PyCQA/bandit/pull/393

Change-Id: I005962a63341bb8585141dfe5dcff3ea79560b87
Signed-off-by: Moisés Guimarães de Medeiros <moguimar@redhat.com>
2020-07-25 13:43:49 +02:00
Hervé Beraud b7cf243fb9 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: Ifd5fabb3e5f56b61b056d8a90e5b64406b9d29eb
2020-06-02 20:41:50 +02:00
OpenStack Proposal Bot f1cc6d3239 Imported Translations from Zanata
For more information about this automatic import see:
https://docs.openstack.org/i18n/latest/reviewing-translation-import.html

Change-Id: Icca83ad3a75582e2c78267f06ea9ceb66374683e
2020-05-22 09:23:21 +00:00
Andreas Jaeger d459c3fe4b Update hacking for Python3
The repo is Python 3 now, so update hacking to version 3.1.0 which
supports Python 3.

Fix problems found.

Remove hacking and friends from lower-constraints, they are not needed
for installation.

Change-Id: I810e4c30513746bc46a3e65b398539929a7ac6b0
2020-05-16 19:29:41 +02:00
Stephen Finucane b59f459d36 trivial: Mock warnings
These were being spewed by zuul.

Change-Id: Ifaf41d074d0b43a64c414a1d21cf17c3bbc9f2fa
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2020-04-23 15:24:32 +01:00
Sean McGinnis 4d2310b2a9
Use unittest.mock instead of third party mock
Now that we no longer support py27, we can use the standard library
unittest.mock module instead of the third party mock lib.

Change-Id: I26f2df6d4657133a5c7e6ed85298aa843c1bdd73
Signed-off-by: Sean McGinnis <sean.mcginnis@gmail.com>
2020-03-31 15:56:19 -05:00
Zuul 79b3d5bb5a Merge "Handle unregistered nested objects" 2020-03-07 20:58:38 +00:00
Dan Smith c1933306dd Provide stable getargspec() behavior for method fingerprinting
Python3 has deprecated inspect.getargspec(), which our fixture uses
to provide fingerprinting for remotable methods. Since the hashesh for
those methods are stored in the wild and are used to detect when objects
change in incompatible ways, it is desirable to avoid having to change
all stored hashes when a library adopts the newer method.

This change attempts to use the older spec format when possible to
avoid needless hash changes, and opts for the newer one when necessary
to represent some newer feature. Changing hashes when adding such a feature
to a remotable method is implied anyway, so getting the newer one based
on the newer method is expected.

Change-Id: I84b4ce9c95d6ab86c58f8d797dba28201c1f1668
2020-02-07 10:37:24 -08:00
Stephen Finucane 298c5107eb Bump to hacking 2.x
This allows us to use a new version of flake8 that supports Python
3-only syntax. Existing issues are resolved.

Change-Id: I5de7e5cde6a5260f4e7e57586952256b59d3756d
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2020-02-07 10:35:08 -08:00
Stephen Finucane da7cd17a2b Drop use of six
We no longer need much of the functionality this was providing.

Change-Id: I0f625b714950a712249757906974715358f9e6c6
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2020-02-07 10:35:08 -08:00
Stephen Finucane bbceb088eb Handle unregistered nested objects
The 'obj_tree_get_versions' function is used by e.g. the
'test_compatibility_routines' fixture to sanity check object versioning
and we don't do things like remove objects that are referenced
elsewhere. Unfortunately if we do this exact thing, an unhelpful
'IndexError' is raised. Handle things better and raise a specific
exception with hints towards what may be the root cause.

Change-Id: I7c05c648a9efb018ef9718fa31a9cc075482db59
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
Closes-bug: #1860652
2020-01-23 11:21:25 +00:00
Rodolfo Alonso Hernandez f806dda675 Import ABCs from collections.abc
From the deprecation warning message:
"Using or importing the ABCs from 'collections' instead of from
'collections.abc' is deprecated since Python 3.3, and in 3.9 it
will stop working"

Change-Id: I53b11ebe81977d13a460cdf167ba37c5d3e1bdcd
Closes-Bug: #1856882
2019-12-18 18:22:16 +00:00
Sean McGinnis 37473e3afa
Fix deprecation warnings
This addresses a couple sources of deprecation warnings in the code.

The collections package has moved abstract base classes from
collections.* to collections.abc.*. Use of the old path causes
DeprecationWarning messages now, but will eventually be removed. Six
does not support this yet, so for now just try the newer preferred path
and fall back to the old path if the import fails.

This also addresses unit test deprecation methods with self.skip()
changing to self.skipTest().

Change-Id: I0463ab2109adeee6468261f9e96225766a55998e
Signed-off-by: Sean McGinnis <sean.mcginnis@gmail.com>
2019-04-09 15:18:14 -05:00
Zuul c45d34823a Merge "Allow lists to be generated from any non-string iterable" 2019-02-25 17:29:33 +00:00
Doug Wiegley bc203115b1
Allow lists to be generated from any non-string iterable
The type check on the list field requires a list, though many
objects can be trivially iterated as lists, like sqlalchemy
lazy query objects. Relax the check slightly to fit a broader
range of "lists".

Change-Id: I514a0e6d445e9a14e3c0279b4e9bebfa0940337d
2019-02-18 09:50:59 -07:00
ZhijunWei e2f25b563e Update hacking version
Use latest release 1.1.0 and compatible changes w.r.t pep8

Change-Id: Ie245c376f126b885dcf8e9bb250355f98613a6a4
2019-02-17 11:24:12 +08:00
Zuul 8c989ebc64 Merge "Lower ObjectVersionChecker logging to DEBUG level" 2019-02-13 22:20:46 +00:00
Matt Riedemann 1fbd1b557a Lower ObjectVersionChecker logging to DEBUG level
The ObjectVersionChecker fixture is logging object
comparison at INFO which in some tests can blow up
the subunit output stream capture parser (see nova
bug 1813147). This change drops the logging level
to DEBUG which can be enabled using the OS_DEBUG
environment variable found in oslotest.

Change-Id: If20663ecad19f18f22172ae489206b42489fd9f6
Closes-Bug: #1815223
2019-02-08 12:32:53 -05:00
Matt Riedemann 6d62263009 Add ListOfUUIDField
This adds a simple ListOfUUIDField which is copied from
kuryr-kubernetes and is also needed in nova.

Change-Id: Ife866af6e07c887774689fd98ac6fde6fa55d6de
2019-02-04 17:00:30 +00:00
OpenStack Proposal Bot 8080113f05 Imported Translations from Zanata
For more information about this automatic import see:
https://docs.openstack.org/i18n/latest/reviewing-translation-import.html

Change-Id: I0ef964a0a6b7ba0ef4424c0b4a71315ad6f2a73f
2018-08-13 07:05:11 +00:00
Zuul 85e4fcabe1 Merge "Make the hash of a defaulted set field stable" 2018-06-20 03:39:38 +00:00
Zuul 1df5414618 Merge "Add support version in exception output" 2018-06-14 22:51:03 +00:00
Balazs Gibizer ad962c05be Make the hash of a defaulted set field stable
The string representation of an empty set is different between py27 and
py35. The ObjectVersionChecker uses the string represenation of the
default value of the fields as input for the hash of the object. This
makes hash of an object with a set field defaulted to an empty set
unstable.

This patch enhances the repr generation of the Field object to avoid the
unstable hash situation.

Change-Id: Ie9519c1893175614d60af97b635e6ff57f2b0d7d
Closes-Bug: #1771804
2018-06-01 16:08:31 +02:00
jichen fe2207f9f3 Add support version in exception output
The latest version of Incompatible check exception Shows
in the exception output but the supported version is not listed.

Change-Id: Ia9f433342b1b233e119613470a829608085de10c
Related-Bug: 1773393
2018-05-28 14:03:34 +08:00
Charles Short eca8c7c039 Remove moxstubout usage
In newer versions of oslotest, moxstubout will be deprecated.
So we can get out in front of the curve now and remove it.

Change-Id: I7b39aa52d3051e81a908277a6fc956d680d653e7
Signed-off-by: Charles Short <zulcss@gmail.com>
2018-05-17 22:12:53 -04:00
Zuul abd4d930f7 Merge "set default python to python3" 2018-04-17 14:58:16 +00:00
Doug Hellmann 151296d66b set default python to python3
Set the default python to python3 except for the py27 environment. We
have to set that explicitly to override the new default.

Because flake8 runs under python 3, where the type "long" has been
merged into int(), we have to ignore the error from the undefined name
in one of the tests.

Change-Id: I86ae7f83d17724d74bae7102dd1775eceb82599d
Signed-off-by: Doug Hellmann <doug@doughellmann.com>
2018-04-16 14:49:20 -04:00
Sean McGinnis b719764ba8 Don't force unicode strings for UUID coercion
Change Ic6b6308fb1960ec40407e6efde30137b64543e72 attempts to
fix difference between Python 2 and Python 3 values by switching
from using str() to formatting into a unicode string (u"%s").

This is equivalent to changing str() to unicode(), but that is
not correct for expected default string types for Python 2.
This requires either using six.text_type(), or just formatting
into a string, without forcing unicode ("%s"), to be correct on
either runtime.

Change-Id: I178f14cdc670d7a696778891e587ef75de208fc2
Closes-bug: #1763179
2018-04-11 21:05:58 +00:00
Seyeong Kim b1d0b5d886 Fixing UUID coerce function for unicode non uuid form
If we use non uuid unicode user id in py27 env,
unicode error pop up when function is called.

Closes-bug: #1760918

Change-Id: Ic6b6308fb1960ec40407e6efde30137b64543e72
2018-04-05 18:16:25 -07:00
OpenStack Proposal Bot 372c737c65 Imported Translations from Zanata
For more information about this automatic import see:
https://docs.openstack.org/i18n/latest/reviewing-translation-import.html

Change-Id: Ic76d6715821711d18f6f32689e6c3eaa8df5f4fc
2018-03-01 06:08:56 +00:00
Balazs Gibizer 0e3526710f Allow escalation of UUID validation warning to error
Today UUIDField emits a warning if the provided value is not a valid
UUID. However this warning cannot be escalated to an exception through
the standard warnings module because the validation code also adds a
warning filter to the warning filter list that overrides the existing
filters.

This patch ensures that the 'once' warning filter only added to the
end of the filter list. This way if the client has already specified
another filter for this warning (e.g. and error filter) then that
filter will not be overriden.

Change-Id: I17cb96d16fcd91195478b738fbdda01b47cfd69d
Closes-Bug: #1746966
2018-02-02 12:21:52 +01:00
Sean McGinnis 9c4aefb8ea Handle TZ change in iso8601 >=0.1.12
The iso8601 lib introduced a change such that if running on python
3.2 or later it internally uses the python timezone information
instead of its own implementation. This does not change direct
date handling, but when converting this value there is a slight
difference where now python 2.x will show UTC times as "UTC", but
on python 3 they will end up with "UTC+00:00".

The to_primitive call for DateTime fields was doing an exact match
on "UTC" to determine whether to include "Z" in the resulting string.
This updates that handling to recognize either of the new values.

Change-Id: I71b58e8fd8fee8a57ee275ff3e0b77f165eca836
Closes-bug: #1744160
2018-01-24 03:00:51 +00:00
hnyang 2c9258b4ed Remove log translations
Log messages are no longer being translated. This
removes all use of the _LE, _LI, and _LW translation markers to simplify
logging and to avoid confusion with new contributions.

See:
http://lists.openstack.org/pipermail/openstack-i18n/2016-November/002574.html
http://lists.openstack.org/pipermail/openstack-dev/2017-March/113365.html

Change-Id: Ibfe04fd84dc50d5d4ad6ad6736e6d8b74c8e41b4
Closes-Bug: 1674577
2017-12-29 11:31:37 -06:00
ChangBo Guo(gcb) 16a6db4e9e Add bandit to pep8 job
Add the bandit security scanner to the pep8 job.
* convert assert statement to raise AssertionError
* skip B303

Change-Id: I0eb83dd6de80090562dd43bca4e5eb4e88e27bf9
2017-12-26 18:56:35 +08:00
OpenStack Proposal Bot 3fd76ff13c Imported Translations from Zanata
For more information about this automatic import see:
https://docs.openstack.org/i18n/latest/reviewing-translation-import.html

Change-Id: I40d5128202e9384ec6ac084b91def190e262b793
2017-10-08 06:51:01 +00:00
Dinesh Bhor 6f21a10b6a Use newer location for iso8601 UTC
iso8601.UTC is correct datetime UTC field object.
iso8601 >= 0.1.12 includes only iso8601.UTC for python3
while both UTC and Utc() for python2. Less then 0.1.12
included both UTC and Utc() for both python2/3.

Some of the occurrences were missed in the previous commit:
934fb45a2d

This patch fixes those missing occurrences.

Change-Id: Ib6ba40a31bbc0e4a279568bd70fb210ad142d77b
2017-09-29 12:42:51 +05:30
Jenkins 6165add042 Merge "iso8601.is8601.Utc No Longer Exists" 2017-09-27 13:27:47 +00:00
Jenkins a32faa0913 Merge "Add a TimestampedObject mixin" 2017-09-25 23:47:29 +00:00
Sean McCully 934fb45a2d iso8601.is8601.Utc No Longer Exists
iso8601.UTC is correct datetime UTC field object.

iso8601.UTC is correct datetime UTC field object.
iso8601 >= 0.1.12 includes only iso8601.UTC for python3
while both UTC and Utc() for python2. Less then 0.1.12
included both UTC and Utc() for both python2/3.

Change-Id: Ie7957959e836d2f78409d4197c6a2d7ad9e8457b
Closes-Bug: #1713354
2017-08-29 19:29:20 -04:00