Skip to content

Commit

Permalink
Fix typing.cast when subclassing (#20149)
Browse files Browse the repository at this point in the history
  • Loading branch information
james77777778 authored Aug 22, 2024
1 parent befa049 commit f4a4725
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion keras/src/models/functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class Functional(Function, Model):
"""

def __new__(cls, *args, **kwargs):
return typing.cast(Functional, super().__new__(cls))
return typing.cast(cls, super().__new__(cls))

@tracking.no_automatic_dependency_tracking
def __init__(self, inputs, outputs, name=None, **kwargs):
Expand Down
2 changes: 1 addition & 1 deletion keras/src/models/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def __new__(cls, *args, **kwargs):
from keras.src.models.functional import Functional

return Functional.__new__(Functional, *args, **kwargs)
return typing.cast(Model, super().__new__(cls))
return typing.cast(cls, super().__new__(cls))

def __init__(self, *args, **kwargs):
Trainer.__init__(self)
Expand Down
2 changes: 1 addition & 1 deletion keras/src/models/sequential.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class Sequential(Model):
"""

def __new__(cls, *args, **kwargs):
return typing.cast(Sequential, super().__new__(cls))
return typing.cast(cls, super().__new__(cls))

def __init__(self, layers=None, trainable=True, name=None):
super().__init__(trainable=trainable, name=name)
Expand Down

0 comments on commit f4a4725

Please sign in to comment.