Skip to content

Commit

Permalink
Merge pull request #22 from henribru/v20.0.0-support
Browse files Browse the repository at this point in the history
Add v20.0.0 support
  • Loading branch information
henribru authored Mar 4, 2023
2 parents eb8363d + cdd1d5d commit 5b38eb7
Show file tree
Hide file tree
Showing 2,017 changed files with 37,773 additions and 33,843 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[![PyPI version](https://badge.fury.io/py/google-ads-stubs.svg)](https://badge.fury.io/py/google-ads-stubs)

This package provides type stubs for the [Google Ads API Client Library for Python](https://github.com/googleads/google-ads-python).
It's currently compatible with v18.1.0 of this library. It allows you to type check usage of the library with e.g. [mypy](http://mypy-lang.org/) and will also improve autocomplete in many editors.
It's currently compatible with v20.0.0 of this library. It allows you to type check usage of the library with e.g. [mypy](http://mypy-lang.org/) and will also improve autocomplete in many editors.

**This is in no way affiliated with Google.**

Expand All @@ -26,16 +26,16 @@ methods of `Client`. The only exception is `get_service("GoogleAdsService")`, wh
# Replace this:
campaign_operation = client.get_type('CampaignOperation')
# With this:
from google.ads.googleads.v10 import CampaignOperation
from google.ads.googleads.v13 import CampaignOperation
campaign_operation: CampaignOperation = client.get_type('CampaignOperation')
# Or this:
from google.ads.googleads.v10 import CampaignOperation
from google.ads.googleads.v13 import CampaignOperation
campaign_operation = CampaignOperation()

# Replace this:
campaign_service = client.get_service('CampaignService')
# With this:
from google.ads.googleads.v10 import CampaignServiceClient
from google.ads.googleads.v13 import CampaignServiceClient
campaign_service: CampaignServiceClient = client.get_service('CampaignService')
# But you can keep this:
google_ads_service = client.get_service('GoogleAdsService')
Expand All @@ -52,7 +52,7 @@ On the other hand certain types are more strict than what's allowed at runtime.
# Replace this:
AdGroupAd({"status": "ENABLED", ad={"type": 2}})
# With this:
from google.ads.googleads.v10 import AdGroupAdStatusEnum, AdTypeEnum, Ad
from google.ads.googleads.v13 import AdGroupAdStatusEnum, AdTypeEnum, Ad
AdGroupAd(status=AdGroupAdStatusEnum.AdGroupAdStatus.ENABLED, ad=Ad(type=AdTypeEnum.AdType.TEXT_AD))
```

Expand Down
20 changes: 12 additions & 8 deletions google-stubs/ads/googleads/client.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ from google.oauth2.credentials import Credentials
from google.protobuf.message import Message
from typing_extensions import Literal

from google.ads.googleads import v10, v11
from google.ads.googleads import v11, v12, v13
from google.ads.googleads.config import _ConfigDataUnparsed

_V10 = Literal["v10"]
_V11 = Literal["v11"]
_V12 = Literal["v12"]
_V = Union[_V10, _V11, _V12]
_V13 = Literal["v13"]
_V = Union[_V11, _V12, _V13]

class GoogleAdsClient:
credentials: Credentials
Expand Down Expand Up @@ -57,16 +57,20 @@ class GoogleAdsClient:
) -> None: ...
def get_type(cls, name: str, version: _V = ...) -> Any: ...
@overload
def get_service(
self, name: Literal["GoogleAdsService"], version: _V10
) -> v10.GoogleAdsServiceClient: ...
@overload
def get_service(
self, name: Literal["GoogleAdsService"], version: _V11
) -> v11.GoogleAdsServiceClient: ...
@overload
def get_service(
self, name: Literal["GoogleAdsService"], version: _V12
) -> v12.GoogleAdsServiceClient: ...
@overload
def get_service(
self, name: Literal["GoogleAdsService"], version: _V13
) -> v13.GoogleAdsServiceClient: ...
@overload
def get_service(
self, name: Literal["GoogleAdsService"]
) -> v11.GoogleAdsServiceClient: ...
) -> v13.GoogleAdsServiceClient: ...
@overload
def get_service(self, name: str, version: _V = ...) -> Any: ...
4 changes: 2 additions & 2 deletions google-stubs/ads/googleads/errors.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ from typing import Union

import grpc

from google.ads.googleads.v10 import GoogleAdsFailure as GoogleAdsFailureV10
from google.ads.googleads.v11 import GoogleAdsFailure as GoogleAdsFailureV11
from google.ads.googleads.v12 import GoogleAdsFailure as GoogleAdsFailureV12
from google.ads.googleads.v13 import GoogleAdsFailure as GoogleAdsFailureV13

GoogleAdsFailure = Union[GoogleAdsFailureV10, GoogleAdsFailureV11, GoogleAdsFailureV12]
GoogleAdsFailure = Union[GoogleAdsFailureV11, GoogleAdsFailureV12, GoogleAdsFailureV13]

class GoogleAdsException(Exception):
error: grpc.RpcError = ...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@ from typing import Callable, TypeVar

import grpc

from google.ads.googleads import v10, v11, v12
from google.ads.googleads import v11, v12, v13

from .interceptor import Interceptor

_Request = TypeVar(
"_Request",
v10.SearchGoogleAdsRequest,
v10.SearchGoogleAdsStreamRequest,
v11.SearchGoogleAdsRequest,
v11.SearchGoogleAdsStreamRequest,
v12.SearchGoogleAdsRequest,
v12.SearchGoogleAdsStreamRequest,
v13.SearchGoogleAdsRequest,
v13.SearchGoogleAdsStreamRequest,
)
_Response = TypeVar("_Response")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@ from typing import Callable, TypeVar
import grpc
from google.protobuf.message import Message

from google.ads.googleads import v10, v11, v12
from google.ads.googleads import v11, v12, v13

from .interceptor import Interceptor

_Request = TypeVar(
"_Request",
v10.SearchGoogleAdsRequest,
v10.SearchGoogleAdsStreamRequest,
v11.SearchGoogleAdsRequest,
v11.SearchGoogleAdsStreamRequest,
v12.SearchGoogleAdsRequest,
v12.SearchGoogleAdsStreamRequest,
v13.SearchGoogleAdsRequest,
v13.SearchGoogleAdsStreamRequest,
)
_Response = TypeVar("_Response")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@ from typing import Callable, Tuple, TypeVar

import grpc

from google.ads.googleads import v10, v11, v12
from google.ads.googleads import v11, v12, v13

from .interceptor import Interceptor

_Request = TypeVar(
"_Request",
v10.SearchGoogleAdsRequest,
v10.SearchGoogleAdsStreamRequest,
v11.SearchGoogleAdsRequest,
v11.SearchGoogleAdsStreamRequest,
v12.SearchGoogleAdsRequest,
v12.SearchGoogleAdsStreamRequest,
v13.SearchGoogleAdsRequest,
v13.SearchGoogleAdsStreamRequest,
)
_Response = TypeVar("_Response")

Expand Down
Loading

0 comments on commit 5b38eb7

Please sign in to comment.