summaryrefslogtreecommitdiff
path: root/HACKING.rst
Commit message (Collapse)AuthorAgeFilesLines
* Remove "six" libraryRodolfo Alonso Hernandez2020-07-281-0/+1
| | | | | | Last step to remove "six" library usage in Neutron. Change-Id: Idd42e0c51c8c3bd598c9cf91602596be238bccae
* Use unittest.mock instead of mockHervé Beraud2020-06-171-0/+2
| | | | | | | | | | | | The mock third party library was needed for mock support in py2 runtimes. Since we now only support py36 and later, we can use the standard lib unittest.mock module instead. Also enabled the hacking check that should have caught this, it was missing from tox.ini along with most of the other in-tree hacking checks we have added over the years. Change-Id: Id91175d0db8b8edc72f0dd98925ddbf7415bb881
* Remove references to unittest2 libraryRodolfo Alonso Hernandez2020-01-141-4/+1
| | | | | | | | | | | Library "unittest2" has not released a new version since Jun 30 2015 [1]. Neutron should remove the references to this library and point to "unittest" instead. [1] https://pypi.org/project/unittest2/#history Change-Id: I7d55adc262280c0c2f13b9b81ecc582e1729afa0 Closes-Bug: #1859190
* Update the documentation link for doc migrationAkihiro Motoki2017-07-221-2/+2
| | | | | | | | | | | | * Update the URLs affected by the doc-migration (/developer/<project>/ to <project>/latest/) * Follow content rearrangement * Convert links to local documents into :doc: or :ref: * Use https instead of http for the updated links on docs.openstack.org. Part of the doc-migration work. Change-Id: I62e317d9198f175a43d73bbfd419b6878de90d5a
* hacking: Remove dead codeJakub Libosvar2017-07-191-1/+0
| | | | | | | Checks for logs translation were removed. Code in this patch is not used anywhere. Change-Id: Ia8b6ce545ed0182825fc9d32eedfdf7b949c27d0
* Switch to neutron-lib hacking factoryIhar Hrachyshka2017-04-131-10/+14
| | | | | | | | | | | | This allows us to kill a bunch of in-tree checks. There are still some checks that are either not yet in the library, or don't belong there in the first place, so we still stick to our own factory, just reusing whatever is there in neutron-lib. This change skips some new checks. We gotta figure out what to do with those, that will belong in a separate follow-up. Change-Id: Ifeb40ec0e0c4ca623b33a6b9f500dec15cec4de0
* Merge "Replace assertEqual(None, *) with assertIsNone in tests"Jenkins2016-11-221-0/+1
|\
| * Replace assertEqual(None, *) with assertIsNone in testsgengchc22016-11-161-0/+1
| | | | | | | | | | | | | | Replace assertEqual(None, *) with assertIsNone in tests to have more clear messages in case of failure. Change-Id: Ice018dfd3e48326ce9cac58342d03979559b9e82
* | Switch to new hacking 0.12Ihar Hrachyshka2016-11-081-1/+0
|/ | | | | | | | | | | | The release includes its own check for delayed string interpolation for log messages, so we can now remove our own check for the same thing. The check is off-by-default, so we need to explicitly enable it. Sadly, select= directive in tox.ini is broken [1] so we need to enable the check with flake8 argument instead. [1] https://github.com/PyCQA/pycodestyle/issues/390 Change-Id: Idc6b8e5b1cb594e130d4cc0cbcfffd362f9ab86a
* Forbid importing neutron.tests.* from outside tests subtreeIhar Hrachyshka2016-09-151-0/+1
| | | | | | | | | | | | | | | | | | | | neutron-sanity-check tool was importing neutron.tests.base module, which may be not present on some systems (f.e. RDO splits neutron/tests/ subtree in a separate python-neutron-tests package). It made the tool not usable in some setups. https://bugzilla.redhat.com/show_bug.cgi?id=1374282 This is not the first time when we by mistake import from neutron.tests.* and break distributions. It's time to stop it by proactively forbidding that pattern via a new hacking check. Some functions were moved from neutron.tests.base to neutron.common.utils to fulfill the need requirement. They were moved using debtcollector, no current consumers should be affected. Closes-Bug: #1621782 Change-Id: I790777ddcbd1b02218b3db54ae3d5c931d72d4fa
* Prevent use filter(lambda obj: test(obj), data)Nguyen Phuong An2016-09-141-0/+2
| | | | | | | | | | | | In Python3 [1], if we need filter on python3, replace filter(lambda obj: test(obj), data) with: [obj for obj in data if test(obj)]. This patch replaces filter function and introduces a hacking rule to prevent using filter in future. [1] https://wiki.openstack.org/wiki/Python3 Change-Id: I83d22108c02f8da007a7233e71a4a7fb833170ec
* Add a hacking rule for string interpolation at loggingTakashi NATSUME2016-07-111-0/+1
| | | | | | | | | | | | | | 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: I91e8d59d508c594256d5f74514e62f8f928d1df5 Closes-Bug: #1596829
* Use unittest2 uniformly across NeutronMartin Hickey2016-05-231-1/+4
| | | | | | | | | | | | unittest2 contains bug fixes to unittest for all versions of Python<3.5. Move unittest references to unittest2. Bumped hacking requirement to reflect the version in openstack/requirements that is the minimal version that supports off_by_default checks. Change-Id: I2d26534230ffe5d01aa0aab6ec902f81cfba774d Depends-On: I883223962426ed8e9cdf4e304dfed17ef0946c8a
* Hacking rule to check i18n usageAkihiro Motoki2016-03-301-0/+2
| | | | | | | | | | | | | * Detect neutron.i18n import (neutron._i18n is recommended) * Check builtins _ usage * 'builtins = _' in tox.ini is no longer required. * Introduce hacking rule doctest framework. Newly added check_builtins_gettext() hacking check takes token as argument. It is not a good idea to pass a tokenized line manually. Instead it is reasonable to use docstring based tests used in hacking repo. Change-Id: Ib7464658fc4c8a6f1b03af6ab46f0bd3ee0bfb18
* Using LOG.warning replace LOG.warnLiuNanke2016-03-101-0/+2
| | | | | | | | | | | Python 3 deprecated the logger.warn method, see: https://docs.python.org/3/library/logging.html#logging.warning so we prefer to use warning to avoid DeprecationWarning. Closes-Bugs: #1529913 Change-Id: Icc01ce5fbd10880440cf75a2e0833394783464a0 Co-Authored-By: Gary Kotton <gkotton@vmware.com>
* hacking: remove oslo.* import checkIhar Hrachyshka2016-03-031-1/+0
| | | | | | | Oslo libraries don't ship oslo.* namespace anymore (since Liberty). Time to clean those up. Change-Id: I86f571c576141d3574a0b5efd0f62670ed6e2dcd
* Add hacking check for assertEqual HTTP codelzklibj2016-02-061-0/+2
| | | | | | | | | Add a hacking check for wrong usage, like: assertEqual(observed.code, webob.exc.HTTP**.code) the correct usage should be: assertEqual(webob.exc.HTTP**.code, observed.code) Change-Id: I8c038bae61c528d30af43e904a9bb98ac4cd4d3a
* Unify using assertIsInstancelzklibj2016-01-151-0/+1
| | | | | | | | | | Use assertIsInstance(A, B) to replace assertTrue(isinstance(A, B)). Prefer specific assertions such as assert(Not)IsInstance over generic ones (assertTrue/False, assertEqual) because they raise more meaningful errors. Change-Id: I56278b1a74108e2765a8a740658f33954f5404c7 Closes-bug: #1268480
* HACKING: update HACKING.rst file to include latest changesGary Kotton2016-01-141-0/+2
| | | | | | | Commit 3491cbc0c510404bfb4ddc2e60fde5c5d23400fd updated a hacking check but did not update the HACKING.rst file. Change-Id: Ie9be701f61da93686b79df23f1acf14008e4d486
* HACKING: align the underline text and headerGary Kotton2015-11-291-2/+2
| | | | | | | | Beautify the HACKING.rst file TrivialFix Change-Id: Ide187ba409f57f5cc451f0b774b55a2b09e93c1c
* Removes the use of mutables as default argsGary Kotton2015-10-291-0/+1
| | | | | | | | | | | | | | Passing mutable objects as default args is a known Python pitfall. We'd better avoid this. This commit changes mutable default args with None, then use 'arg = arg or {}', 'arg = arg or []'. For unit code which doesn't use the args , just set with None. This commit also adds hacking check. This code was taken from commit 0bea84ac20fe498bd08f7212a0017196c8cb0812 in Nova. Change-Id: I36d07cade687690dc02a8f6cc3d70f5d00caf112 Co-Authored-By: ChangBo Guo(gcb) <glongwave@gmail.com>
* Use assertTrue(observed) instead of assertEqual(True, observed)Hirofumi Ichihara2015-10-091-0/+1
| | | | | | | | We should use assertTrue not assertEqual. Closes-Bug: #1503071 Change-Id: Ib75dd9f8965fd04fe581f09a5e5df3df43542d89
* Python3: use six.iteritems() instead of dict.iteritems()Cyril Roelandt2015-06-011-0/+1
| | | | | | | | This also adds a check to neutron/hacking/checks.py that should catch this error in the future. Blueprint: neutron-python3 Change-Id: Ie7b833ffa173772d39b85ee3ecaddace18e1274f
* Python 3: use six.string_types instead of basestringCyril Roelandt2015-05-211-0/+1
| | | | | | | | In Python 3, there is no "basestring". In Python 3, "six.string_types" is "basestring", and "str" in Python 3. Change-Id: Ic22e932cbf3c4b75cd424f4b41428da869f197cf Blueprint: neutron-python3
* Python 3: Use six.moves.rangeAdrien Vergé2015-05-191-0/+1
| | | | | | | | | | | | | | The function `xrange` was renamed to `range` in Python 3. * Remove `xrange` occurences so that Python 3 tests can pass. Use `six.moves.range` instead to get the right function in both cases. * Generalize the use of the efficient `range` (ex-`xrange`) in critical sections (when iterating over large lists). * Simplify code. * Add a hacking check to prevent future usage of `xrange`. Change-Id: I080acaaa1d4753619fbbb76dddba6d946d84e73f Partially implements: blueprint neutron-python3
* Remove use of contextlib.nestedankitagrawal2015-05-061-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | Removed use of contextlib.nested call from codebase, as it has been deprecated since Python 2.7. There are also known issues with contextlib.nested that were addressed by the native support for multiple "with" variables. For instance, if the first object is created but the second one throws an exception, the first object's __exit__ is never called. For more information see https://docs.python.org/2/library/contextlib.html#contextlib.nested contextlib.nested is also not compatible with Python 3. This is the first patch in a series for removing use of contextlib.nested. Added hacking check to catch if any new instances are added to the codebase. Line continuation markers (e.g. '\') had to be used or syntax errors were thrown. While using parentheses is the preferred way for multiple line statements, but in case of long with statements backslashes are acceptable. Partial-Bug: 1428424 Change-Id: I171fbdb89892a3d4548bf2ca52f4a7dd9ef8dccb
* oslo: migrate to namespace-less import pathsIhar Hrachyshka2015-02-051-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Oslo project decided to move away from using oslo.* namespace for all their libraries [1], so we should migrate to new import path. This patch applies new paths for: - oslo.config - oslo.db - oslo.i18n - oslo.messaging - oslo.middleware - oslo.rootwrap - oslo.serialization - oslo.utils Added hacking check to enforce new import paths for all oslo libraries. Updated setup.cfg entry points. We'll cleanup old imports from oslo-incubator modules on demand or if/when oslo officially deprecates old namespace in one of the next cycles. [1]: https://blueprints.launchpad.net/oslo-incubator/+spec/drop-namespace-packages Depends-On: https://review.openstack.org/#/c/147248/ Depends-On: https://review.openstack.org/#/c/152292/ Depends-On: https://review.openstack.org/#/c/147240/ Closes-Bug: #1409733 Change-Id: If0dce29a0980206ace9866112be529436194d47e
* Update hacking to 0.10Ihar Hrachyshka2015-01-121-3/+1
| | | | | | | | | | | | | Release notes: http://git.openstack.org/cgit/openstack-dev/hacking/tag/?id=0.10.0 * Remove references in tox.ini to removed rules. * Remove custom @author check since it's now implemented in hacking. * Move N323 to N322 that is freed due to @author check removal. * Temporarily skip W292 (no newline at the end of file). * Temporarily skip H238 (old style classes). Change-Id: I6d990a564df6a312bd09b2a152315bbdba732082
* test_dhcp_agent: Fix no-op testsYAMAMOTO Takashi2014-12-021-1/+1
| | | | | | | | | | Fix some uses of assertCalledOnceWith, which seems like a mistake of assert_called_once_with. Also, add a hacking check to prevent the mistake. Closes-Bug: #1397184 Change-Id: I12d077e2724d52eff65d55aff1130fbbb69671b1
* Update i18n translation for neutron.agents log msg'sGary Kotton2014-11-151-0/+1
| | | | | | | | | | | | | | | | | | | | Don't translate debug level logs and enforce log hints Our translation policy (https://wiki.openstack.org/wiki/LoggingStandards#Log_Translation) calls for not translating debug level logs. This is to help prioritize log translation. Furthermore translation has a performance overhead, even if the log isn't used (since neutron doesn't support lazy translation yet). NOTE: this is done on a directory by directory basis to ensure that we do not have too many conflicts and rebases. Add a local hacking rule to enforce this. This patch set enforces the directory neutron/agents Partial-bug: #1320867 Change-Id: I4bd562e5138c2d2850072440aa121f27e902463a
* mock.assert_called_once() is not a valid methodJacek Swiderski2014-10-131-0/+1
| | | | | | | | | | | | | | mock.assert_called_once() is a no-op that tests nothing. Instead mock.assert_called_once_with() should be used (or use assertEqual(1, mock_obj.call_count) if you don't want to check parameters). Borrowed HACKING rule from Davanum Srinivas's nova patch to prevent it from appearing again. Change-Id: Idac1d3c89c07e13c9a209663f4e557fcb7547821 Closes-Bug: #1365751 Closes-Bug: #1300265
* Remove @author(s) from copyright statementsGary Kotton2014-09-151-0/+2
| | | | | | | | | We have git to track authorship, so let's not pad source files with it as well. A hacking check has been added for this. The value is N322. Change-Id: Iab0b64d417e0bb41a6b455e2ac377deee64ec3ee
* Use jsonutils instead of stdlib jsonIhar Hrachyshka2014-08-141-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | jsonutils provides multiple benefits in comparison to pure stdlib json (like using simplejson on Python 2.6). Similar patch was already merged before [1], but since it lacked hacking rule to enforce jsonutils usage, new occurrences of stdlib json module usage were introduced. This patch switches all the code to using jsonutils and adds a hacking rule to enforce the rule. The hacking rule requires that jsonutils module does not mimic as 'json' thru using import renames, so the code was updated not to rename the module when doing import. The hacking rule was shamelessly copied from the corresponding nova review [2]. [1]: https://review.openstack.org/#/c/99760/ [2]: https://review.openstack.org/111296/ Change-Id: Ie7a5bb76445e15cde9fbf9ff3d2101a014637b37
* Add missing translation supportGary Kotton2014-05-191-1/+1
| | | | | | | | | | | | | | | Update a number of files to add missing translation support. The patch adds a new hacking check - N320. This ensures that all log messages, except debug ones, have translations. A '# noqa' indicates that the validation will not be done on the specific log message. This should be used in cases where the translations do not need to be done, for example, the log message is logging raw data. Change-Id: I3e1fdd04d87b09dff50950b5e85f5cacfb29afdc Closes-bug: #1314994
* Cleanup HACKING.rstJoe Gordon2013-11-111-16/+1
| | | | | | | | * Point to new location for hacking doc (http://docs.openstack.org/developer/hacking/) * Remove openstack-common section because already in main hacking doc Change-Id: I7fbcfe13469a75fed08700ccbe07fefbee33db22
* Cleanup and make HACKING.rst DRYerKeshava Bharadwaj2013-10-161-190/+7
| | | | | | | | Reference the OpenStack hacking guide in HACKING.rst and remove duplicate entries. Adds placeholder section for neutron specific rules. Change-Id: I4bfbab50b77e7592178dda44c7f4f52edc7fdc21
* Fix wrong example in HACKING.rstZhiQiang Fan2013-08-181-1/+1
| | | | | | | | | Example of Human Alphabetical Order Examples section in HACKING.rst is wrong, this patch fixes it to the right order. Closes-Bug: #1213568 Change-Id: Ib7f8baf20c437c3fa776201998c36f33bdde2f78
* Rename Quantum to NeutronMark McClain2013-07-061-15/+15
| | | | | | | | | This change renames everything to Neutron while providing backwards compatible adjustments for Grizzly configuration files. implements blueprint: remove-use-of-quantum Change-Id: Ie7d07ba7c89857e13d4ddc8f0e9b68de020a3d19
* Remove locals() from strings substitutionsGary Kotton2013-04-201-0/+2
| | | | | | Fixes bug 1168988 Change-Id: Ifd1e7a027f16062ff35e777cf2d953f652a806a7
* Add common test base class to hold common things.Monty Taylor2013-03-051-1/+4
| | | | | | | There are several common fixtures that every test case wants. Following the pattern in Nova, add a common base test case class to hold these things. Change-Id: I2d2cd91e5051d9cbf230e6f48985d6eddcb7b58a
* Use testtools instead of unittest or unittest2.Monty Taylor2013-02-261-1/+7
| | | | | | | | | | As part of the move towards testr and parallel test running, we start to use testtools and fixtures to make the test suite resilient and more pedantic. Part of blueprint grizzly-testtools Change-Id: I90250de9fe21237db34f6a50b89b15863e270aa5
* Logging module cleanupZhongyue Luo2013-01-031-1/+1
| | | | | | | | | Replaced logging with openstack.common.log Removed imports where logging is not used Fixes bug #1095541 Change-Id: I5b03d9697dde3ef3520f67d1d8166f7af7689551
* Import order clean-upZhongyue Luo2012-11-021-0/+13
| | | | | | Reorder imports by full module path Change-Id: I50bc2a5ff6cea939049fed8066471b15e84adbe6
* Add HACKING.rst coding style docMaru Newby2012-04-091-0/+202
* Addresses bug 977685 Change-Id: Id04cad3021f015abe965f79b8930da55e092ada1