Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Declare support for Python 3.11 and drop support for Python 3.7 #275

Merged
merged 1 commit into from
Jul 26, 2023

Conversation

jiasli
Copy link
Member

@jiasli jiasli commented Jul 21, 2023

Declare support for Python 3.11 and drop support for Python 3.7.

Corresponding Azure CLI issues:

@@ -117,7 +117,7 @@ def setUp(self):

# set up cassette
cm = self.vcr.use_cassette(self.recording_file)
self.cassette = cm.__enter__()
self.cassette = cm.__enter__() # pylint: disable=unnecessary-dunder-call
Copy link
Member Author

@jiasli jiasli Jul 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +70 to +71
sig = inspect.signature(operation)
args = sig.parameters
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@jiasli jiasli changed the title Declare support for Python 3.11 and drop support for Python 3.6 Declare support for Python 3.11 and drop support for Python 3.7 Jul 21, 2023
@@ -53,9 +53,8 @@ jobs:
name: 'pool-ubuntu-2004'
steps:
- task: UsePythonVersion@0
displayName: Use Python 3.10
Copy link
Member Author

@jiasli jiasli Jul 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using the default displayName is sufficient - it is the same as what we are specifying here.

image

[testenv]
deps = -rrequirements.txt
commands=
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
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment on lines +99 to +100
from packaging.version import parse
return parse(v1) <= parse(v2)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar changes were previously made in Azure/azure-cli#17667.

PEP 632 mentions:

distutils.version — use the packaging package

@@ -104,15 +104,15 @@ def __init__(self,
def _should_show_version(args):
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):
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The removal of # pylint: disable=no-self-use is explained in Azure/azure-cli-dev-tools#359 (comment)

@jiasli jiasli self-assigned this Jul 21, 2023
@jiasli jiasli mentioned this pull request Jul 21, 2023
@jiasli jiasli mentioned this pull request Jul 24, 2023
@jiasli jiasli merged commit 7ba2349 into microsoft:dev Jul 26, 2023
7 checks passed
@jiasli jiasli deleted the py311 branch July 26, 2023 06:09
@bebound bebound mentioned this pull request Aug 24, 2023
4 tasks
This was referenced Jul 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants