Skip to content

Commit 1c91c61

Browse files
committed
Add workflow for updating stubs
1 parent 41b013d commit 1c91c61

4 files changed

Lines changed: 126 additions & 3 deletions

File tree

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Create updated stubs PR
2+
3+
on:
4+
workflow_dispatch:
5+
schedule:
6+
- cron: '0 0 * * 0' # every Sunday at midnight
7+
8+
jobs:
9+
create_pr:
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: write
13+
pull-requests: write
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- name: Setup Python
18+
uses: actions/setup-python@v5
19+
20+
- name: Install uv
21+
uses: astral-sh/setup-uv@v2
22+
with:
23+
enable-cache: true
24+
25+
- name: Update stubs
26+
run: uv run python create_stubs.py
27+
28+
- name: Detect changes
29+
id: changes
30+
run: |
31+
if git diff --quiet; then
32+
echo "has_changes=false" >> "$GITHUB_OUTPUT"
33+
else
34+
echo "has_changes=true" >> "$GITHUB_OUTPUT"
35+
fi
36+
37+
- name: Bump minor version in pyproject.toml
38+
if: steps.changes.outputs.has_changes == 'true'
39+
run: uv version --bump minor
40+
41+
- name: Create pull request
42+
if: steps.changes.outputs.has_changes == 'true'
43+
uses: peter-evans/create-pull-request@v6
44+
with:
45+
commit-message: Update stubs
46+
author: henribru <6639509+henribru@users.noreply.github.com>
47+
committer: henribru <6639509+henribru@users.noreply.github.com>
48+
branch: create-updated-stubs-pr
49+
delete-branch: true
50+
title: Update stubs
51+
body: Update stubs
52+
53+

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@
1111
!/README.md
1212
!/LICENSE
1313
!/create_stubs.py
14+
!discovery.pyi

create_stubs.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,13 @@
22
import json
33
import keyword
44
import os
5-
import re
65
import shutil
76
import subprocess
87
import textwrap
98
from contextlib import contextmanager
109
from pathlib import Path
1110
from typing import Any, DefaultDict, Dict, List, Set
1211

13-
from mypy.api import run
14-
1512
from googleapiclient.discovery import fix_method_name, key2param
1613

1714

@@ -397,6 +394,11 @@ def copytree(src, dst, symlinks=False, ignore=None, overwrite=True):
397394

398395

399396
def main():
397+
subprocess.run(["uv", "remove", "google-api-python-client"])
398+
subprocess.run(["uv", "add", "google-api-python-client"])
399+
subprocess.run(["git", "clone", "https://github.com/googleapis/google-api-python-client.git"]);
400+
subprocess.run(["git", "restore", "."], cwd="google-api-python-client")
401+
subprocess.run(["git", "pull"], cwd="google-api-python-client")
400402
shutil.rmtree("apiclient-stubs", ignore_errors=True)
401403
apis = []
402404
ignored_apis = [

discovery.pyi

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
import types
2+
from email.generator import BytesGenerator
3+
from typing import Any, Protocol, TypeVar, overload
4+
5+
import google.auth.credentials
6+
import httplib2
7+
import oauth2client # type: ignore[import-not-found]
8+
from _typeshed import Incomplete
9+
from google.api_core.client_options import ClientOptions
10+
from typing_extensions import Literal
11+
12+
from googleapiclient.discovery_cache.base import Cache
13+
from googleapiclient.http import HttpMock, HttpRequest
14+
from googleapiclient.model import Model
15+
16+
_T = TypeVar("_T")
17+
18+
class _BytesGenerator(BytesGenerator): ...
19+
20+
def fix_method_name(name): ...
21+
def key2param(key): ...
22+
23+
class ResourceMethodParameters:
24+
argmap: Incomplete
25+
required_params: Incomplete
26+
repeated_params: Incomplete
27+
pattern_params: Incomplete
28+
query_params: Incomplete
29+
path_params: Incomplete
30+
param_types: Incomplete
31+
enum_params: Incomplete
32+
def __init__(self, method_desc) -> None: ...
33+
def set_parameters(self, method_desc) -> None: ...
34+
35+
class Resource:
36+
def __init__(
37+
self,
38+
http,
39+
baseUrl,
40+
model,
41+
requestBuilder,
42+
developerKey,
43+
resourceDesc,
44+
rootDesc,
45+
schema,
46+
) -> None: ...
47+
def __enter__(self: _T) -> _T: ...
48+
def __exit__(
49+
self,
50+
exc_type: type[BaseException] | None,
51+
exc: BaseException | None,
52+
exc_tb: types.TracebackType | None,
53+
) -> None: ...
54+
def close(self) -> None: ...
55+
56+
class _RequestBuilder(Protocol):
57+
def __call__(
58+
self,
59+
http,
60+
postproc,
61+
uri,
62+
method: str = ...,
63+
body: Incomplete | None = ...,
64+
headers: Incomplete | None = ...,
65+
methodId: Incomplete | None = ...,
66+
resumable: Incomplete | None = ...,
67+
) -> HttpRequest: ...

0 commit comments

Comments
 (0)