azure-cli
azure-cli copied to clipboard
Python 3.14: batch module argument loading fails due to typing/union handling in _command_type.py
Summary
Doc generation fails on Python 3.14 when running ExportCommands.py.
Environment
- Repo:
Azure/azure-cli - OS: Windows
- Python (failing):
3.14.4 - Python (working):
3.13.13
Repro steps
- Activate
env314. - Ensure
PYTHONPATHincludes localknackcheckout. - Run:
python ExportCommands.py ./doc
Actual result
The run fails during command argument loading with:
AttributeError: module 'azure.batch.models' has no attribute 'bool | None'
Trace location includes:
azure-cli/src/azure-cli/azure/cli/command_modules/batch/_command_type.py:838azure-cli/src/azure-cli/azure/cli/command_modules/batch/_command_type.py:41
Expected result
Doc generation completes successfully.
Comparison
- Python
3.13.13: succeeds (Export finished, help files generated) - Python
3.14.4: fails with the error above
Additional output seen in failing run
- Error loading command module
acs: deadlock detected by_ModuleLock('requests.structures') - Error loading command module
containerapp: deadlock detected by_ModuleLock('requests.structures')
Thank you for opening this issue, we will look into it.
Update after investigation:
This does not appear to be specific to doc generation itself.
What we verified:
- Python 3.13.13:
TestBatchLoader::test_batch_load_argumentspasses - Python 3.14.4: the same test fails
- The original
ExportCommands.pyfailure is just one caller that triggers the same Batch command-loading path
Narrow repro:
env313/Scripts/python.exe -m pytest src/azure-cli/azure/cli/command_modules/batch/tests/latest/test_batch_commands.py::TestBatchLoader::test_batch_load_arguments -v --tb=short- passes
env314/Scripts/python.exe -m pytest src/azure-cli/azure/cli/command_modules/batch/tests/latest/test_batch_commands.py::TestBatchLoader::test_batch_load_arguments -v --tb=short- fails
Current 3.14 failure:
AttributeError: module 'azure.batch.models' has no attribute 'VirtualMachineConfiguration | None'
Owning code path:
src/azure-cli/azure/cli/command_modules/batch/_command_type.py- specifically the Batch model introspection / flattening logic used to build CLI arguments
Interpretation:
- Python 3.14 changed typing/union representations
- the Batch module relies on brittle typing introspection/string handling
- doc generation exposed it first, but the underlying bug is in Batch runtime argument loading, not in the docs pipeline specifically