Skip to content

Fix: FutureWarning functools.partial will be a method descriptor in future Python versions; wrap it in staticmethod() if you want to preserve the old behavior#31821

Closed
anaclumos wants to merge 4 commits intoAzure:devfrom
anaclumos:dev

Conversation

@anaclumos
Copy link
Copy Markdown

Related command

Everything, including az login

Description

This removes the warning script error message:

python3.13-azure-cli-core-2.75.0/lib/python3.13/site-packages/azure/cli/core/aaz/_command.py:132: FutureWarning: functools.partial will be a method descriptor in future Python versions; wrap it in staticmethod() if you want to preserve the old behavior
  if self.AZ_PREVIEW_INFO:
python3.13-azure-cli-core-2.75.0/lib/python3.13/site-packages/azure/cli/core/aaz/_command.py:133: FutureWarning: functools.partial will be a method descriptor in future Python versions; wrap it in staticmethod() if you want to preserve the old behavior
  self.preview_info = self.AZ_PREVIEW_INFO(cli_ctx=self.cli_ctx)
python3.13-azure-cli-core-2.75.0/lib/python3.13/site-packages/azure/cli/core/aaz/_command.py:50: FutureWarning: functools.partial will be a method descriptor in future Python versions; wrap it in staticmethod() if you want to preserve the old behavior
  if self.AZ_PREVIEW_INFO:
python3.13-azure-cli-core-2.75.0/lib/python3.13/site-packages/azure/cli/core/aaz/_command.py:51: FutureWarning: functools.partial will be a method descriptor in future Python versions; wrap it in staticmethod() if you want to preserve the old behavior
  self.group_kwargs['preview_info'] = self.AZ_PREVIEW_INFO(cli_ctx=self.cli_ctx)

…uture Python versions; wrap it in staticmethod() if you want to preserve the old behavior
Copilot AI review requested due to automatic review settings July 16, 2025 02:01
@azure-client-tools-bot-prd
Copy link
Copy Markdown

Validation for Azure CLI Full Test Starting...

Thanks for your contribution!

@azure-client-tools-bot-prd
Copy link
Copy Markdown

Validation for Breaking Change Starting...

Thanks for your contribution!

@yonzhan
Copy link
Copy Markdown
Collaborator

yonzhan commented Jul 16, 2025

Thank you for your contribution! We will review the pull request and get back to you soon.

@github-actions
Copy link
Copy Markdown

The git hooks are available for azure-cli and azure-cli-extensions repos. They could help you run required checks before creating the PR.

Please sync the latest code with latest dev branch (for azure-cli) or main branch (for azure-cli-extensions).
After that please run the following commands to enable git hooks:

pip install azdev --upgrade
azdev setup -c <your azure-cli repo path> -r <your azure-cli-extensions repo path>

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR addresses future compatibility warnings in Python 3.13 by wrapping functools.partial calls in staticmethod() to preserve the current behavior and eliminate deprecation warnings.

  • Wraps functools.partial calls in staticmethod() for AZ_PREVIEW_INFO, AZ_EXPERIMENTAL_INFO, and AZ_DEPRECATE_INFO class attributes
  • Applies the fix to both command group and command decorators
  • Maintains backward compatibility while preparing for future Python versions

Comment thread src/azure-cli-core/azure/cli/core/aaz/_command.py Outdated
Comment thread src/azure-cli-core/azure/cli/core/aaz/_command.py Outdated
@microsoft-github-policy-service
Copy link
Copy Markdown
Contributor

Thank you for your contribution @anaclumos! We will review the pull request and get back to you soon.

@microsoft-github-policy-service microsoft-github-policy-service bot added customer-reported Issues that are reported by GitHub users external to the Azure organization. Auto-Assign Auto assign by bot labels Jul 16, 2025
@microsoft-github-policy-service microsoft-github-policy-service bot added the Account az login/account label Jul 16, 2025
anaclumos and others added 2 commits July 28, 2025 18:41
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@anaclumos
Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree [company="Sunghyun Cho"]

@anaclumos
Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

@sheeeng
Copy link
Copy Markdown

sheeeng commented Aug 14, 2025

I used the following to suppress the warnings as a workaround while waiting for this fix to be made available.

export PYTHONWARNINGS="ignore::FutureWarning"

or

PYTHONWARNINGS="ignore::FutureWarning" az --help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Account az login/account Auto-Assign Auto assign by bot customer-reported Issues that are reported by GitHub users external to the Azure organization.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants