ENH add type annotations - #119
Draft
kroq-gar78 wants to merge 37 commits into
Draft
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR raises type-safety across cottoncandy by adding/refining type annotations, introducing py.typed packaging metadata, and wiring mypy into CI (non-blocking for now).
Changes:
- Adds/updates type annotations across backends (
S3Client,LocalClient,GDriveClient) and interfaces, including a typedCloudStream. - Updates packaging/config to support typing (
requires-python>=3.9,py.typed, mypy config) and adds a mypy CI step. - Minor test typing refinements (e.g.,
Literal['C','F']in generators).
Reviewed changes
Copilot reviewed 14 out of 15 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
pyproject.toml |
Bumps minimum Python version, adds mypy config and typing marker packaging. |
cottoncandy/utils.py |
Adds typing and refactors GzipInputStream to be more explicitly file-like. |
cottoncandy/s3client.py |
Adds typing, introduces bucket_name property, and tightens upload argument types. |
cottoncandy/localclient.py |
Adds typing and aligns backend API surface (bucket_name, return types). |
cottoncandy/interfaces.py |
Broad typing pass, adds TypedDict metadata, tweaks recursive dict upload/download behavior. |
cottoncandy/backend.py |
Introduces CloudStream as a typed NamedTuple and adds abstract bucket_name. |
cottoncandy/gdriveclient.py |
Adds typing ignores for IPython import variants; adds bucket_name property typing surface. |
cottoncandy/browser.py |
Adds mypy suppression for __dir__ redefinition. |
cottoncandy/__init__.py |
Adds typing and exports DefaultInterface. |
cottoncandy/tests/* |
Adds Literal typing to test content generators. |
.github/workflows/run_tests.yml |
Adds non-blocking mypy step in CI. |
cottoncandy/py.typed |
Marks package as typed for downstream type checkers. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+10
to
12
| from .browser import BrowserObject | ||
| from .interfaces import DefaultInterface | ||
| from .utils import get_keys, string2bool |
Comment on lines
232
to
+233
| auto_makedirs(destination) | ||
| return shutil.copy(source, destination) | ||
| shutil.copy(source, destination) |
Comment on lines
384
to
403
| @@ -389,6 +399,7 @@ def upload_file(self, file_name, cloud_name=None, permissions=DEFAULT_ACL, threa | |||
| response : boto3 response | |||
| """ | |||
| assert os.path.exists(file_name) | |||
| assert permissions is not None, 'Permissions must be specified for S3 uploads' | |||
| if cloud_name is None: | |||
Comment on lines
338
to
+352
| @@ -340,29 +348,31 @@ def upload_stream(self, stream, cloud_name, metadata, permissions, threads): | |||
| ------- | |||
|
|
|||
| """ | |||
| assert permissions is not None, 'Permissions must be specified for S3 uploads' | |||
|
|
|||
kroq-gar78
force-pushed
the
frontend-types
branch
from
April 22, 2026 09:33
f6a70c6 to
b24cb56
Compare
Fix decorator to pass through return type
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
kroq-gar78
force-pushed
the
frontend-types
branch
from
May 21, 2026 21:18
b24cb56 to
db9e0ef
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
(From #114)
This pull request improves type safety and code clarity across the codebase by adding or refining type annotations, using more precise types, and making some small API documentation updates.
.github/workflows/run_tests.yml, set to continue on error for now.# type: ignorecomments where necessary to silence type checker warnings for dynamic imports or assignments, and updated docstrings to match new type annotations.