-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
tensorflow
: Add (and rename) aliases
#11324
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
Conversation
a9395ed
to
deb8ec7
Compare
This comment has been minimized.
This comment has been minimized.
af9b2cb
to
4e4c6a4
Compare
This comment has been minimized.
This comment has been minimized.
ce8f46f
to
481f035
Compare
This comment has been minimized.
This comment has been minimized.
481f035
to
bf619d6
Compare
bf619d6
to
7cf876d
Compare
This comment has been minimized.
This comment has been minimized.
@hmc-cs-mdrissi Should the type aliases declared in |
tensorflow
: Add (and rename) aliases
Yup. The convention is anything in _aliases.py is type checking only and has no equivalent at runtime. Partly motivated by that flake8 rule so no need to have underscore start in alias name. |
|
||
class _KerasSerializable1(Protocol): | ||
def get_config(self) -> dict[str, Any]: ... | ||
|
||
class _KerasSerializable2(Protocol): | ||
__name__: str | ||
|
||
KerasSerializable: TypeAlias = _KerasSerializable1 | _KerasSerializable2 | ||
_KerasSerializable: TypeAlias = _KerasSerializable1 | _KerasSerializable2 |
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 think since you've unified aliases to all live here consistently they can all lose underscore prefix.
Except for that the PR looks good to me.
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.
Done in c7d65fd
ce8b30e
to
f22350f
Compare
This comment has been minimized.
This comment has been minimized.
f22350f
to
785e666
Compare
This comment has been minimized.
This comment has been minimized.
785e666
to
c7d65fd
Compare
This comment has been minimized.
This comment has been minimized.
This looks good but I suspect it conflicts with some of the other PRs I just merged, so I updated the branch and might push some changes to the branch to get it to pass. |
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
This PR adds aliases (taken from here) so that they can be used in the future. It also renames aliases that do not have a runtime equivalent (by adding an
_
).@hmc-cs-mdrissi The previous PR keeps getting bigger because
tf.keras.Model
relies on many other types, so I will make smaller PRs adding those types before addingtf.keras.Model
.