Repository: sdispater/pendulum

Issue:
Period inequality does not work as expected
- [x] I am on the [latest](https://github.com/sdispater/pendulum/releases/latest) Pendulum version.
- [x] I have searched the [issues](https://github.com/sdispater/pendulum/issues) of this repo and believe that this is not a duplicate.

- **OS version and name**: WSL2 on Win10, Ubuntu-20.04, Python 3.9.13
- **Pendulum version**: 2.1.2

## Issue

Only equality (`_eq` method) is defined for `Period`.
However, when testing for inequality, the results are not consistent with $A \neq B \Leftrightarrow \neg (A = B)$.
```py
>>> # Initialization
>>> import pendulum
>>> dt0 = pendulum.datetime(2000,1,1, 0)
>>> dt1 = pendulum.datetime(2000,1,1, 1)
>>> dt2 = pendulum.datetime(2000,1,1, 2)
>>> p1 = dt1 - dt0
>>> p2 = dt2 - dt1
>>> p1 == p1, p2 == p2
(True, True)
>>> # ^ This is expected and correct
>>> p1 == p2, p2 == p1
(False, False)
>>> # ^ This is also expected and correct
>>> p1 != p2, p2 != p1
(False, False)
>>> # ^ This is unexpected and incorrect, should be (True, True)
```

I believe the same issue applies to the new `Interval`.

Discussion:
codspeed-hq[bot]: ## [CodSpeed Performance Report](https://codspeed.io/sdispater/pendulum/branches/fix/period-interval-inequality)

### Merging #726 will **improve performances by 14.02%**

<sub>Comparing <code>fix/period-interval-inequality</code> (5517a45) with <code>master</code> (377dc2f)</sub>



### Summary

`🔥 1` improvements
`✅ 1` untouched benchmarks




### Benchmarks breakdown

|     | Benchmark | `master` | `fix/period-interval-inequality` | Change |
| --- | --------- | ----------------------- | ------------------- | ------ |
| 🔥 | `test_format` | 2.8 ms | 2.5 ms | +14.02% |


Patch:
diff --git a/pendulum/interval.py b/pendulum/interval.py
index 0c77305..2721494 100644
--- a/pendulum/interval.py
+++ b/pendulum/interval.py
@@ -448,3 +448,6 @@ class Interval(Duration):
             )
         else:
             return self.as_duration() == other
+
+    def __ne__(self, other: object) -> bool:
+        return not self.__eq__(other)


Test patch:
diff --git a/tests/interval/test_behavior.py b/tests/interval/test_behavior.py
index b5e057a..29636bd 100644
--- a/tests/interval/test_behavior.py
+++ b/tests/interval/test_behavior.py
@@ -52,3 +52,16 @@ def test_equality_to_timedelta():
     period = dt2 - dt1
 
     assert period == timedelta(days=2)
+
+
+def test_inequality():
+    dt1 = pendulum.datetime(2016, 11, 18)
+    dt2 = pendulum.datetime(2016, 11, 20)
+    dt3 = pendulum.datetime(2016, 11, 22)
+
+    period1 = dt2 - dt1
+    period2 = dt3 - dt2
+    period3 = dt3 - dt1
+
+    assert period1 != period2
+    assert period1 != period3