Skip to content

Commit bc9dd3a

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

4 files changed

Lines changed: 123 additions & 3 deletions

File tree

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
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+
steps:
12+
- uses: actions/checkout@v4
13+
14+
- name: Setup Python
15+
uses: actions/setup-python@v5
16+
17+
- name: Install uv
18+
uses: astral-sh/setup-uv@v2
19+
with:
20+
enable-cache: true
21+
22+
- name: Update stubs
23+
run: uv run python create_stubs.py
24+
25+
- name: Detect changes
26+
id: changes
27+
run: |
28+
if git diff --quiet; then
29+
echo "has_changes=false" >> "$GITHUB_OUTPUT"
30+
else
31+
echo "has_changes=true" >> "$GITHUB_OUTPUT"
32+
fi
33+
34+
- name: Bump minor version in pyproject.toml
35+
if: steps.changes.outputs.has_changes == 'true'
36+
run: uv version --bump minor
37+
38+
- name: Create pull request
39+
if: steps.changes.outputs.has_changes == 'true'
40+
uses: peter-evans/create-pull-request@c0f553fe549906ede9cf27b5156039d195d2ece0
41+
with:
42+
token: ${{ secrets.PR_TOKEN }}
43+
commit-message: Update stubs
44+
author: henribru <6639509+henribru@users.noreply.github.com>
45+
committer: henribru <6639509+henribru@users.noreply.github.com>
46+
branch: create-updated-stubs-pr
47+
delete-branch: true
48+
title: Update stubs
49+
50+

.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)