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

mypy checks violation in AzureBlobStorage #13216

Closed
5 tasks done
bowenliang123 opened this issue Feb 5, 2025 · 1 comment · Fixed by #13215
Closed
5 tasks done

mypy checks violation in AzureBlobStorage #13216

bowenliang123 opened this issue Feb 5, 2025 · 1 comment · Fixed by #13215
Labels
🐞 bug Something isn't working

Comments

@bowenliang123
Copy link
Contributor

Self Checks

  • This is only for bug report, if you would like to ask a question, please head to Discussions.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
  • [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
  • Please do not modify this template :) and fill in all the required fields.

Dify version

master

Cloud or Self Hosted

Self Hosted (Source)

Steps to reproduce

  • the violation in mypy checks:
extensions/storage/azure_blob_storage.py:25: error: Incompatible types in assignment (expression has type "None", variable has type "DefaultAzureCredential")  [assignment]
extensions/storage/azure_blob_storage.py:67: error: Argument "account_url" to "BlobServiceClient" has incompatible type "str | None"; expected "str"  [arg-type]
Found 2 errors in 1 file (checked 952 source files)

✔️ Expected Behavior

No response

❌ Actual Behavior

No response

Copy link

dosubot bot commented Feb 5, 2025

The mypy errors you're encountering in the azure_blob_storage.py file are related to type mismatches. Here's how you can address them:

  1. Incompatible types in assignment (line 25):
    The error indicates that None is being assigned to a variable expected to be of type DefaultAzureCredential. To resolve this, ensure that self.credential is always assigned a DefaultAzureCredential or handle the None case appropriately. You might need to adjust the type hint for self.credential to allow None if it's a valid state, like this:

    from typing import Optional
    from azure.identity import DefaultAzureCredential
    
    self.credential: Optional[DefaultAzureCredential] = None
  2. Incompatible type for account_url (line 67):
    The error suggests that account_url is expected to be a string, but it might be None. Ensure that dify_config.AZURE_BLOB_ACCOUNT_URL is always a string. If it can be None, you should handle this case before passing it to BlobServiceClient. For example:

    if self.account_url is not None:
        self.blob_service_client = BlobServiceClient(account_url=self.account_url, credential=self.credential)
    else:
        # Handle the None case appropriately

By ensuring that the types match the expected types, you should be able to resolve these mypy errors.

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other

@dosubot dosubot bot added the 🐞 bug Something isn't working label Feb 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant