Skip to content
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

Unsuppressible mypy syntax error for azure.core when using it from a typechecked project with python 3.9.0 #15762

Closed
christophebiocca opened this issue Dec 11, 2020 · 2 comments · Fixed by #15768
Assignees
Labels
Azure.Core bug This issue requires a change to an existing behavior in the product in order to be resolved. Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that

Comments

@christophebiocca
Copy link

christophebiocca commented Dec 11, 2020

  • Package Name: azure.core
  • Package Version: 1.9.0
  • Operating System: Arch Linux
  • Python Version: 3.9.0

Describe the bug
Importing from azure.core.* will cause a hard-to-suppress mypy typechecking error about internal type annotations of azure core that have syntax errors.

I don't understand why it only happens on 3.9.0.

Note that mypy has a really hard time with syntax errors: python/mypy#6897 which makes it hard for the end user to ignore them.

To Reproduce

  1. Clone https://github.com/EncircleInc/azure-core-mypy-error
  2. pip install -r requirements.lock.txt file.
  3. mypy -p test. You'll get something like .../python3.9/site-packages/azure/core/pipeline/policies/_authentication.py:33: error: syntax error in type comment '(TokenCredential, *str, Mapping[str, Any]) -> None
  4. Try to suppress the error by adding ignore_errors = True in the mypy.ini file.
  5. mypy -p test still errors out.

Expected behavior
No type errors when using default mypy settings, or an error saying there aren't any types available.

@ghost ghost added needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. customer-reported Issues that are reported by GitHub users external to the Azure organization. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that labels Dec 11, 2020
@christophebiocca
Copy link
Author

Note to anyone else experiencing the issue: a workaround is to add the following to your mypy.ini:

[mypy-azure.core.pipeline.policies._authentication]
follow_imports = skip

A bit of a nuclear option, but nothing short of it will work.

@lmazuel lmazuel self-assigned this Dec 12, 2020
@lmazuel lmazuel added Azure.Core Client This issue points to a problem in the data-plane of the library. labels Dec 12, 2020
@ghost ghost removed the needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. label Dec 12, 2020
@lmazuel lmazuel added the bug This issue requires a change to an existing behavior in the product in order to be resolved. label Dec 12, 2020
@lmazuel
Copy link
Member

lmazuel commented Dec 12, 2020

That's an interesting bug! PR to fix it #15768

openapi-sdkautomation bot pushed a commit to AzureSDKAutomation/azure-sdk-for-python that referenced this issue Sep 8, 2021
Use IncidentSeverity in IncidentInfo (Azure#15762)

Co-authored-by: Anat Gilenson <[email protected]>
@github-actions github-actions bot locked and limited conversation to collaborators Apr 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Azure.Core bug This issue requires a change to an existing behavior in the product in order to be resolved. Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants