Skip to content

ENH add type annotations - #119

Draft
kroq-gar78 wants to merge 37 commits into
mainfrom
frontend-types
Draft

ENH add type annotations#119
kroq-gar78 wants to merge 37 commits into
mainfrom
frontend-types

Conversation

@kroq-gar78

Copy link
Copy Markdown
Collaborator

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

  • Added type annotations for function signatures, variables, and return types for public and private APIs.
  • Added a mypy type checking step to the GitHub Actions workflow in .github/workflows/run_tests.yml, set to continue on error for now.
  • Added # type: ignore comments where necessary to silence type checker warnings for dynamic imports or assignments, and updated docstrings to match new type annotations.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 typed CloudStream.
  • 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 thread cottoncandy/interfaces.py
Comment thread cottoncandy/utils.py
Comment thread cottoncandy/utils.py Outdated
Comment thread cottoncandy/__init__.py
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 thread cottoncandy/s3client.py
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 thread cottoncandy/interfaces.py
Comment thread cottoncandy/backend.py
Comment thread cottoncandy/s3client.py
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'

Comment thread cottoncandy/interfaces.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants