We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Bug with union in disjoint_set
https://github.com/TheAlgorithms/Python/blob/master/data_structures/disjoint_set/disjoint_set.py
```python
def union_set(x, y):
    """
    union two sets.
    set with bigger rank should be parent, so that the
    disjoint set tree will be more flat.
    """
    x, y = find_set(x), find_set(y)
    if x.rank > y.rank:
        y.parent = x
    else:
        x.parent = y
        if x.rank == y.rank:
            y.rank += 1
```

here need check if x==y

Bug with union in disjoint_set
https://github.com/TheAlgorithms/Python/blob/master/data_structures/disjoint_set/disjoint_set.py
```python
def union_set(x, y):
    """
    union two sets.
    set with bigger rank should be parent, so that the
    disjoint set tree will be more flat.
    """
    x, y = find_set(x), find_set(y)
    if x.rank > y.rank:
        y.parent = x
    else:
        x.parent = y
        if x.rank == y.rank:
            y.rank += 1
```

here need check if x==y


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `data_structures/disjoint_set/disjoint_set.py`
Content:
```
1 """
2     disjoint set
3     Reference: https://en.wikipedia.org/wiki/Disjoint-set_data_structure
4 """
5 
6 
7 class Node:
8     def __init__(self, data):
9         self.data = data
10 
11 
12 def make_set(x):
13     """
14     make x as a set.
15     """
16     # rank is the distance from x to its' parent
17     # root's rank is 0
18     x.rank = 0
19     x.parent = x
20 
21 
22 def union_set(x, y):
23     """
24     union two sets.
25     set with bigger rank should be parent, so that the
26     disjoint set tree will be more flat.
27     """
28     x, y = find_set(x), find_set(y)
29     if x.rank > y.rank:
30         y.parent = x
31     else:
32         x.parent = y
33         if x.rank == y.rank:
34             y.rank += 1
35 
36 
37 def find_set(x):
38     """
39     return the parent of x
40     """
41     if x != x.parent:
42         x.parent = find_set(x.parent)
43     return x.parent
44 
45 
46 def find_python_set(node: Node) -> set:
47     """
48     Return a Python Standard Library set that contains i.
49     """
50     sets = ({0, 1, 2}, {3, 4, 5})
51     for s in sets:
52         if node.data in s:
53             return s
54     raise ValueError(f"{node.data} is not in {sets}")
55 
56 
57 def test_disjoint_set():
58     """
59     >>> test_disjoint_set()
60     """
61     vertex = [Node(i) for i in range(6)]
62     for v in vertex:
63         make_set(v)
64 
65     union_set(vertex[0], vertex[1])
66     union_set(vertex[1], vertex[2])
67     union_set(vertex[3], vertex[4])
68     union_set(vertex[3], vertex[5])
69 
70     for node0 in vertex:
71         for node1 in vertex:
72             if find_python_set(node0).isdisjoint(find_python_set(node1)):
73                 assert find_set(node0) != find_set(node1)
74             else:
75                 assert find_set(node0) == find_set(node1)
76 
77 
78 if __name__ == "__main__":
79     test_disjoint_set()
80
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/data_structures/disjoint_set/disjoint_set.py b/data_structures/disjoint_set/disjoint_set.py
--- a/data_structures/disjoint_set/disjoint_set.py
+++ b/data_structures/disjoint_set/disjoint_set.py
@@ -26,7 +26,10 @@
     disjoint set tree will be more flat.
     """
     x, y = find_set(x), find_set(y)
-    if x.rank > y.rank:
+    if x == y:
+        return
+
+    elif x.rank > y.rank:
         y.parent = x
     else:
         x.parent = y

{"golden_diff": "diff --git a/data_structures/disjoint_set/disjoint_set.py b/data_structures/disjoint_set/disjoint_set.py\n--- a/data_structures/disjoint_set/disjoint_set.py\n+++ b/data_structures/disjoint_set/disjoint_set.py\n@@ -26,7 +26,10 @@\n     disjoint set tree will be more flat.\r\n     \"\"\"\r\n     x, y = find_set(x), find_set(y)\r\n-    if x.rank > y.rank:\r\n+    if x == y:\r\n+        return\r\n+\r\n+    elif x.rank > y.rank:\r\n         y.parent = x\r\n     else:\r\n         x.parent = y\n", "issue": "Bug with union in disjoint_set\nhttps://github.com/TheAlgorithms/Python/blob/master/data_structures/disjoint_set/disjoint_set.py\r\n```python\r\ndef union_set(x, y):\r\n    \"\"\"\r\n    union two sets.\r\n    set with bigger rank should be parent, so that the\r\n    disjoint set tree will be more flat.\r\n    \"\"\"\r\n    x, y = find_set(x), find_set(y)\r\n    if x.rank > y.rank:\r\n        y.parent = x\r\n    else:\r\n        x.parent = y\r\n        if x.rank == y.rank:\r\n            y.rank += 1\r\n```\r\n\r\nhere need check if x==y\r\n\nBug with union in disjoint_set\nhttps://github.com/TheAlgorithms/Python/blob/master/data_structures/disjoint_set/disjoint_set.py\r\n```python\r\ndef union_set(x, y):\r\n    \"\"\"\r\n    union two sets.\r\n    set with bigger rank should be parent, so that the\r\n    disjoint set tree will be more flat.\r\n    \"\"\"\r\n    x, y = find_set(x), find_set(y)\r\n    if x.rank > y.rank:\r\n        y.parent = x\r\n    else:\r\n        x.parent = y\r\n        if x.rank == y.rank:\r\n            y.rank += 1\r\n```\r\n\r\nhere need check if x==y\r\n\n", "before_files": [{"content": "\"\"\"\r\n    disjoint set\r\n    Reference: https://en.wikipedia.org/wiki/Disjoint-set_data_structure\r\n\"\"\"\r\n\r\n\r\nclass Node:\r\n    def __init__(self, data):\r\n        self.data = data\r\n\r\n\r\ndef make_set(x):\r\n    \"\"\"\r\n    make x as a set.\r\n    \"\"\"\r\n    # rank is the distance from x to its' parent\r\n    # root's rank is 0\r\n    x.rank = 0\r\n    x.parent = x\r\n\r\n\r\ndef union_set(x, y):\r\n    \"\"\"\r\n    union two sets.\r\n    set with bigger rank should be parent, so that the\r\n    disjoint set tree will be more flat.\r\n    \"\"\"\r\n    x, y = find_set(x), find_set(y)\r\n    if x.rank > y.rank:\r\n        y.parent = x\r\n    else:\r\n        x.parent = y\r\n        if x.rank == y.rank:\r\n            y.rank += 1\r\n\r\n\r\ndef find_set(x):\r\n    \"\"\"\r\n    return the parent of x\r\n    \"\"\"\r\n    if x != x.parent:\r\n        x.parent = find_set(x.parent)\r\n    return x.parent\r\n\r\n\r\ndef find_python_set(node: Node) -> set:\r\n    \"\"\"\r\n    Return a Python Standard Library set that contains i.\r\n    \"\"\"\r\n    sets = ({0, 1, 2}, {3, 4, 5})\r\n    for s in sets:\r\n        if node.data in s:\r\n            return s\r\n    raise ValueError(f\"{node.data} is not in {sets}\")\r\n\r\n\r\ndef test_disjoint_set():\r\n    \"\"\"\r\n    >>> test_disjoint_set()\r\n    \"\"\"\r\n    vertex = [Node(i) for i in range(6)]\r\n    for v in vertex:\r\n        make_set(v)\r\n\r\n    union_set(vertex[0], vertex[1])\r\n    union_set(vertex[1], vertex[2])\r\n    union_set(vertex[3], vertex[4])\r\n    union_set(vertex[3], vertex[5])\r\n\r\n    for node0 in vertex:\r\n        for node1 in vertex:\r\n            if find_python_set(node0).isdisjoint(find_python_set(node1)):\r\n                assert find_set(node0) != find_set(node1)\r\n            else:\r\n                assert find_set(node0) == find_set(node1)\r\n\r\n\r\nif __name__ == \"__main__\":\r\n    test_disjoint_set()\r\n", "path": "data_structures/disjoint_set/disjoint_set.py"}], "after_files": [{"content": "\"\"\"\r\n    disjoint set\r\n    Reference: https://en.wikipedia.org/wiki/Disjoint-set_data_structure\r\n\"\"\"\r\n\r\n\r\nclass Node:\r\n    def __init__(self, data):\r\n        self.data = data\r\n\r\n\r\ndef make_set(x):\r\n    \"\"\"\r\n    make x as a set.\r\n    \"\"\"\r\n    # rank is the distance from x to its' parent\r\n    # root's rank is 0\r\n    x.rank = 0\r\n    x.parent = x\r\n\r\n\r\ndef union_set(x, y):\r\n    \"\"\"\r\n    union two sets.\r\n    set with bigger rank should be parent, so that the\r\n    disjoint set tree will be more flat.\r\n    \"\"\"\r\n    x, y = find_set(x), find_set(y)\r\n    if x == y:\r\n        return\r\n\r\n    elif x.rank > y.rank:\r\n        y.parent = x\r\n    else:\r\n        x.parent = y\r\n        if x.rank == y.rank:\r\n            y.rank += 1\r\n\r\n\r\ndef find_set(x):\r\n    \"\"\"\r\n    return the parent of x\r\n    \"\"\"\r\n    if x != x.parent:\r\n        x.parent = find_set(x.parent)\r\n    return x.parent\r\n\r\n\r\ndef find_python_set(node: Node) -> set:\r\n    \"\"\"\r\n    Return a Python Standard Library set that contains i.\r\n    \"\"\"\r\n    sets = ({0, 1, 2}, {3, 4, 5})\r\n    for s in sets:\r\n        if node.data in s:\r\n            return s\r\n    raise ValueError(f\"{node.data} is not in {sets}\")\r\n\r\n\r\ndef test_disjoint_set():\r\n    \"\"\"\r\n    >>> test_disjoint_set()\r\n    \"\"\"\r\n    vertex = [Node(i) for i in range(6)]\r\n    for v in vertex:\r\n        make_set(v)\r\n\r\n    union_set(vertex[0], vertex[1])\r\n    union_set(vertex[1], vertex[2])\r\n    union_set(vertex[3], vertex[4])\r\n    union_set(vertex[3], vertex[5])\r\n\r\n    for node0 in vertex:\r\n        for node1 in vertex:\r\n            if find_python_set(node0).isdisjoint(find_python_set(node1)):\r\n                assert find_set(node0) != find_set(node1)\r\n            else:\r\n                assert find_set(node0) == find_set(node1)\r\n\r\n\r\nif __name__ == \"__main__\":\r\n    test_disjoint_set()\r\n", "path": "data_structures/disjoint_set/disjoint_set.py"}]}