-
Notifications
You must be signed in to change notification settings - Fork 339
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
base: master
Are you sure you want to change the base?
Conversation
@jamesdaniels @lahirumaramba |
This feature requires PR #713 to be approved before linters can take advantage of it. |
In this class, the methods assume that client will never be None. Can you help me here? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your contribution! We understand that this is an important addition to the the codebase, but as this was not something we had prioritized in the current roadmap the review process will take some time to complete.
I have added a comment to start the process. Do you have any objections to change the import statements to specific items over importing the entire typings module?
@@ -17,23 +17,31 @@ | |||
import json | |||
import os | |||
import threading | |||
import typing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason to import the entire module here over importing specific items as needed?
from typing import Any, Callable, List, Optional, Tuple, Coroutine
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I handled it by considering the use of a star import and not defining __all__
.
When this type of import is used, it brings in all symbols from the module that do not start with _, including those that were imported.
However, if __all__
is defined, only the names listed there will be imported.
This also helps separate what is used for type hints from what is accessed at runtime.
That said, it ultimately depends on the preferences of other contributors whether they favor explicit names during import or during use.
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
Tools
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.