Skip to content

Commit

Permalink
[BEAM-5949] Remove trivial __ne__ implementations.
Browse files Browse the repository at this point in the history
  • Loading branch information
tvalentyn committed Feb 3, 2021
1 parent eb733a4 commit 9bc1cba
Show file tree
Hide file tree
Showing 34 changed files with 0 additions and 241 deletions.
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 @@ -292,10 +292,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 @@ -167,10 +167,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 @@ -37,10 +37,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 @@ -163,9 +163,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 @@ -82,9 +82,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 @@ -142,9 +139,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 @@ -164,9 +158,6 @@ class Nothing(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
8 changes: 0 additions & 8 deletions sdks/python/apache_beam/io/vcfio.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,6 @@ def __init__(
def __eq__(self, other):
return isinstance(other, Variant) and vars(self) == vars(other)

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

def __repr__(self):
return ', '.join([
str(s) for s in [
Expand Down Expand Up @@ -238,10 +234,6 @@ def __eq__(self, other):
return ((self.name, self.genotype, self.phaseset, self.info) == (
other.name, other.genotype, other.phaseset, other.info))

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

def __repr__(self):
return ', '.join(
[str(s) for s in [self.name, self.genotype, self.phaseset, self.info]])
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 @@ -286,11 +286,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 @@ -345,11 +340,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 @@ -391,11 +381,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 @@ -457,11 +442,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 @@ -86,10 +86,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 @@ -129,10 +125,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 @@ -193,9 +185,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 @@ -151,10 +151,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 @@ -677,9 +673,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 @@ -91,10 +91,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 @@ -134,10 +130,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 @@ -2683,10 +2679,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
Loading

0 comments on commit 9bc1cba

Please sign in to comment.