-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Fix mypy errors #42192
Conversation
… error handling for trunk retrieval
API Change CheckAPIView identified API level changes in this PR and created the following API reviews |
…into sofiar/Address_mypy_errors
There was a problem hiding this 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()
withos.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 |
...on/azure-communication-phonenumbers/samples/browse_and_reserve_phone_numbers_sample_async.py
Outdated
Show resolved
Hide resolved
...nication/azure-communication-phonenumbers/samples/browse_and_reserve_phone_numbers_sample.py
Outdated
Show resolved
Hide resolved
...ion/azure-communication-phonenumbers/samples/browse_and_reserve_numbers_bulk_sample_async.py
Outdated
Show resolved
Hide resolved
...unication/azure-communication-phonenumbers/samples/browse_and_reserve_numbers_bulk_sample.py
Outdated
Show resolved
Hide resolved
...on-phonenumbers/azure/communication/phonenumbers/siprouting/aio/_sip_routing_client_async.py
Show resolved
Hide resolved
…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]>
...ommunication-phonenumbers/azure/communication/phonenumbers/siprouting/_sip_routing_client.py
Outdated
Show resolved
Hide resolved
4846517
to
269f1b3
Compare
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:
After fixing sample typing errors, you should remove the
mypy=false
andtype_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:
General Guidelines and Best Practices
Testing Guidelines