Skip to content

Commit a5198b5

Browse files
authored
[Packaging] Support Python 3.11 (#26923)
1 parent 2e81a4a commit a5198b5

File tree

17 files changed

+82
-79
lines changed

17 files changed

+82
-79
lines changed

azure-pipelines-full-tests.yml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ jobs:
2525
matrix:
2626
Python39:
2727
python.version: '3.9'
28-
Python310:
29-
python.version: '3.10'
28+
Python311:
29+
python.version: '3.11'
3030
steps:
3131
- template: .azure-pipelines/templates/automation_test.yml
3232
parameters:
@@ -44,8 +44,8 @@ jobs:
4444
matrix:
4545
Python39:
4646
python.version: '3.9'
47-
Python310:
48-
python.version: '3.10'
47+
Python311:
48+
python.version: '3.11'
4949
steps:
5050
- template: .azure-pipelines/templates/automation_test.yml
5151
parameters:
@@ -63,8 +63,8 @@ jobs:
6363
matrix:
6464
Python39:
6565
python.version: '3.9'
66-
Python310:
67-
python.version: '3.10'
66+
Python311:
67+
python.version: '3.11'
6868
steps:
6969
- template: .azure-pipelines/templates/automation_test.yml
7070
parameters:
@@ -107,8 +107,8 @@ jobs:
107107
fullTest: true
108108
jobName: 'FullTest'
109109

110-
- job: AutomationFullTestPython310ProfileLatest
111-
displayName: Automation Full Test Python310 Profile Latest
110+
- job: AutomationFullTestPython311ProfileLatest
111+
displayName: Automation Full Test Python311 Profile Latest
112112
timeoutInMinutes: 9999
113113
strategy:
114114
maxParallel: 8
@@ -134,7 +134,7 @@ jobs:
134134
steps:
135135
- template: .azure-pipelines/templates/automation_test.yml
136136
parameters:
137-
pythonVersion: '3.10'
137+
pythonVersion: '3.11'
138138
profile: 'latest'
139139
instance_cnt: '8'
140140
instance_idx: '$(Instance_idx)'
@@ -147,16 +147,16 @@ jobs:
147147
- AutomationTest20190301
148148
- AutomationTest20180301
149149
- AutomationFullTestPython39ProfileLatest
150-
- AutomationFullTestPython310ProfileLatest
150+
- AutomationFullTestPython311ProfileLatest
151151
condition: and(failed(), in(variables['Build.Reason'], 'BatchedCI'))
152152
displayName: Notify CI Errors
153153
pool:
154154
name: ${{ variables.ubuntu_pool }}
155155
steps:
156156
- task: UsePythonVersion@0
157-
displayName: 'Use Python 3.10'
157+
displayName: 'Use Python 3.11'
158158
inputs:
159-
versionSpec: 3.10
159+
versionSpec: 3.11
160160
- task: AzureCLI@2
161161
inputs:
162162
azureSubscription: 'Azure CLI'

azure-pipelines.yml

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,9 @@ jobs:
130130

131131
steps:
132132
- task: UsePythonVersion@0
133-
displayName: 'Use Python 3.10'
133+
displayName: 'Use Python 3.11'
134134
inputs:
135-
versionSpec: 3.10
135+
versionSpec: 3.11
136136

137137
- bash: ./scripts/ci/dependency_check.sh
138138
displayName: 'Verify src/azure-cli/requirements.py3.Linux.txt'
@@ -145,9 +145,9 @@ jobs:
145145

146146
steps:
147147
- task: UsePythonVersion@0
148-
displayName: 'Use Python 3.10'
148+
displayName: 'Use Python 3.11'
149149
inputs:
150-
versionSpec: 3.10
150+
versionSpec: 3.11
151151

152152
- bash: ./scripts/ci/dependency_check.sh
153153
displayName: 'Verify src/azure-cli/requirements.py3.Darwin.txt'
@@ -160,9 +160,9 @@ jobs:
160160

161161
steps:
162162
- task: UsePythonVersion@0
163-
displayName: 'Use Python 3.10'
163+
displayName: 'Use Python 3.11'
164164
inputs:
165-
versionSpec: 3.10
165+
versionSpec: 3.11
166166

167167
- task: BatchScript@1
168168
inputs:
@@ -177,9 +177,9 @@ jobs:
177177
name: ${{ variables.ubuntu_pool }}
178178
steps:
179179
- task: UsePythonVersion@0
180-
displayName: 'Use Python 3.10'
180+
displayName: 'Use Python 3.11'
181181
inputs:
182-
versionSpec: 3.10
182+
versionSpec: 3.11
183183
- template: .azure-pipelines/templates/azdev_setup.yml
184184
- bash: |
185185
set -ev
@@ -349,9 +349,9 @@ jobs:
349349
name: ${{ variables.ubuntu_pool }}
350350
steps:
351351
- task: UsePythonVersion@0
352-
displayName: 'Use Python 3.10'
352+
displayName: 'Use Python 3.11'
353353
inputs:
354-
versionSpec: 3.10
354+
versionSpec: 3.11
355355

356356

357357
- script: |
@@ -411,9 +411,9 @@ jobs:
411411
--rm -v $PYPI_FILES:/mnt/pypi python:3.9 \
412412
/bin/bash -c "cd /mnt/pypi && ls && pip install --find-links ./ azure_cli-$CLI_VERSION*whl && az self-test && az --version && sleep 5"
413413
414-
echo "== Testing pip install on Python 3.10 =="
414+
echo "== Testing pip install on Python 3.11 =="
415415
docker run \
416-
--rm -v $PYPI_FILES:/mnt/pypi python:3.10 \
416+
--rm -v $PYPI_FILES:/mnt/pypi python:3.11 \
417417
/bin/bash -c "cd /mnt/pypi && ls && pip install --find-links ./ azure_cli-$CLI_VERSION*whl && az self-test && az --version && sleep 5"
418418
419419
displayName: 'Test pip Install'
@@ -427,8 +427,8 @@ jobs:
427427
matrix:
428428
Python39:
429429
python.version: '3.9'
430-
Python310:
431-
python.version: '3.10'
430+
Python311:
431+
python.version: '3.11'
432432
steps:
433433
- template: .azure-pipelines/templates/automation_test.yml
434434
parameters:
@@ -444,8 +444,8 @@ jobs:
444444
matrix:
445445
Python39:
446446
python.version: '3.9'
447-
Python310:
448-
python.version: '3.10'
447+
Python311:
448+
python.version: '3.11'
449449
steps:
450450
- template: .azure-pipelines/templates/automation_test.yml
451451
parameters:
@@ -464,8 +464,8 @@ jobs:
464464
matrix:
465465
Python39:
466466
python.version: '3.9'
467-
Python310:
468-
python.version: '3.10'
467+
Python311:
468+
python.version: '3.11'
469469
steps:
470470
- task: UsePythonVersion@0
471471
displayName: 'Use Python $(python.version)'
@@ -485,8 +485,8 @@ jobs:
485485
name: ${{ variables.ubuntu_pool }}
486486
strategy:
487487
matrix:
488-
Python310:
489-
python.version: '3.10'
488+
Python311:
489+
python.version: '3.11'
490490
steps:
491491
- task: UsePythonVersion@0
492492
displayName: 'Use Python $(python.version)'
@@ -530,7 +530,7 @@ jobs:
530530
-e CLI_VERSION=$CLI_VERSION \
531531
-e HOMEBREW_UPSTREAM_URL=$HOMEBREW_UPSTREAM_URL \
532532
--name azurecli \
533-
python:3.10 \
533+
python:3.11 \
534534
/mnt/scripts/run.sh
535535
536536
# clean up
@@ -954,9 +954,9 @@ jobs:
954954
name: ${{ variables.ubuntu_pool }}
955955
steps:
956956
- task: UsePythonVersion@0
957-
displayName: 'Use Python 3.10'
957+
displayName: 'Use Python 3.11'
958958
inputs:
959-
versionSpec: 3.10
959+
versionSpec: 3.11
960960
- template: .azure-pipelines/templates/azdev_setup.yml
961961
- bash: |
962962
set -ev
@@ -970,9 +970,9 @@ jobs:
970970
name: ${{ variables.ubuntu_pool }}
971971
steps:
972972
- task: UsePythonVersion@0
973-
displayName: 'Use Python 3.10'
973+
displayName: 'Use Python 3.11'
974974
inputs:
975-
versionSpec: 3.10
975+
versionSpec: 3.11
976976
- template: .azure-pipelines/templates/azdev_setup.yml
977977
- bash: |
978978
set -ev
@@ -987,8 +987,8 @@ jobs:
987987
matrix:
988988
Python39:
989989
python.version: '3.9'
990-
Python310:
991-
python.version: '3.10'
990+
Python311:
991+
python.version: '3.11'
992992
pool:
993993
name: ${{ variables.ubuntu_pool }}
994994
steps:
@@ -1016,9 +1016,9 @@ jobs:
10161016
name: ${{ variables.ubuntu_pool }}
10171017
steps:
10181018
- task: UsePythonVersion@0
1019-
displayName: 'Use Python 3.10'
1019+
displayName: 'Use Python 3.11'
10201020
inputs:
1021-
versionSpec: 3.10
1021+
versionSpec: 3.11
10221022
- template: .azure-pipelines/templates/azdev_setup.yml
10231023
- bash: |
10241024
set -ev
@@ -1039,9 +1039,9 @@ jobs:
10391039
name: ${{ variables.ubuntu_pool }}
10401040
steps:
10411041
- task: UsePythonVersion@0
1042-
displayName: 'Use Python 3.10'
1042+
displayName: 'Use Python 3.11'
10431043
inputs:
1044-
versionSpec: 3.10
1044+
versionSpec: 3.11
10451045
- template: .azure-pipelines/templates/azdev_setup.yml
10461046
- bash: |
10471047
set -ev
@@ -1126,9 +1126,9 @@ jobs:
11261126
name: ${{ variables.ubuntu_pool }}
11271127
steps:
11281128
- task: UsePythonVersion@0
1129-
displayName: 'Use Python 3.10'
1129+
displayName: 'Use Python 3.11'
11301130
inputs:
1131-
versionSpec: 3.10
1131+
versionSpec: 3.11
11321132
- task: AzureCLI@2
11331133
inputs:
11341134
azureSubscription: 'Azure CLI'

scripts/ci/build.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ CLASSIFIERS = [
101101
'Programming Language :: Python :: 3.8',
102102
'Programming Language :: Python :: 3.9',
103103
'Programming Language :: Python :: 3.10',
104+
'Programming Language :: Python :: 3.11',
104105
'License :: OSI Approved :: MIT License',
105106
]
106107

src/azure-cli-core/azure/cli/core/telemetry.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ def _get_azure_cli_properties(self):
191191
lambda: _get_config().get('core', 'output', fallback='unknown'))
192192
set_custom_properties(result, 'EnvironmentVariables', _get_env_string)
193193
set_custom_properties(result, 'Locale',
194-
lambda: '{},{}'.format(locale.getdefaultlocale()[0], locale.getdefaultlocale()[1]))
194+
lambda: '{},{}'.format(locale.getlocale()[0], locale.getlocale()[1]))
195195
set_custom_properties(result, 'StartTime', str(self.start_time))
196196
set_custom_properties(result, 'EndTime', str(self.end_time))
197197
set_custom_properties(result, 'InitTimeElapsed', str(self.init_time_elapsed))

src/azure-cli-core/azure/cli/core/tests/test_command_registration.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -298,10 +298,10 @@ def _check_index():
298298
loader.load_command_table(["hello", "mod-only"])
299299
_check_index()
300300

301-
with mock.patch("azure.cli.core.__version__", "2.7.0"), mock.patch.object(cli.cloud, "profile", "2019-03-01-hybrid"):
301+
with mock.patch.object(cli.cloud, "profile", "2019-03-01-hybrid"):
302302
def update_and_check_index():
303303
loader.load_command_table(["hello", "mod-only"])
304-
self.assertEqual(INDEX[CommandIndex._COMMAND_INDEX_VERSION], "2.7.0")
304+
self.assertEqual(INDEX[CommandIndex._COMMAND_INDEX_VERSION], __version__)
305305
self.assertEqual(INDEX[CommandIndex._COMMAND_INDEX_CLOUD_PROFILE], "2019-03-01-hybrid")
306306
self.assertDictEqual(INDEX[CommandIndex._COMMAND_INDEX], self.expected_command_index)
307307

@@ -395,6 +395,7 @@ def update_and_check_index():
395395
@mock.patch('azure.cli.core.extension.get_extension_modname', _mock_get_extension_modname)
396396
@mock.patch('azure.cli.core.extension.get_extensions', _mock_get_extensions)
397397
def test_command_index_always_loaded_extensions(self):
398+
import azure
398399
from azure.cli.core import CommandIndex
399400

400401
cli = DummyCli()
@@ -403,14 +404,14 @@ def test_command_index_always_loaded_extensions(self):
403404
index.invalidate()
404405

405406
# Test azext_always_loaded is loaded when command index is rebuilt
406-
with mock.patch('azure.cli.core.ALWAYS_LOADED_EXTENSIONS', ['azext_always_loaded']):
407+
with mock.patch.object(azure.cli.core,'ALWAYS_LOADED_EXTENSIONS', ['azext_always_loaded']):
407408
loader.load_command_table(["hello", "mod-only"])
408409
self.assertEqual(TestCommandRegistration.test_hook, "FAKE_HANDLER")
409410

410411
TestCommandRegistration.test_hook = []
411412

412413
# Test azext_always_loaded is loaded when command index is used
413-
with mock.patch('azure.cli.core.ALWAYS_LOADED_EXTENSIONS', ['azext_always_loaded']):
414+
with mock.patch.object(azure.cli.core,'ALWAYS_LOADED_EXTENSIONS', ['azext_always_loaded']):
414415
loader.load_command_table(["hello", "mod-only"])
415416
self.assertEqual(TestCommandRegistration.test_hook, "FAKE_HANDLER")
416417

src/azure-cli-core/azure/cli/core/tests/test_help.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,6 @@ def test_help_loads(self):
130130
except SystemExit:
131131
pass
132132
cmd_tbl = cli.invocation.commands_loader.command_table
133-
cli.invocation.parser.load_command_table(cli.invocation.commands_loader)
134133
for cmd in cmd_tbl:
135134
try:
136135
cmd_tbl[cmd].loader.command_name = cmd
@@ -140,7 +139,6 @@ def test_help_loads(self):
140139
cli.register_event(events.EVENT_INVOKER_POST_CMD_TBL_CREATE, register_global_subscription_argument)
141140
cli.register_event(events.EVENT_INVOKER_POST_CMD_TBL_CREATE, register_ids_argument)
142141
cli.raise_event(events.EVENT_INVOKER_CMD_TBL_LOADED, command_table=cmd_tbl)
143-
cli.invocation.parser.load_command_table(cli.invocation.commands_loader)
144142
_store_parsers(cli.invocation.parser, parser_dict)
145143

146144
# TODO: do we want to update this as it doesn't actually load all help.

src/azure-cli-core/azure/cli/core/tests/test_parser.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,8 @@ def load_command_table(self, args):
196196
@mock.patch('azure.cli.core.extension.get_extension_modname', _mock_extension_modname)
197197
@mock.patch('azure.cli.core.extension.get_extensions', _mock_get_extensions)
198198
def test_parser_error_spellchecker(self):
199+
import logging
200+
import azure
199201
cli = DummyCli()
200202
main_loader = MainCommandsLoader(cli)
201203
cli.loader = main_loader
@@ -224,8 +226,8 @@ def mock_add_extension(*args, **kwargs):
224226
pass
225227

226228
# run multiple faulty commands and save error logs, as well as close matches
227-
with mock.patch('logging.Logger.error', mock_log_error), \
228-
mock.patch('difflib.get_close_matches', mock_get_close_matches):
229+
with mock.patch.object(logging.Logger, 'error', mock_log_error), \
230+
mock.patch.object(difflib, 'get_close_matches', mock_get_close_matches):
229231
faulty_cmd_args = [
230232
'test module1 --opt enum_1',
231233
'test extension1 --opt enum_1',
@@ -256,11 +258,14 @@ def mock_add_extension(*args, **kwargs):
256258
self.assertIn(choice, choices)
257259

258260
# test dynamic extension install
259-
with mock.patch('logging.Logger.error', mock_log_error), \
260-
mock.patch('azure.cli.core.extension.operations.add_extension', mock_add_extension), \
261-
mock.patch('azure.cli.core.extension.dynamic_install._get_extension_command_tree', mock_ext_cmd_tree_load), \
262-
mock.patch('azure.cli.core.extension.dynamic_install._get_extension_use_dynamic_install_config', return_value='yes_without_prompt'), \
263-
mock.patch('azure.cli.core.extension.dynamic_install._get_extension_run_after_dynamic_install_config', return_value=False):
261+
with mock.patch.object(logging.Logger, 'error', mock_log_error), \
262+
mock.patch.object(azure.cli.core.extension.operations, 'add_extension', mock_add_extension), \
263+
mock.patch.object(azure.cli.core.extension.dynamic_install, '_get_extension_command_tree',
264+
mock_ext_cmd_tree_load), \
265+
mock.patch.object(azure.cli.core.extension.dynamic_install, '_get_extension_use_dynamic_install_config',
266+
return_value='yes_without_prompt'), \
267+
mock.patch.object(azure.cli.core.extension.dynamic_install,
268+
'_get_extension_run_after_dynamic_install_config', return_value=False):
264269
with self.assertRaises(SystemExit):
265270
parser.parse_args('test new-ext create --opt enum_2'.split())
266271
self.assertIn("Extension new-ext-name installed. Please rerun your command.", logger_msgs[5])

src/azure-cli-core/azure/cli/core/util.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -655,14 +655,8 @@ def in_cloud_console():
655655

656656
def get_arg_list(op):
657657
import inspect
658-
659-
try:
660-
# only supported in python3 - falling back to argspec if not available
661-
sig = inspect.signature(op)
662-
return sig.parameters
663-
except AttributeError:
664-
sig = inspect.getargspec(op) # pylint: disable=deprecated-method
665-
return sig.args
658+
sig = inspect.signature(op)
659+
return sig.parameters
666660

667661

668662
def is_track2(client_class):

0 commit comments

Comments
 (0)