GeezerVison is showing github.com — fix: Return False from __eq__ on cross-type comparison by larrysingleton007 · Pull Request #6637 · feast-dev/feast
fix: Return False from __eq__ on cross-type comparison
#6637
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
Uh oh!
There was an error while loading. Please reload this page.
Show file tree
Hide file tree
Changes from all commits
Commits
File filter
Filter by extension
.py
(37)
All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Hide whitespace
Diff view
Hide whitespace
There are no files selected for viewing
Original file line number
Diff line number
Diff line change
Expand Up
@@ -90,7 +90,7 @@ def from_proto(cls, agg_proto: AggregationProto):
def __eq__(self, other):
if not isinstance(other, Aggregation):
raise TypeError("Comparisons should only involve Aggregations.")
return False
if (
self.column != other.column
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -172,9 +172,7 @@ def _schema_or_udf_changed(self, other: "BaseFeatureView") -> bool:
def __eq__(self, other):
if not isinstance(other, BaseFeatureView):
raise TypeError(
"Comparisons should only involve BaseFeatureView class objects."
)
return False
if (
self.name != other.name
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -33,6 +33,8 @@ def to_proto(self):
pass
def __eq__(self, other):
if not isinstance(other, FileFormat):
return False
return self.to_proto() == other.to_proto()
@classmethod
Expand Down
Expand Up
@@ -95,6 +97,8 @@ def to_proto(self):
pass
def __eq__(self, other):
if not isinstance(other, StreamFormat):
return False
return self.to_proto() == other.to_proto()
@classmethod
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -279,7 +279,7 @@ def __eq__(self, other):
return False
if not isinstance(other, DataSource):
raise TypeError("Comparisons should only involve DataSource class objects.")
return False
if (
self.name != other.name
Expand Down
Expand Up
@@ -499,9 +499,7 @@ def __init__(
def __eq__(self, other):
if not isinstance(other, KafkaSource):
raise TypeError(
"Comparisons should only involve KafkaSource class objects."
)
return False
if not super().__eq__(other):
return False
Expand Down
Expand Up
@@ -639,9 +637,7 @@ def get_table_column_names_and_types(
def __eq__(self, other):
if not isinstance(other, RequestSource):
raise TypeError(
"Comparisons should only involve RequestSource class objects."
)
return False
if not super().__eq__(other):
return False
Expand Down
Expand Up
@@ -801,9 +797,7 @@ def __init__(
def __eq__(self, other):
if not isinstance(other, KinesisSource):
raise TypeError(
"Comparisons should only involve KinesisSource class objects."
)
return False
if not super().__eq__(other):
return False
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -126,7 +126,7 @@ def __hash__(self) -> int:
def __eq__(self, other):
if not isinstance(other, Entity):
raise TypeError("Comparisons should only involve Entity class objects.")
return False
if (
self.name != other.name
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -50,6 +50,8 @@ def __init__(
self._labels = labels
def __eq__(self, other):
if not isinstance(other, Feature):
return False
if self.name != other.name or self.dtype != other.dtype:
return False
return True
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -293,9 +293,7 @@ def __hash__(self):
def __eq__(self, other):
if not isinstance(other, FeatureService):
raise TypeError(
"Comparisons should only involve FeatureService class objects."
)
return False
if (
self.name != other.name
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -395,9 +395,7 @@ def _schema_or_udf_changed(self, other: "BaseFeatureView") -> bool:
def __eq__(self, other):
if not isinstance(other, FeatureView):
raise TypeError(
"Comparisons should only involve FeatureView class objects."
)
return False
if not super().__eq__(other):
return False
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -97,9 +97,7 @@ def __hash__(self):
def __eq__(self, other):
if not isinstance(other, BigQuerySource):
raise TypeError(
"Comparisons should only involve BigQuerySource class objects."
)
return False
return (
super().__eq__(other)
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -115,9 +115,7 @@ def __hash__(self):
def __eq__(self, other):
if not isinstance(other, AthenaSource):
raise TypeError(
"Comparisons should only involve AthenaSource class objects."
)
return False
return (
super().__eq__(other)
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -93,9 +93,7 @@ def __hash__(self):
def __eq__(self, other):
if not isinstance(other, CouchbaseColumnarSource):
raise TypeError(
"Comparisons should only involve CouchbaseColumnarSource class objects."
)
return False
return (
super().__eq__(other)
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -170,9 +170,7 @@ def __init__(
def __eq__(self, other):
if not isinstance(other, MsSqlServerSource):
raise TypeError(
"Comparisons should only involve SqlServerSource class objects."
)
return False
return (
self.name == other.name
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -105,9 +105,7 @@ def __init__(
def __eq__(self, other):
if not isinstance(other, OracleSource):
raise TypeError(
"Comparisons should only involve OracleSource class objects."
)
return False
return (
self.name == other.name
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -77,9 +77,7 @@ def __hash__(self):
def __eq__(self, other):
if not isinstance(other, PostgreSQLSource):
raise TypeError(
"Comparisons should only involve PostgreSQLSource class objects."
)
return False
return (
super().__eq__(other)
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -228,7 +228,7 @@ def get_table_query_string(self) -> str:
def __eq__(self, other):
if not isinstance(other, RaySource):
raise TypeError("Comparisons should only involve RaySource class objects.")
return False
base_eq = super().__eq__(other)
if not base_eq:
return False
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -262,8 +262,13 @@ def _load_dataframe_from_path(self, spark_session):
return reader.load(self.path)
def __eq__(self, other):
base_eq = super().__eq__(other)
if not base_eq:
# Guard before the spark-specific attribute access below: the base
# DataSource.__eq__ accepts any DataSource subclass, so a cross-type
# comparison (e.g. against a FileSource with a matching name) would
# otherwise raise AttributeError on `other.table` (#6636).
if not isinstance(other, SparkSource):
return False
if not super().__eq__(other):
return False
return (
self.table == other.table
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -146,9 +146,7 @@ def __hash__(self):
def __eq__(self, other):
if not isinstance(other, TrinoSource):
raise TypeError(
"Comparisons should only involve TrinoSource class objects."
)
return False
return (
super().__eq__(other)
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -97,7 +97,7 @@ def __hash__(self):
def __eq__(self, other):
if not isinstance(other, FileSource):
raise TypeError("Comparisons should only involve FileSource class objects.")
return False
return (
super().__eq__(other)
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -123,9 +123,7 @@ def __hash__(self):
def __eq__(self, other):
if not isinstance(other, RedshiftSource):
raise TypeError(
"Comparisons should only involve RedshiftSource class objects."
)
return False
return (
super().__eq__(other)
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -132,9 +132,7 @@ def __hash__(self):
def __eq__(self, other):
if not isinstance(other, SnowflakeSource):
raise TypeError(
"Comparisons should only involve SnowflakeSource class objects."
)
return False
return (
super().__eq__(other)
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -221,7 +221,7 @@ def __copy__(self):
def __eq__(self, other):
if not isinstance(other, LabelView):
raise TypeError("Comparisons should only involve LabelView class objects.")
return False
if not super().__eq__(other):
return False
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -459,9 +459,7 @@ def _schema_or_udf_changed(self, other: "BaseFeatureView") -> bool:
def __eq__(self, other):
if not isinstance(other, OnDemandFeatureView):
raise TypeError(
"Comparisons should only involve OnDemandFeatureView class objects."
)
return False
# Note, no longer evaluating the base feature view layer as ODFVs can have
# multiple datasources and a base_feature_view only has one source
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -84,7 +84,7 @@ def __init__(
def __eq__(self, other):
if not isinstance(other, Permission):
raise TypeError("Comparisons should only involve Permission class objects.")
return False
if (
self.name != other.name
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -80,9 +80,7 @@ def __init__(
def __eq__(self, other):
if not isinstance(other, RoleBasedPolicy):
raise TypeError(
"Comparisons should only involve RoleBasedPolicy class objects."
)
return False
if sorted(self.roles) != sorted(other.roles):
return False
Expand Down
Expand Up
@@ -148,9 +146,7 @@ def __init__(
def __eq__(self, other):
if not isinstance(other, GroupBasedPolicy):
raise TypeError(
"Comparisons should only involve GroupBasedPolicy class objects."
)
return False
if sorted(self.groups) != sorted(other.groups):
return False
Expand Down
Expand Up
@@ -206,9 +202,7 @@ def __init__(
def __eq__(self, other):
if not isinstance(other, NamespaceBasedPolicy):
raise TypeError(
"Comparisons should only involve NamespaceBasedPolicy class objects."
)
return False
if sorted(self.namespaces) != sorted(other.namespaces):
return False
Expand Down
Expand Up
@@ -270,9 +264,7 @@ def __init__(
def __eq__(self, other):
if not isinstance(other, CombinedGroupNamespacePolicy):
raise TypeError(
"Comparisons should only involve CombinedGroupNamespacePolicy class objects."
)
return False
if sorted(self.groups) != sorted(other.groups) or sorted(
self.namespaces
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -82,7 +82,7 @@ def __hash__(self) -> int:
def __eq__(self, other):
if not isinstance(other, Project):
raise TypeError("Comparisons should only involve Project class objects.")
return False
if (
self.name != other.name
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -60,9 +60,7 @@ def __hash__(self) -> int:
def __eq__(self, other):
if not isinstance(other, ProjectMetadata):
raise TypeError(
"Comparisons should only involve ProjectMetadata class objects."
)
return False
if (
self.project_name != other.project_name
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -133,9 +133,7 @@ def __hash__(self):
def __eq__(self, other):
if not isinstance(other, SavedDataset):
raise TypeError(
"Comparisons should only involve SavedDataset class objects."
)
return False
if (
self.name != other.name
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -248,7 +248,7 @@ def _schema_or_udf_changed(self, other: "BaseFeatureView") -> bool:
def __eq__(self, other):
if not isinstance(other, StreamFeatureView):
raise TypeError("Comparisons should only involve StreamFeatureViews")
return False
if not super().__eq__(other):
return False
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -132,9 +132,7 @@ def infer_features(
def __eq__(self, other):
if not isinstance(other, PandasTransformation):
raise TypeError(
"Comparisons should only involve PandasTransformation class objects."
)
return False
if (
self.udf_string != other.udf_string
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -143,9 +143,7 @@ def infer_features(
def __eq__(self, other):
if not isinstance(other, PythonTransformation):
raise TypeError(
"Comparisons should only involve PythonTransformation class objects."
)
return False
if (
self.udf_string != other.udf_string
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -270,9 +270,7 @@ def infer_features(
def __eq__(self, other):
if not isinstance(other, RayTransformation):
raise TypeError(
"Comparisons should only involve RayTransformation class objects."
)
return False
if (
self.udf_string != other.udf_string
Expand Down
Loading
Oops, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Loading
Oops, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.