Skip to content
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

[BEAM-5949] Remove trivial __ne__ implementations. #13887

Merged
merged 1 commit into from
Mar 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions sdks/python/apache_beam/coders/coders.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,10 +291,6 @@ def __eq__(self, other):

# pylint: enable=protected-access

def __ne__(self, other):
# TODO(BEAM-5949): Needed for Python 2 compatibility.
return not self == other

def __hash__(self):
return hash(type(self))

Expand Down
4 changes: 0 additions & 4 deletions sdks/python/apache_beam/coders/coders_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,6 @@ def __eq__(self, other):
return True
return False

def __ne__(self, other):
# TODO(BEAM-5949): Needed for Python 2 compatibility.
return not self == other

def __hash__(self):
return hash(type(self))

Expand Down
4 changes: 0 additions & 4 deletions sdks/python/apache_beam/coders/typecoders_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ def __init__(self, n):
def __eq__(self, other):
return self.number == other.number

def __ne__(self, other):
# TODO(BEAM-5949): Needed for Python 2 compatibility.
return not self == other

def __hash__(self):
return self.number

Expand Down
3 changes: 0 additions & 3 deletions sdks/python/apache_beam/dataframe/expressions.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,6 @@ def __hash__(self):
def __eq__(self, other):
return self._id == other._id

def __ne__(self, other):
return not self == other

def __repr__(self):
return '%s[%s]' % (self.__class__.__name__, self._id)

Expand Down
9 changes: 0 additions & 9 deletions sdks/python/apache_beam/dataframe/partitionings.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,6 @@ def __repr__(self):
def __eq__(self, other):
return type(self) == type(other) and self._levels == other._levels

def __ne__(self, other):
return not self == other

def __hash__(self):
if self._levels:
return hash(tuple(sorted(self._levels)))
Expand Down Expand Up @@ -154,9 +151,6 @@ class Singleton(Partitioning):
def __eq__(self, other):
return type(self) == type(other)

def __ne__(self, other):
return not self == other

def __hash__(self):
return hash(type(self))

Expand All @@ -176,9 +170,6 @@ class Arbitrary(Partitioning):
def __eq__(self, other):
return type(self) == type(other)

def __ne__(self, other):
return not self == other

def __hash__(self):
return hash(type(self))

Expand Down
8 changes: 0 additions & 8 deletions sdks/python/apache_beam/internal/metrics/cells.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,6 @@ def __eq__(self, other):
def __hash__(self):
return hash(self.data)

def __ne__(self, other):
# TODO(BEAM-5949): Needed for Python 2 compatibility.
return not self == other

def __repr__(self):
return '<HistogramResult({})>'.format(
self.data.histogram.get_percentile_info())
Expand Down Expand Up @@ -147,10 +143,6 @@ def __eq__(self, other):
def __hash__(self):
return hash(self.histogram)

def __ne__(self, other):
# TODO(BEAM-5949): Needed for Python 2 compatibility.
return not self == other

def __repr__(self):
return 'HistogramData({})'.format(self.histogram.get_percentile_info())

Expand Down
4 changes: 0 additions & 4 deletions sdks/python/apache_beam/internal/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,6 @@ def __eq__(self, other):
"""
return isinstance(other, ArgumentPlaceholder)

def __ne__(self, other):
# TODO(BEAM-5949): Needed for Python 2 compatibility.
return not self == other

def __hash__(self):
return hash(type(self))

Expand Down
4 changes: 0 additions & 4 deletions sdks/python/apache_beam/io/concat_source_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,6 @@ def __eq__(self, other):
type(self) == type(other) and self._start == other._start and
self._end == other._end and self._split_freq == other._split_freq)

def __ne__(self, other):
# TODO(BEAM-5949): Needed for Python 2 compatibility.
return not self == other


class ConcatSourceTest(unittest.TestCase):
def test_range_source(self):
Expand Down
4 changes: 0 additions & 4 deletions sdks/python/apache_beam/io/filebasedsink.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,10 +403,6 @@ def __eq__(self, other):
# pylint: disable=unidiomatic-typecheck
return type(self) == type(other) and self.__dict__ == other.__dict__

def __ne__(self, other):
# TODO(BEAM-5949): Needed for Python 2 compatibility.
return not self == other


class FileBasedSinkWriter(iobase.Writer):
"""The writer for FileBasedSink.
Expand Down
4 changes: 0 additions & 4 deletions sdks/python/apache_beam/io/filesystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -452,10 +452,6 @@ def __eq__(self, other):
def __hash__(self):
return hash((self.path, self.size_in_bytes))

def __ne__(self, other):
# TODO(BEAM-5949): Needed for Python 2 compatibility.
return not self == other

def __repr__(self):
return 'FileMetadata(%s, %s)' % (self.path, self.size_in_bytes)

Expand Down
4 changes: 0 additions & 4 deletions sdks/python/apache_beam/io/gcp/pubsub.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,6 @@ def __eq__(self, other):
return isinstance(other, PubsubMessage) and (
self.data == other.data and self.attributes == other.attributes)

def __ne__(self, other):
# TODO(BEAM-5949): Needed for Python 2 compatibility.
return not self == other

def __repr__(self):
return 'PubsubMessage(%s, %s)' % (self.data, self.attributes)

Expand Down
4 changes: 0 additions & 4 deletions sdks/python/apache_beam/io/hadoopfilesystem_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,6 @@ def __init__(self, path, mode='', type='FILE'):
def __eq__(self, other):
return self.stat == other.stat and self.getvalue() == self.getvalue()

def __ne__(self, other):
# TODO(BEAM-5949): Needed for Python 2 compatibility.
return not self == other

def close(self):
self.saved_data = self.getvalue()
io.BytesIO.close(self)
Expand Down
4 changes: 0 additions & 4 deletions sdks/python/apache_beam/io/restriction_trackers.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,6 @@ def __eq__(self, other):

return self.start == other.start and self.stop == other.stop

def __ne__(self, other):
# TODO(BEAM-5949): Needed for Python 2 compatibility.
return not self == other

def __hash__(self):
return hash((type(self), self.start, self.stop))

Expand Down
20 changes: 0 additions & 20 deletions sdks/python/apache_beam/metrics/cells.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,11 +288,6 @@ def __hash__(self):
# type: () -> int
return hash(self.data)

def __ne__(self, other):
# type: (object) -> bool
# TODO(BEAM-5949): Needed for Python 2 compatibility.
return not self == other

def __repr__(self):
# type: () -> str
return 'DistributionResult(sum={}, count={}, min={}, max={})'.format(
Expand Down Expand Up @@ -347,11 +342,6 @@ def __hash__(self):
# type: () -> int
return hash(self.data)

def __ne__(self, other):
# type: (object) -> bool
# TODO(BEAM-5949): Needed for Python 2 compatibility.
return not self == other

def __repr__(self):
return '<GaugeResult(value={}, timestamp={})>'.format(
self.value, self.timestamp)
Expand Down Expand Up @@ -393,11 +383,6 @@ def __hash__(self):
# type: () -> int
return hash((self.value, self.timestamp))

def __ne__(self, other):
# type: (object) -> bool
# TODO(BEAM-5949): Needed for Python 2 compatibility.
return not self == other

def __repr__(self):
# type: () -> str
return '<GaugeData(value={}, timestamp={})>'.format(
Expand Down Expand Up @@ -459,11 +444,6 @@ def __hash__(self):
# type: () -> int
return hash((self.sum, self.count, self.min, self.max))

def __ne__(self, other):
# type: (object) -> bool
# TODO(BEAM-5949): Needed for Python 2 compatibility.
return not self == other

def __repr__(self):
# type: () -> str
return 'DistributionData(sum={}, count={}, min={}, max={})'.format(
Expand Down
11 changes: 0 additions & 11 deletions sdks/python/apache_beam/metrics/execution.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,6 @@ def __eq__(self, other):
self.step == other.step and self.metric == other.metric and
self.labels == other.labels)

def __ne__(self, other):
# TODO(BEAM-5949): Needed for Python 2 compatibility.
return not self == other

def __hash__(self):
return hash((self.step, self.metric, frozenset(self.labels)))

Expand Down Expand Up @@ -131,10 +127,6 @@ def __eq__(self, other):
self.key == other.key and self.committed == other.committed and
self.attempted == other.attempted)

def __ne__(self, other):
# TODO(BEAM-5949): Needed for Python 2 compatibility.
return not self == other

def __hash__(self):
return hash((self.key, self.committed, self.attempted))

Expand Down Expand Up @@ -195,9 +187,6 @@ def __eq__(self, other):
return self is other or (
self.cell_type == other.cell_type and self.fast_name == other.fast_name)

def __ne__(self, other):
return not self == other

def __hash__(self):
return self._hash

Expand Down
4 changes: 0 additions & 4 deletions sdks/python/apache_beam/metrics/metricbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,6 @@ def __eq__(self, other):
self.namespace == other.namespace and self.name == other.name and
self.urn == other.urn and self.labels == other.labels)

def __ne__(self, other):
# TODO(BEAM-5949): Needed for Python 2 compatibility.
return not self == other

def __str__(self):
if self.urn:
return 'MetricName(namespace={}, name={}, urn={}, labels={})'.format(
Expand Down
4 changes: 0 additions & 4 deletions sdks/python/apache_beam/options/value_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,6 @@ def __eq__(self, other):
return True
return False

def __ne__(self, other):
# TODO(BEAM-5949): Needed for Python 2 compatibility.
return not self == other

def __hash__(self):
return hash((type(self), self.value_type, self.value))

Expand Down
7 changes: 0 additions & 7 deletions sdks/python/apache_beam/pvalue.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,6 @@ def __eq__(self, other):
if isinstance(other, PCollection):
return self.tag == other.tag and self.producer == other.producer

def __ne__(self, other):
# TODO(BEAM-5949): Needed for Python 2 compatibility.
return not self == other

def __hash__(self):
return hash((self.tag, self.producer))

Expand Down Expand Up @@ -679,9 +675,6 @@ def __hash__(self):
def __eq__(self, other):
return type(self) == type(other) and self.__dict__ == other.__dict__

def __ne__(self, other):
return not self == other

def __reduce__(self):
return _make_Row, tuple(sorted(self.__dict__.items()))

Expand Down
8 changes: 0 additions & 8 deletions sdks/python/apache_beam/runners/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,6 @@ def __init__(self, step_name, transform_id=None):
def __eq__(self, other):
return self.step_name == other.step_name

def __ne__(self, other):
# TODO(BEAM-5949): Needed for Python 2 compatibility.
return not self == other

def __repr__(self):
return 'NameContext(%s)' % self.__dict__

Expand Down Expand Up @@ -136,10 +132,6 @@ def __eq__(self, other):
self.user_name == other.user_name and
self.system_name == other.system_name)

def __ne__(self, other):
# TODO(BEAM-5949): Needed for Python 2 compatibility.
return not self == other

def __hash__(self):
return hash((self.step_name, self.user_name, self.system_name))

Expand Down
4 changes: 0 additions & 4 deletions sdks/python/apache_beam/testing/test_stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,6 @@ def __hash__(self):
def __lt__(self, other):
raise NotImplementedError

def __ne__(self, other):
# TODO(BEAM-5949): Needed for Python 2 compatibility.
return not self == other

@abstractmethod
def to_runner_api(self, element_coder):
raise NotImplementedError
Expand Down
4 changes: 0 additions & 4 deletions sdks/python/apache_beam/testing/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,6 @@ def __init__(self, iterable):
def __eq__(self, other):
return self._counter == collections.Counter(other)

def __ne__(self, other):
# TODO(BEAM-5949): Needed for Python 2 compatibility.
return not self == other

def __hash__(self):
return hash(self._counter)

Expand Down
8 changes: 0 additions & 8 deletions sdks/python/apache_beam/transforms/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -448,10 +448,6 @@ def __eq__(self, other):
return self.param_id == other.param_id
return False

def __ne__(self, other):
# TODO(BEAM-5949): Needed for Python 2 compatibility.
return not self == other

def __hash__(self):
return hash(self.param_id)

Expand Down Expand Up @@ -2697,10 +2693,6 @@ def __eq__(self, other):
self.environment_id == self.environment_id)
return False

def __ne__(self, other):
# TODO(BEAM-5949): Needed for Python 2 compatibility.
return not self == other

def __hash__(self):
return hash((
self.windowfn,
Expand Down
4 changes: 0 additions & 4 deletions sdks/python/apache_beam/transforms/cy_combiners.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,6 @@ def __eq__(self, other):
isinstance(other, AccumulatorCombineFn) and
self._accumulator_type is other._accumulator_type)

def __ne__(self, other):
# TODO(BEAM-5949): Needed for Python 2 compatibility.
return not self == other

def __hash__(self):
return hash(self._accumulator_type)

Expand Down
4 changes: 0 additions & 4 deletions sdks/python/apache_beam/transforms/display.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,10 +321,6 @@ def __eq__(self, other):
return self._get_dict() == other._get_dict()
return False

def __ne__(self, other):
# TODO(BEAM-5949): Needed for Python 2 compatibility.
return not self == other

def __hash__(self):
return hash(tuple(sorted(self._get_dict().items())))

Expand Down
Loading