Skip to content

Update support for type hints #886

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

ViktorSky
Copy link

This pull request introduces comprehensive type annotations to the firebase_admin codebase using PEP 484 standards. All changes have been validated with Pyright in strict mode to enforce consistency and catch potential type errors early.

Goals

  • Enhance developer experience with precise autocomplete and type hints.
  • Catch type-related bugs upfront via static analysis.

Tools

  • Pyright in strict mode for robust type-checking.
  • Manual review of ambiguous or potentially problematic sections.

Configuration Additions

  • pyrightconfig.json: config file created to declare strict-mode settings.

  • firebase_admin/_typing.py: A new central module that defines all custom type aliases, TypedDicts, and Protocols. By consolidating these shared types in one place, we simplify extension and reuse across the package and avoid circular-import issues.

@ViktorSky ViktorSky mentioned this pull request Jun 5, 2025
@ViktorSky
Copy link
Author

@jamesdaniels @lahirumaramba
Could someone please assign a reviewer to this PR? The previous one was completely ignored, and I closed it because it conflicted with the new Firebase version.

@ViktorSky
Copy link
Author

This feature requires PR #713 to be approved before linters can take advantage of it.

@lahirumaramba lahirumaramba self-requested a review June 10, 2025 15:46
@lahirumaramba lahirumaramba self-assigned this Jun 10, 2025
- TypeError: 'ABCMeta' object is not subscriptable
- AttributeError: partially initialized module 'firebase_admin._user_mgt' has no attribute 'UserMetadata' (most likely due to a circular import)
- db.Reference signature
- TypeError: 'ABCMeta' object is not subscriptable
- AttributeError: partially initialized module 'firebase_admin._user_mgt' has no attribute 'UserMetadata' (most likely due to a circular import)
- db.Reference signature
@ViktorSky
Copy link
Author

ViktorSky commented Jun 10, 2025

tests/test_db.py:907 creates a firebase_admin.db.Reference instance without client.

In this class, the methods assume that client will never be None.

Can you help me here?
Should I add a line that creates an instance when it's None? Or should I add validations in each part where it's referenced?

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