Commit Graph

57 Commits

Author SHA1 Message Date
Brian Haley 1dbc373869 Update .pylintrc
There are a few warnings disabled that do not generate
failures any more, re-enable them by removing from
.pylintrc file.

TrivialFix

Change-Id: I1a4fff33b0dcd3d88b4ab0c86546098c7a9cafa4
2024-01-17 13:33:08 -05:00
Zuul 0fa45c8684 Merge "Fix pylint "W" missing-timeout warnings" 2023-12-02 00:55:55 +00:00
Zuul 62bbfad8ff Merge "Fix some new pylint "W" warnings" 2023-08-02 11:03:07 +00:00
Brian Haley 48f2933060 Fix pylint "W" missing-timeout warnings
After updating pylint, it started emitting additional "W"
warnings in some cases. Fix the missing-timeout ones by
adding a timeout=60 value to the calls done by the
metadata agent code.

Trivialfix

Change-Id: Ica5c2a2d3941813b3518b83738ada96bdf7c3760
2023-08-01 15:59:34 -04:00
Brian Haley 4757b46646 Fix some new pylint "W" warnings
After updating pylint, it started emitting additional "W"
warnings in some cases, fix some of them.

  modified-iterating-list,
  implicit-str-concat,
  global-variable-not-assigned

Trivialfix

Change-Id: I7deb5f1e0aa2852cb033c78dcb4c8bc87e34be1e
2023-08-01 15:40:22 -04:00
Zuul d32c5f8f32 Merge "Fix some new pylint "R" warnings" 2023-07-28 06:58:46 +00:00
Brian Haley 929b383743 Fix some new pylint "R" warnings
After updating pylint, it started emitting additional "R"
warnings in some cases, fix some of them.

  use-a-generator,
  unnecessary-lambda-assignment,
  consider-using-max-builtin,
  consider-using-generator,
  consider-using-in,
  use-list-literal,
  consider-using-from-import

Trivialfix

Change-Id: Ife6565cefcc30b4e8a0df9121c9454cf744225df
2023-07-18 18:06:51 -04:00
Brian Haley 126d54badc Fix some new pylint "E" warnings
After updating pylint, it started emitting additional "E"
warnings in some cases, fix them.

  unsubscriptable-object,
  unsupported-delete-operation

These were associated with the OVN AgentCache code. Instead
of using a subscript, create get/delete methods to do the
same thing.

  used-before-assignment

Re-factor some code so it's clear to pylint variables are
being assigned properly.

Trivialfix

Change-Id: I4a5ccb7f33465705e59b5274c41db3c371862b1e
2023-06-22 20:41:29 -04:00
Brian Haley 10ff1caaca Fix some new pylint "C" warnings
After updating pylint, it started emitting additional "C"
warnings in some cases, fix some of them.

  use-implicit-booleaness-not-comparison,
  use-maxsplit-arg,
  unnecessary-dunder-call

Trivialfix

Change-Id: I53558e6bc52aaea590f6c147aacc062c08099464
2023-05-18 21:54:38 -04:00
Brian Haley ed274efcf7 Update pylint version
It has been over 2 years since we set the version of
pylint and associated tools in tox.ini, update to
something newer, specifically:

  bashate>=2.1.1
  bandit>=1.7.5
  flake8-import-order==0.18.2
  pylint==2.17.4

This required disabling additional checks for new
warnings that were found, and adding a directive to
add the "no-self-use" plugin that is now required
with the newer version.

Will work on fixing new warnings and re-enabling
checks in subsequent patches.

Trivialfix

Change-Id: I5d74d47ac1d8a085b447ff531d7abbecfb4cce6e
2023-05-17 23:04:24 -04:00
Brian Haley 0d315d2467 Update .pylintrc
Update .pylintrc to be stricter, for example, to enforce
C0330 warnings (hanging/continued indentation). This
should be the end of the series.

Also did some cleanup of old unsupport options that pylint
complains about when you run it.

Change-Id: Id1bce82f584243b55a47fd6d5c5db81729e11f03
2022-12-12 11:48:41 -05:00
Zuul fb945cfa38 Merge "Fix misplaced comparison constant warnings" 2022-10-06 23:07:21 +00:00
Brian Haley 4858315286 Fix misplaced comparison constant warnings
Use "value > constant" syntax and not vice-versa. Also
removed disable of misplaced-comparison-constant in
.pylintrc so future ones are caught.

Trivialfix

Change-Id: I733864e7437213bfb6edde24f207b2c9861998c6
2022-10-05 17:13:39 -04:00
Brian Haley 72493d1472 Add missing comma in .pylintrc
Without the comma in the deprecated-modules section, any
subsequent arguments are silently ignored. Add it so pylint
will catch any six imports.

Change-Id: I4bca5ab81dd4ef6f28c7ff854dcc782a9b3c3f12
2022-09-23 15:22:16 -04:00
Rodolfo Alonso Hernandez ddd5832323 Remove "six" library
Last step to remove "six" library usage in Neutron.

Change-Id: Idd42e0c51c8c3bd598c9cf91602596be238bccae
2020-07-28 16:55:52 +00:00
Brian Haley 8e4f625da6 Fix pylint R1717 (consider-using-dict-comprehension) refactor messages
Don't create an intermediate list before creating a dict.

Change-Id: Idb93835f2312625d649231c1baa2a3c566096825
2019-03-14 23:19:58 +00:00
Brian Haley 7b973d151e Fix pylint R1716 (chained-comparison) refactor messages
Use "a < b < c" instead of "a < b and b < c".

Change-Id: I1f0c46a609c56ffe869486b25fe6e82faaf3d5fb
2019-02-21 16:15:23 -05:00
Brian Haley fba5eb694b Fix pylint R1714 (consider-using-in) refactor messages
Instead of checking variables are equal to one of many
values, use a tuple and check if the variable is 'in' it.
This is faster and less verbose.

Change-Id: I429dbbd92a78fdfae3140cae8a397ff10f6d956e
2019-02-21 21:11:34 +00:00
Doug Wiegley 7e208c3014 Bump pylint version to one that supports python3.7
The listed revision no longer supports python2, but afaik, we are
always running under python3 for those tests anyway.

Change-Id: Iba94d73eeb65fb21f5d098afe0fbe4348dbea850
2019-02-21 13:22:26 +00:00
Doug Hellmann 87d98dcbe2 Disable some pylint checks
Newer pylint added some checks that trigger a lot for this
code base. Turn them off until we are ready to apply the
new rules.  They are:

 - c-extension-no-member (Informational)
 - keyword-arg-before-vararg (Warning)
 - inconsistent-return-statements (Refactor recommendation)

Change-Id: I8c1f72bb334c87d62d47e8296d13c660d6bb5576
Signed-off-by: Doug Hellmann <doug@doughellmann.com>
2018-10-03 08:41:56 +00:00
Akihiro Motoki 17ed89cbc1 Update pylint disable list to pass pylint 1.7.1 checks
Recenly pylint version was bumped to 1.7.1 in global-requirements.txt.
Pylint 1.7.1 adds more checks and breaks the neutron pep8 job.

This commit adds new checks to the disabled list to avoid the gate
breakage. Individual disabled tests can be fixed later.

The new disabled list is compatible with pylint 1.4.5,
so we can merge this regardless of pylint bump is reverted or not.

Closes-Bug: #1696403
Change-Id: If6228d0626413049b82f9d75bcdf3bea7ddacde5
2017-06-08 09:49:46 +00:00
da52700 67da6a3122 Fix typo in .pylintrc file
Change-Id: I00be2feff24a56e82b2c9f3639f5cb33178dd5b3
2017-02-09 01:07:07 +00:00
Henry Gessau 7b277a1ba0 Remove last vestiges of oslo-incubator
This is a community goal for Ocata.  We're already not using any of
the code, but there are some other files and references left over.

Partial-Bug: #1639103

Change-Id: I2afd263ddc480e2512e3be77a03ffe5ae16e17a5
2016-11-04 20:49:13 -04:00
Ihar Hrachyshka a77453a6fe pylint: remove 'openstack' from ignore list
The neutron.openstack module is gone for some time, no need to ignore
it.

Change-Id: I19f2e1521d44c8a2743bcb48a7ec6a74f65f6403
2016-09-08 16:39:02 +00:00
Doug Wiegley 87a79256c4 Start using neutron-lib for shared constants and exceptions
Debtcollector warnings are enabled by an env var for now, to avoid blasting
everyone's unit tests at once.

Partially-Implements: blueprint neutron-lib
Depends-On: I6991464acc3aef99f6ec5eff56a893deaaefe40b
Change-Id: If183b7a6797834e29c377937fc06261aa3b00249
2016-02-10 16:41:18 -07:00
Angus Lees d00bd978f8 pylint: enable `duplicate-key` check
This check attempts to detect dictionary literals with duplicate keys.

The rest of the Neutron tree has already had the few instances of this
cleaned[1] or moved into external vendor repos.  Enabling the pylint
check will stop future occurrences.

[1] I29cd2b843a7905986de13a1ecfba0cb5797ccaf8

(Original patch I1aa221d2019853f905f2b8421dd45b0a3102baf0 by zhiyuan_cai)

Change-Id: If4fed9714cd7fa586845f21f8f56dde2645cc5e0
Co-Authored-By: zhiyuan_cai <luckyvega.g@gmail.com>
2015-06-04 13:10:44 +10:00
Assaf Muller f512253569 Remove 'free' exclusions from pylint
This is a comprehensive list of current pylint exclusions that
don't actually appear in the code.

Change-Id: Ifaeb4c9d3ed7cf2f85a35555004c830559ba2d2b
2015-03-06 09:37:00 -05:00
armando-migliaccio c0aa0b37c0 Move pylint checks to pep8 testenv
This change proposes to move pylint violation checks to the pep8
testenv. This changes make pylint gating within Neutron as it would
participate in the vote.  Having pylint executed on a separate job makes
it difficult to handle potential unexpected breakages, because we need
to get infra involved. When we need to renable the job, it is equally
painful.

Furthermore, it also causes us to spin an extra node, when the checks
can easily be handled by the node for the pep8 job.

Finally, having pylint running with tox -epep8 "helps" developers
become aware of pylint violations sooner rather than later, if they
"forget" to run the pylint testenv too before submitting the change.

In order to make this patch succeed, a couple of pylint violation
checks were skipped, as they slipped in, whilst the job was non-voting.

We'll tackle them in due course.

Change-Id: Ida6ae44a837d1761f5ce3e8a92f8850407f5cd16
2015-02-25 17:45:38 -08:00
Assaf Muller b0124c55cb Enable pylint unnecessary-pass
Change-Id: I5ba003286a9abdcd92c08d9a164282a03eb1144a
2015-02-19 20:02:58 -05:00
Assaf Muller d7d4f1f96d Enable pylint no-value-for-parameter
Change-Id: I532dc0c8f0f9f8c92b47a51138d5162bc506016b
2015-02-19 20:02:58 -05:00
Assaf Muller 2eadd37829 Enable pylint bad-super-call
Change-Id: I408ce142a2f2145ac442ad4130681b135f9d52cf
2015-02-19 20:02:57 -05:00
Assaf Muller 0e4781e2ab Enable 'free' pylint checks
Change-Id: I4aa1e4a43c50b8ac0f4e97b84479c66d78407625
2015-02-19 20:01:05 -05:00
Angus Lees 935deb3994 Enable super-on-old-class pylint check
.. and disable the check locally for two midonet and Ryu classes that
fail since the midonet/ryu libraries are unavailable in our toxenv.

Change-Id: Idca46f853e6a116e8b2c246b4c6cae159894f887
2015-02-02 16:31:40 +11:00
Cedric Brandily c9974b9269 Fix pylint unbalanced-tuple-unpacking warning
Pylint last version(1.4.1), at least, reports an
unbalanced-tuple-unpacking warning[1] in keepalived[2] module because
self.authentication is defined as an empty tuple in __init__ method and
unpacked in build_config method as if it was a 2-tuple.

self.authentication references an empty tuple (defined in __init__
method) or a 2-tuple (updated in set_authentication method). Such
warning is a false positive because the unpacking is only performed if
self.authentication is not evaluated to false which only appends if
self.authentication is a 2-tuple.

Defining self.authentication as None in __init__ avoids such warning
without disabling unbalanced-tuple-unpacking warning check.

[1]
W:252,12: Possible unbalanced tuple unpacking with sequence defined at
line 153: left side has 2 label(s), right side has 0 value(s)
(unbalanced-tuple-unpacking)

[2] neutron.agent.linux.keepalived

Change-Id: Ifcdf08e574ef44a65c6d121323cbe31d9af2f921
Closes-Bug: #1411865
2015-01-18 11:37:43 +00:00
Carl Baldwin 4906e0cf8e Disable unbalanced-tuple-unpacking
This check seems to have changed and started to break in Neutron.
Disabling it is one way we could get back to good.

Change-Id: I6d06d43cb2e78501cd69fcb3940694d04d936fa8
Closes-bug: #1411865
2015-01-16 23:40:13 +00:00
Jenkins 03f33d67d7 Merge "Enable the "not-callable" pylint check" 2015-01-06 13:20:15 +00:00
Angus Lees 73c9a5fc7c Enable the "not-callable" pylint check
This check catches attempts to call variables that pylint believes are
not functions.  A trivial example would be:

    # Trivial example caught by this check:
    foo = dict()
    print foo('bar')  # <- oops, meant foo['bar']

This change enables the "not-callable" pylint check, after disabling a
few cases where the alert triggers but the usage was intended (defining
decorators).

Change-Id: I09ad929902509018fe7183a15b784601c36b6196
Related-Bug: #1356224
2014-12-31 15:33:44 +11:00
Angus Lees e9cee51e56 Enable pylint checks for "anomalous" string escapes
Escapes in python string literals are well defined, but can be
confusing.  These pylint checks look for backslash escapes in strings
that might be mistakes.  Two code refactors were required to satisfy
these tests:

1. midonet_lib.py used \**kwargs in docstrings.

There doesn't seem to be a sphinx standard for kwargs, so this change
simply replaces them with "kwargs".

2. Regex literals containing escapes replaced with r''.

The assumption with this change (and the underlying pylint
check) is that r'' literals are more straightforward for regular
expressions, where every backslash is important.

While looking at these regexes, this change also removes a few
unnecessary "\-" escapes.

Change-Id: I01528b2482f78b9e851685ebbf6fded4e58355f1
2014-12-23 14:53:02 +11:00
Angus Lees cd5b3646c1 Use comments rather than no-op string statements
This change replaces a few no-op string statements with regular
comments.  While there was no harm in the previous use of strings for
comments, this allows us to re-enable the corresponding pylint check
which may catch genuinely unintended cases.

Change-Id: I796a059292e26c4df75c54f095d9e20e99187c98
2014-12-09 08:40:32 +11:00
Jenkins 4bdee18097 Merge "Enable undefined-loop-variable pylint check" 2014-11-30 17:04:58 +00:00
Angus Lees 4f1129190b Enable undefined-loop-variable pylint check
This required a trivial refactor of two existing cases in the codebase.

These two cases were perfectly correct, but the check uncovered a 3rd
case which was a real bug (fixed separately).  The new versions also
make it clear that if the loop fails to break early then the 'result' is
None (and thus an error) and not simply the last element.  On balance,
it's probably worth enforcing this small inconvenience to coding style.

Change-Id: I780a95241f1454c6886d91f980eb9ada7678a119
Related-Bug: #1362466
2014-11-28 11:40:41 +11:00
Angus Lees b0d763e922 Fix incorrect exception order in _execute_request
_execute_request has a list of exception handlers to log various types
of errors with more specific error messages. Unfortunately, it catches
requests.exceptions.ConnectionError before requests.exceptions.SSLError,
but ConnectionError is a superclass of SSLError so the latter is never
invoked.

This change corrects the exception handling order, and enables the
bad-except-order pylint check now that the check passes.

Change-Id: I92bacd6088de5cbc170bc5c081a1db1baeec69e7
Closes-Bug: #1360970
2014-11-27 16:44:44 +11:00
Jenkins 0965f81eb4 Merge "Switch run-time import to using importutils.import_module" 2014-11-19 11:49:20 +00:00
Jenkins 0f70fe054c Merge "Enable assignment-from-no-return pylint check" 2014-11-11 03:31:19 +00:00
Jenkins 71153eaa60 Merge "Remove single occurrence of lost-exception warning" 2014-11-08 23:35:44 +00:00
Jenkins 6bb791dfc8 Merge "Hyper-V: Remove useless use of "else" clause on for loop" 2014-10-28 23:21:48 +00:00
Jenkins 2873de1a59 Merge "Enable no-name-in-module pylint check" 2014-10-28 08:46:01 +00:00
Angus Lees 105ce10838 Hyper-V: Remove useless use of "else" clause on for loop
"else" on for loops is only important if the loop contains a "break"
statement.  Without a "break", the else block is _always_ executed and
it is clearer just to omit "else".

This change also enables the corresponding pylint warning, now that the
only offending case has been fixed.

Change-Id: Ibe8761cb40a7d2d564aa718d62c9f383b5ad711e
2014-10-22 09:38:23 +11:00
Angus Lees db476ffc51 Enable no-name-in-module pylint check
Add _MovedItems (from six.moves) to pylintrc ignored-modules, and adjust
one import of sqlalchemy.orm.properties.RelationshipProperty.

s.o.p.RelationshipProperty is created at import-time in a rather
exciting manner - rearranging the import in this way forces the
import-time code to be executed and seems sufficient to satisfy the
pylint static check.

Change-Id: Ic99dc2b7dfac75930a5c446ae899eaae09ee6174
2014-10-22 09:24:21 +11:00
Angus Lees be6bd82d43 Remove duplicate import of constants module
.. and enable corresponding pylint check now the only offending instance
is fixed.

Change-Id: I35a12ace46c872446b8c87d0aacce45e94d71bae
2014-10-21 16:03:22 +11:00