diff --git a/.gitignore b/.gitignore index d083ea1dd..0670e9ac9 100644 --- a/.gitignore +++ b/.gitignore @@ -51,6 +51,14 @@ docs.metadata # Virtual environment env/ venv/ +.venv/ +.env/ + +# UV generated files +.python-version +uv.lock +hello.py +pyproject.toml # Test logs coverage.xml diff --git a/MANIFEST.in b/MANIFEST.in index d6814cd60..49e9a0b28 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -23,3 +23,5 @@ global-exclude __pycache__ # Exclude scripts for samples readmegen prune scripts/readme-gen + +include google/cloud/storage/py.typed \ No newline at end of file diff --git a/google/cloud/storage/__init__.pyi b/google/cloud/storage/__init__.pyi new file mode 100644 index 000000000..bfc10e366 --- /dev/null +++ b/google/cloud/storage/__init__.pyi @@ -0,0 +1,104 @@ +# Stubs for google.cloud.storage package +# Generated minimal PEP 561 stub to improve Pylance/Pyright experience. +from __future__ import annotations + +from typing import Any, Optional, MutableMapping, Sequence, Tuple + +__all__ = ["__version__", "Batch", "Blob", "Bucket", "Client"] + +__version__: str + +class Batch: + def __init__(self, client: "Client", raise_exception: bool = True) -> None: ... + + def finish(self, raise_exception: bool = True) -> Sequence[Tuple[Any, Any]]: ... + + +class Blob: + STORAGE_CLASSES: Sequence[str] + + def __init__( + self, + name: str, + bucket: "Bucket", + chunk_size: Optional[int] = None, + encryption_key: Optional[bytes] = None, + kms_key_name: Optional[str] = None, + generation: Optional[int] = None, + ) -> None: ... + + name: str + bucket: "Bucket" + generation: Optional[int] + + @property + def public_url(self) -> str: ... + + @property + def client(self) -> "Client": ... + + def from_uri(self, uri: str) -> "Blob": ... + + def download_as_bytes(self, timeout: Optional[float] = ...) -> bytes: ... + + def upload_from_file(self, file_obj: Any, timeout: Optional[float] = ...) -> None: ... + + +class Bucket: + STORAGE_CLASSES: Sequence[str] + + def __init__( + self, + client: "Client", + name: str, + user_project: Optional[str] = None, + generation: Optional[int] = None, + ) -> None: ... + + name: str + client: "Client" + user_project: Optional[str] + + def blob(self, blob_name: str, chunk_size: Optional[int] = None) -> Blob: ... + + def get_blob(self, blob_name: str, timeout: Optional[float] = ...) -> Optional[Blob]: ... + + def create(self, timeout: Optional[float] = ...) -> None: ... + + @classmethod + def from_string(cls, uri: str, client: Optional["Client"] = ...) -> "Bucket": ... + + +class Client: + SCOPE: Sequence[str] + + def __init__( + self, + project: Optional[str] = ..., + credentials: Optional[Any] = ..., + _http: Optional[Any] = ..., + client_info: Optional[Any] = ..., + client_options: Optional[Any] = ..., + use_auth_w_custom_endpoint: bool = True, + extra_headers: Optional[MutableMapping[str, str]] = ..., *, api_key: Optional[str] = ..., + ) -> None: ... + + project: Optional[str] + + @classmethod + def create_anonymous_client(cls) -> "Client": ... + + @property + def universe_domain(self) -> str: ... + + @property + def api_endpoint(self) -> str: ... + + @property + def current_batch(self) -> Optional[Batch]: ... + + def bucket(self, bucket_name: str, user_project: Optional[str] = None, generation: Optional[int] = None) -> Bucket: ... + + def batch(self, raise_exception: bool = True) -> Batch: ... + + def get_service_account_email(self, project: Optional[str] = None, timeout: Optional[float] = ..., retry: Optional[Any] = ...) -> str: ... diff --git a/google/cloud/storage/py.typed b/google/cloud/storage/py.typed new file mode 100644 index 000000000..1aad32711 --- /dev/null +++ b/google/cloud/storage/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561 \ No newline at end of file diff --git a/setup.py b/setup.py index 43e3404f6..4efda30ec 100644 --- a/setup.py +++ b/setup.py @@ -99,6 +99,9 @@ ], platforms="Posix; MacOS X; Windows", packages=packages, + package_data={ + "google.cloud.storage": ["py.typed"], + }, install_requires=dependencies, extras_require=extras, python_requires=">=3.7",