Under Python 3.12 this results in a syntax error rather than
M329 being detected on line 8 of the test code.
Change-Id: Ia1bb4dfb43b00115cde1158681d34d6ad7c7d744
The repo is Python 3 now, so update hacking to version 3.0 which
supports Python 3.
Fix problems found by updated hacking version.
Update local hacking checks to work with current flake8.
Remove hacking and friends from lower-constraints, they are not needed
there.
Change-Id: I89695a03791c2de36ab015b3831c85887b27f3b8
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: Ia6927351f591be0c57fd73515b2542a0af35f82b
Signed-off-by: Sean McGinnis <sean.mcginnis@gmail.com>
This patch resolves below gate job issues:
* openstack-tox-py27: Failing for double word hacking test, resolved
by taking reference for nova fixes [1]
* masakari-functional-devstack-multinode: Failing since 'Split
OpenStackCloud at SDK [1]', resolved by calling proper SDK connection.
* Devstack installation add more than one networks if neutron service is
enabled [3] and hence server creation fails with error 'ERROR
(Conflict): Multiple possible networks. Fixed this issue by passing
the network during server creation.
[1]: f545a25cc4
[2]: 1a4ed826b9 (diff-a948cab0aca56c2f4bf6569f8dc8ac66)
[3]: 8f7216290a
Change-Id: Ie477ddf4516712f8fd145ec78ca2335762972053
Adds below things for the implementation of framework for registering and
using default policy rules.
* Policy-in-code
The framework for registering and using default policy rules.
Rules should be defined and returned from a module in
masakari/policies/, and then added to the list in masakari/policies/__init__.py.
A new context.can() method has been added for policy enforcement of
registered rules. It has the same parameters as the enforce() method
currently being used.
* Add policy sample generation
The entry point and config file necessary for using the
oslo.policy sample generation script. It also adds a tox target to
simplify the usage of it.
* Add policy documentation and sample file
Documentation and sample file for default policy in code feature.
* Hacking check for policy registration
It ensures that policy registration happens in the centralized
masakari/policies/ directory.
* Hacking check for _ENFORCER.enforce()
Hacking check in order to ensure that only registered policies
are used for authorization checks _ENFORCER.authorize should be used rather
than _ENFORCER.enforce.
* Add entry_point for oslo policy scripts
There are two helper scripts in oslo.policy to help deployers understand
their policy configuration better. With the setup.cfg entry these can be
called directly from oslo.policy.
Changes done here are with the reference of [1] at NOVA side
which is contributed by Andrew Laski and Claudiu Belu
[1] https://review.openstack.org/#/q/topic:bp/policy-in-code+project:openstack/nova+status:merged
Change-Id: If885a66d92c31be440d27d6780635800a0b12e3e
The 'yield' statement is not a function.
So it must always be followed by a space when yielding a value.
Change-Id: I518d34da400400b678448805ea19e554f48dac85
Community has decided to do not translate log messages anymore.
The motivation behind removing translation jobs for log messages
is that when operators encounters any unfamiliar situations(e.g.
nova error, keystone error etc.), searching on the Internet
based on actual log content would have more results than searching
translated log messages.
In this patch I have added hacking rule to check that logs are
not translated.
Change-Id: I90d53d617aac6839c2f2ab119847cbf24a1300e0
In newer hacking version 0.12.0 [1], we can enable some of the
non-default hacking rules (one by one), which are disabled by
default. The enabled rules are the following:
* [H106] Don’t put vim configuration in source files (off by default).
* [H203] Use assertIs(Not)None to check for None (off by default).
* [H904] Delay string interpolations at logging calls (off by default).
Enabled these hacking rules by adding them in the list of
'enable-extensions' in tox.ini [flake8] section. Removed the local
implementation of those hacking rules from hacking/checks.py.
The test-requirements.txt is already updated to use the newer
hacking version 0.12.0 with this commit:
cc44a33f3d
[1] See "Enabling off-by-default checks" section:
https://pypi.python.org/pypi/hacking/0.12.0
Change-Id: Ieccd5a84ebd80ba3313016c9caeb036eaa37769b
There are occurrences where six.iteritems(dict) and
six.itervalues(dict) is used instead of dict.items()
and dict.values() respectively which contradicts with
the guidelines provided here [1].
This patch fixes such occurrences by replacing 'iteritems'
and 'itervalues' with 'items' and 'values' respectively.
[1] https://wiki.openstack.org/wiki/Python3
Change-Id: I20eb92be8bea01dec6163c9ed84c64370123a75d
LOG.warn is deprecated.
LOG.warning should be used instead of LOG.warn.
So add the following hacking rule.
- [M331] LOG.warn is deprecated. Enforce use of LOG.warning.
Change-Id: I1f99331e2a51f8295eac0734aa653b4ff04ccf65
Closes-Bug: #1508442
String interpolation should be delayed to be handled
by the logging code, rather than being done
at the point of the logging call.
So add a hacking rule for it.
See the oslo i18n guideline.
* http://docs.openstack.org/developer/oslo.i18n/guidelines.html
Change-Id: Ib7d97e6edbb8069c12b22505c0d6653b4a17ec78
Closes-Bug: #1596829