-
Notifications
You must be signed in to change notification settings - Fork 36
refactor: type hints private interface #389
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
refactor: type hints private interface #389
Conversation
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.
please address.
blocking_timeout: Optional[int] = None, | ||
url: Optional[str] = None, | ||
url_template: Optional[str] = None, | ||
logger: Optional[optimizely_logger.Logger] = None, |
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 am not sure, is the type in the past we were expecting?
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.
This is just a type alias for the union of the python standard library logging.Logger
and our BaseLogger
.
variables: Optional[dict[str, Any]] = None, | ||
rule_key: Optional[str] = None, | ||
flag_key: Optional[str] = None, | ||
user_context: Optional[OptimizelyUserContext] = None, |
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.
this shouldn't be NULL.
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.
The only problem with removing the user_context
default None
, is that we can't have a non default argument after default arguments. So to remove the user_context
default, we would need to make user_context
the first parameter or remove all preceding defaults, which would both be breaking changes.
@@ -16,21 +16,21 @@ | |||
|
|||
https://pypi.python.org/pypi/mmh3/2.3.1 | |||
''' | |||
from __future__ import annotations |
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 am leaving this file unreviewed.
@@ -624,7 +629,7 @@ def get_variation( | |||
|
|||
return variation_key | |||
|
|||
def is_feature_enabled(self, feature_key: str, user_id: str, attributes: Optional[dict[str, Any]] = None) -> bool: | |||
def is_feature_enabled(self, feature_key: str, user_id: str, attributes: Optional[UserAttributes] = None) -> bool: |
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.
Can you please confirm, this won't break any code change.
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.
This is essentially a no-op wrapper, that gives it a name for the type checker to track. But at runtime the behavior is unchanged.
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.
lgtm
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.
Looks good to me. Hope I didn't miss anything, I went through most of it before.
Summary