Skip to content

fix: improve type hints in __init__.py#53

Merged
sachaservan merged 1 commit intotinfoilsh:mainfrom
kalenmcmillan:fix/improve-type-hints
Dec 16, 2025
Merged

fix: improve type hints in __init__.py#53
sachaservan merged 1 commit intotinfoilsh:mainfrom
kalenmcmillan:fix/improve-type-hints

Conversation

@kalenmcmillan
Copy link

@kalenmcmillan kalenmcmillan commented Nov 20, 2025

Summary
Improves type hints in src/tinfoil/__init__.py for better type safety, IDE support, and consistency with the rest of the codebase. Replaces incorrect dict = None and int = None patterns with Optional[dict] and Optional[int], and adds missing return type annotations.

Changes

  • Add Optional import from typing and httpx import for return type annotations.
  • Fix parameter type hints in TinfoilAI, AsyncTinfoilAI, and NewSecureClient constructors: change measurement: dict = None to measurement: Optional[dict] = None.
  • Fix parameter type hints in _HTTPSecureClient.get() and post() methods: change headers: dict = None, params: dict = None, data: dict = None, json: dict = None, and timeout: int = None to use Optional[...].
  • Add missing type hint for tf_client parameter in _HTTPSecureClient.__init__(): specify tf_client: SecureClient.
  • Add return type annotations for get() and post() methods: both now return -> httpx.Response.

Summary by cubic

Improves type hints in src/tinfoil/init.py to use Optional for nullable params and adds return types for HTTP methods. This tightens type safety and improves IDE support.

  • Refactors
    • Replace dict/int defaults set to None with Optional[...] across constructors and _HTTPSecureClient methods.
    • Add tf_client: SecureClient in _HTTPSecureClient.init and annotate get/post to return httpx.Response.
    • Add imports: Optional (typing) and httpx.

Written for commit 1627629. Summary will update automatically on new commits.

- Replace dict = None with Optional[dict] = None for proper type safety
- Add Optional[int] = None for timeout parameters
- Add missing type hint for tf_client parameter (SecureClient)
- Add return type annotations (httpx.Response) for get() and post() methods
- Add necessary imports (Optional from typing, httpx)

This improves IDE support, type checking, and consistency with the rest of the codebase.
Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

No issues found across 1 file

@sachaservan
Copy link
Member

@kalenmcmillan just got a chance to look at this. Thanks for your contributions.

@sachaservan sachaservan merged commit 987e3aa into tinfoilsh:main Dec 16, 2025
2 checks passed
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