Declare support for Python 3.11 and drop support for Python 3.7#275
Declare support for Python 3.11 and drop support for Python 3.7#275jiasli merged 1 commit intomicrosoft:devfrom
Conversation
| # set up cassette | ||
| cm = self.vcr.use_cassette(self.recording_file) | ||
| self.cassette = cm.__enter__() | ||
| self.cassette = cm.__enter__() # pylint: disable=unnecessary-dunder-call |
There was a problem hiding this comment.
cm.__exit__ is not called immediately in this method to release self.cassette, but registered in self.addCleanup, so this dunder call is not unnecessary.
| except AttributeError: | ||
| pass | ||
|
|
||
| command_argument_default = default if default != inspect.Parameter.empty else None |
There was a problem hiding this comment.
The original code reuses the variable name default to denote different things, which is a bad practice. We rename it to command_argument_default to distinguish command argument default from function argument default.
| sig = inspect.signature(operation) | ||
| args = sig.parameters |
There was a problem hiding this comment.
inspect.getargspec is removed in Python 3.11 and replaced by inspect.getfullargspec. However, inspect.getfullargspec is retained only to maintain backward compatibility. The recommendation is to use inspect.signature:
Note that signature() and Signature Object provide the recommended API for callable introspection, and support additional behaviours (like positional-only arguments) that are sometimes encountered in extension module APIs. This function is retained primarily for use in code that needs to maintain compatibility with the Python 2 inspect module API.
-- https://docs.python.org/3.11/library/inspect.html#inspect.getfullargspec
Given we have dropped Python 2 long ago (#233), it's time to drop the usage of inspect.getargspec too.
| name: 'pool-ubuntu-2004' | ||
| steps: | ||
| - task: UsePythonVersion@0 | ||
| displayName: Use Python 3.10 |
| python ./scripts/license_verify.py | ||
| flake8 --statistics --append-config=.flake8 knack | ||
| pylint knack --rcfile=.pylintrc -r n -d I0013 | ||
| pylint knack --rcfile=.pylintrc --reports n --disable I0013 |
There was a problem hiding this comment.
Use arguments' full name for clarity.
It's very likely we need to remove --disable I0013 in the near future, as pylint 3.0.0b1 disables it by default:
This message is disabled by default. To enable it, add file-ignored to the enable option.
-- https://pylint.pycqa.org/en/latest/user_guide/messages/information/file-ignored.html
| from packaging.version import parse | ||
| return parse(v1) <= parse(v2) |
There was a problem hiding this comment.
Similar changes were previously made in Azure/azure-cli#17667.
PEP 632 mentions:
distutils.version— use thepackagingpackage
| return args and (args[0] == '--version' or args[0] == '-v') | ||
|
|
||
| def get_cli_version(self): # pylint: disable=no-self-use | ||
| def get_cli_version(self): |
There was a problem hiding this comment.
The removal of # pylint: disable=no-self-use is explained in Azure/azure-cli-dev-tools#359 (comment)

Declare support for Python 3.11 and drop support for Python 3.7.
Corresponding Azure CLI issues: