PyFCM icon indicating copy to clipboard operation
PyFCM copied to clipboard

google.oauth2.service_account.Credentials is not assignable to google.oauth2.credentials.Credentials

Open vincentfenet opened this issue 10 months ago • 3 comments

Hi,

While migrating from 2.0.7 to 2.0.8, i got a pyright check error.

Using a very simple test:

from google.oauth2 import service_account
from pyfcm import FCMNotification

gcp_json_credentials_dict = {}

credentials = service_account.Credentials.from_service_account_info(
    gcp_json_credentials_dict,
    scopes=["https://www.googleapis.com/auth/firebase.messaging"],
)
fcm = FCMNotification(
    credentials=credentials, project_id="<project-id>"
)

Here is the error:

test.py:11:17 - error: Argument of type "Credentials" cannot be assigned to parameter "credentials" of type "Credentials" in function "__init__"
    "google.oauth2.service_account.Credentials" is not assignable to "google.oauth2.credentials.Credentials" (reportArgumentType)
1 error, 0 warnings, 0 informations 

Not sure, but it looks like you need to use the right "Credentials" class here.

vincentfenet avatar Mar 07 '25 10:03 vincentfenet

Can you send a PR

olucurious avatar Mar 07 '25 10:03 olucurious

you want me to change from google.oauth2.credentials import Credentials to something like from google.oauth2.service_account import Credentials ?

vincentfenet avatar Mar 07 '25 13:03 vincentfenet

any news ?

vincentfenet avatar Mar 24 '25 10:03 vincentfenet