Skip to content

Fix mypy errors #42192

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

Merged
merged 11 commits into from
Jul 31, 2025
Merged

Fix mypy errors #42192

merged 11 commits into from
Jul 31, 2025

Conversation

sofiar-msft
Copy link
Member

@sofiar-msft sofiar-msft commented Jul 23, 2025

Description

Hi Python communication library code owners,
Please see the notice below. It is required that each client library in the Python repo run and pass static type checking with MyPy on source and sample code. The table below describes communication libraries with disabled or failing MyPy. Please take a look at the errors and actions needed and ensure each library is enabled with MyPy and passing by August 1st to avoid unexpected failures blocking releases.

azure-communication-phonenumbers

Build

Fix errors and enable mypy and type_check_samples in pyproject.toml

To view errors locally you can run the following command at the package-level:

pip install tox

tox run -e next-mypy -c ../../../eng/tox/tox.ini --root .

After fixing sample typing errors, you should remove the mypy=false and type_check_samples=false found in your library's pyproject.toml file to enable this check to run in CI.
If there is anything preventing these checks from being enabled for your library, please reach out. Thanks for your help in making our libraries MyPy clean for our customers!

All SDK Contribution checklist:

  • The pull request does not introduce [breaking changes]
  • CHANGELOG is updated for new features, bug fixes or other significant changes.
  • I have read the contribution guidelines.

General Guidelines and Best Practices

  • Title of the pull request is clear and informative.
  • There are a small number of commits, each of which have an informative message. This means that previously merged commits do not appear in the history of the PR. For more information on cleaning up the commits in your PR, see this page.

Testing Guidelines

  • Pull request includes test coverage for the included changes.

Copy link

github-actions bot commented Jul 23, 2025

API Change Check

APIView identified API level changes in this PR and created the following API reviews

azure-communication-phonenumbers

@sofiar-msft sofiar-msft marked this pull request as ready for review July 29, 2025 22:20
@Copilot Copilot AI review requested due to automatic review settings July 29, 2025 22:20
Copy link
Contributor

@Copilot 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 fixes MyPy type checking errors in the Azure Communication Phone Numbers SDK. The changes are primarily focused on correcting type annotations and handling potential None values that MyPy flagged as unsafe operations.

  • Replaces os.getenv() with os.environ[] in sample files to ensure non-None return types
  • Adds proper type checking and null safety for optional fields in client code
  • Updates type annotations to include Union types for credentials and adds necessary imports
  • Enables MyPy checking by removing disabled flags from pyproject.toml

Reviewed Changes

Copilot reviewed 38 out of 38 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
Multiple sample files Replace os.getenv() with os.environ[] for required environment variables
_sip_routing_client_async.py Add null checks, type annotations, and proper error handling
_sip_routing_client.py Add null checks, type annotations, and proper error handling
_phone_numbers_client_async.py Add type casts and null safety checks
_phone_numbers_client.py Add type casts and null safety checks
_patch.py files Add __all__ declarations
pyproject.toml Enable MyPy and type checking by removing disabled flags

sofiar-msft and others added 4 commits July 30, 2025 11:04
…wse_and_reserve_phone_numbers_sample_async.py


Remove redundant initialization

Co-authored-by: Copilot <[email protected]>
…wse_and_reserve_phone_numbers_sample.py

Co-authored-by: Copilot <[email protected]>
…wse_and_reserve_numbers_bulk_sample_async.py

Co-authored-by: Copilot <[email protected]>
…wse_and_reserve_numbers_bulk_sample.py

Co-authored-by: Copilot <[email protected]>
@sofiar-msft sofiar-msft force-pushed the sofiar/Address_mypy_errors branch from 4846517 to 269f1b3 Compare July 30, 2025 23:52
@sofiar-msft sofiar-msft merged commit 09c6ca6 into Azure:main Jul 31, 2025
20 checks passed
@sofiar-msft sofiar-msft deleted the sofiar/Address_mypy_errors branch July 31, 2025 16:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants