Conversation
|
|
||
| def __setattr__(self, name, value): # pylint: disable=inconsistent-return-statements | ||
| if name == 'type': | ||
| return super(CLICommandArgument, self).__setattr__(name, value) |
There was a problem hiding this comment.
It's a big change for our code. Can you provide more information about this.
There was a problem hiding this comment.
If we run pylint==2.6.0 on the current code, it errors out:
> tox -e py38
************* Module knack.arguments
knack\arguments.py:86:19: R1725: Consider using Python 3 style super() without arguments (super-with-arguments)
knack\arguments.py:189:24: R1725: Consider using Python 3 style super() without arguments (super-with-arguments)
knack\arguments.py:212:24: R1725: Consider using Python 3 style super() without arguments (super-with-arguments)
knack\arguments.py:246:24: R1725: Consider using Python 3 style super() without arguments (super-with-arguments)
knack\arguments.py:297:24: R1725: Consider using Python 3 style super() without arguments (super-with-arguments)
************* Module knack.commands
knack\commands.py:283:12: W0707: Consider explicitly re-raising using the 'from' keyword (raise-missing-from)
************* Module knack.deprecation
knack\deprecation.py:89:8: R1725: Consider using Python 3 style super() without arguments (super-with-arguments)
knack\deprecation.py:141:8: R1725: Consider using Python 3 style super() without arguments (super-with-arguments)
************* Module knack.experimental
knack\experimental.py:55:8: R1725: Consider using Python 3 style super() without arguments (super-with-arguments)
knack\experimental.py:76:8: R1725: Consider using Python 3 style super() without arguments (super-with-arguments)
************* Module knack.help
knack\help.py:95:8: R1725: Consider using Python 3 style super() without arguments (super-with-arguments)
knack\help.py:126:8: R1725: Consider using Python 3 style super() without arguments (super-with-arguments)
knack\help.py:245:8: R1725: Consider using Python 3 style super() without arguments (super-with-arguments)
knack\help.py:269:8: R1725: Consider using Python 3 style super() without arguments (super-with-arguments)
knack\help.py:328:8: R1725: Consider using Python 3 style super() without arguments (super-with-arguments)
knack\help.py:348:8: R1725: Consider using Python 3 style super() without arguments (super-with-arguments)
************* Module knack.output
knack\output.py:81:8: W0707: Consider explicitly re-raising using the 'from' keyword (raise-missing-from)
************* Module knack.parser
knack\parser.py:112:8: R1725: Consider using Python 3 style super() without arguments (super-with-arguments)
knack\parser.py:226:15: R1725: Consider using Python 3 style super() without arguments (super-with-arguments)
knack\parser.py:262:15: R1725: Consider using Python 3 style super() without arguments (super-with-arguments)
************* Module knack.preview
knack\preview.py:55:8: R1725: Consider using Python 3 style super() without arguments (super-with-arguments)
knack\preview.py:76:8: R1725: Consider using Python 3 style super() without arguments (super-with-arguments)
************* Module knack.query
knack\query.py:27:12: W0707: Consider explicitly re-raising using the 'from' keyword (raise-missing-from)
************* Module knack.util
knack\util.py:45:8: R1725: Consider using Python 3 style super() without arguments (super-with-arguments)
************* Module knack.testsdk.base
knack\testsdk\base.py:29:8: R1725: Consider using Python 3 style super() without arguments (super-with-arguments)
knack\testsdk\base.py:85:8: R1725: Consider using Python 3 style super() without arguments (super-with-arguments)
knack\testsdk\base.py:116:8: R1725: Consider using Python 3 style super() without arguments (super-with-arguments)
knack\testsdk\base.py:254:12: W0707: Consider explicitly re-raising using the 'from' keyword (raise-missing-from)
************* Module knack.testsdk.checkers
knack\testsdk\checkers.py:67:12: W0707: Consider explicitly re-raising using the 'from' keyword (raise-missing-from)
knack\testsdk\checkers.py:80:12: W0707: Consider explicitly re-raising using the 'from' keyword (raise-missing-from)
knack\testsdk\checkers.py:93:12: W0707: Consider explicitly re-raising using the 'from' keyword (raise-missing-from)
************* Module knack.testsdk.exceptions
knack\testsdk\exceptions.py:10:8: R1725: Consider using Python 3 style super() without arguments (super-with-arguments)
knack\testsdk\exceptions.py:17:8: R1725: Consider using Python 3 style super() without arguments (super-with-arguments)
knack\testsdk\exceptions.py:25:8: R1725: Consider using Python 3 style super() without arguments (super-with-arguments)
-------------------------------------------------------------------
Your code has been rated at 9.87/10 (previous run: 10.00/10, -0.13)
The help message is pretty straight-forward:
> pylint --help-msg R1725,W0707
:super-with-arguments (R1725): *Consider using Python 3 style super() without arguments*
Emitted when calling the super() builtin with the current class and instance.
On Python 3 these arguments are the default and they can be omitted. This
message belongs to the refactoring checker.
:raise-missing-from (W0707): *Consider explicitly re-raising using the 'from' keyword*
Python 3's exception chaining means it shows the traceback of the current
exception, but also the original exception. Not using `raise from` makes the
traceback inaccurate, because the message implies there is a bug in the
exception-handling code itself, which is a separate situation than wrapping
an exception. This message belongs to the exceptions checker.
There was a problem hiding this comment.
As I know, python2 does not support this, and pycharm are using the old format in code autocompletion.
There was a problem hiding this comment.
We need to make the same changes for azure-cli and azure-cli-extensions after using the new knack version with this bump?
There was a problem hiding this comment.
Definitely not. Knack itself doesn't require pylint and flake8. This PR only makes sure Knack complies with the latest pylint and flake8.
There was a problem hiding this comment.
I see. pylint is still pinned to 2.3.0 in azdev.
| except (ValueError, AttributeError) as ex: | ||
| raise ValueError("The operation '{}' is invalid.".format(operation)) from ex |
There was a problem hiding this comment.
Use Python's built-in Exception Chaining as recommended by W0707:
raise-missing-from (W0707):
Consider explicitly re-raising using the 'from' keyword Python 3's exception chaining means it shows the traceback of the current exception, but also the original exception. Not using raise from makes the traceback inaccurate, because the message implies there is a bug in the exception-handling code itself, which is a separate situation than wrapping an exception.
- Exception Chaining: https://docs.python.org/3.9/tutorial/errors.html#exception-chaining
- Built-in Exceptions: https://docs.python.org/3.9/library/exceptions.html#bltin-exceptions
Bump pylint and flake8 to the latest version to make sure the code comply with the latest Python 3 standards.