Commit Graph

15 Commits

Author SHA1 Message Date
James Page 6b38affa15
tests: Fix syntax error in hacking test
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
2024-01-22 20:18:43 +00:00
Andreas Jaeger 9350d8fb83 Update hacking for Python3
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
2020-04-19 07:41:06 +02:00
Sean McGinnis 9a59610643
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: Ia6927351f591be0c57fd73515b2542a0af35f82b
Signed-off-by: Sean McGinnis <sean.mcginnis@gmail.com>
2020-04-18 11:54:10 -05:00
Shilpa Devharakar 204fa9c849 Resolve gate job failure
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
2019-07-18 13:07:02 +00:00
openstack 68b9c42bef Run all jobs by default using python3
This patch implements the community wide goal to run all jobs by
default using python3.

See the python3-first goal document for details:
https://governance.openstack.org/tc/goals/stein/python3-first.html

Change-Id: Ie235cbffcfc69eee96c4b34358467009ca34ef9f
2019-03-03 19:11:19 +05:30
shilpa.devharakar d7592cbe25 Register and Document policy in code
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
2018-07-27 12:15:14 +05:30
Takashi NATSUME 2047226e5d Removed unnecessary parantheses in yield statements
The 'yield' statement is not a function.
So it must always be followed by a space when yielding a value.

Change-Id: I518d34da400400b678448805ea19e554f48dac85
2018-07-24 13:07:36 +09:00
poojajadhav 892e9b116c Hacking: do not translate log messages
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
2017-09-25 14:34:25 +05:30
Dinesh Bhor 66c607c6e8 Enable global hacking checks and remove local checks
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
2017-08-04 04:55:18 +00:00
lcsong c9f7a3c56d Remove log translations
Log messages are no longer being translated. This removes all use of
the _LC, _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: I4c96f3590d46205c45d12ee4ead8c208e11c52c5
2017-04-05 08:11:09 +00:00
hussainchachuliya 00c2d8857c Use dict.items() and dict.values() as per guidelines
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
2017-01-16 18:08:15 +05:30
Takashi Kajinami 5ea3d2233a Remove wrong reference to cinder
TrivialFix

Change-Id: I2a824a710a092a4fde17f66d5361da304b4b5d07
2016-09-29 00:19:03 +09:00
Takashi NATSUME 8e601d1183 Add a hacking rule to enforce use of LOG.warning
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
2016-08-04 09:45:40 +09:00
Takashi NATSUME cd3be63409 Add a hacking rule for string interpolation at logging
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
2016-08-02 14:47:59 +09:00
Abhishek Kekane 48051ece73 Add hacking checks
Added required hacking checks to follow OpenStack coding
standards.

Change-Id: I20fe168f364296844a593ec3880e1639637dbf06
2016-07-20 12:47:50 +05:30