We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
[bug] visual.Rect component does not recalculate vertices after change of size, width and height properties
Which results in inability to update width and height of Rect during main loop. I have noticed that Rect class was updated (commit from 14 october), but this update made it unusable. Fix is simple, update vertices after setting size and set self._needVertexUpdate to True to enable redrawing updated shape.
 

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `psychopy/visual/rect.py`
Content:
```
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3 
4 """Creates a rectangle of given width and height as a special case of a
5 :class:`~psychopy.visual.ShapeStim`"""
6 
7 # Part of the PsychoPy library
8 # Copyright (C) 2002-2018 Jonathan Peirce (C) 2019 Open Science Tools Ltd.
9 # Distributed under the terms of the GNU General Public License (GPL).
10 
11 from __future__ import absolute_import, print_function
12 
13 import numpy as np
14 
15 import psychopy  # so we can get the __path__
16 from psychopy.visual.shape import BaseShapeStim
17 from psychopy.tools.attributetools import attributeSetter, setAttribute
18 
19 
20 class Rect(BaseShapeStim):
21     """Creates a rectangle of given width and height as a special case of a
22     :class:`~psychopy.visual.ShapeStim`
23 
24     (New in version 1.72.00)
25 
26     Attributes
27     ----------
28     width, height : float or int
29         The width and height of the rectangle. Values are aliased with fields
30         in the `size` attribute. Use these values to adjust the size of the
31         rectangle in a single dimension after initialization.
32 
33     """
34     def __init__(self,
35                  win,
36                  width=.5,
37                  height=.5,
38                  autoLog=None,
39                  units='',
40                  lineWidth=1.5,
41                  lineColor='white',
42                  lineColorSpace='rgb',
43                  fillColor=None,
44                  fillColorSpace='rgb',
45                  pos=(0, 0),
46                  size=None,
47                  ori=0.0,
48                  opacity=1.0,
49                  contrast=1.0,
50                  depth=0,
51                  interpolate=True,
52                  name=None,
53                  autoDraw=False):
54         """
55         Parameters
56         ----------
57         win : `~psychopy.visual.Window`
58             Window object to be associated with this stimuli.
59         width, height : float or int
60             The width and height of the rectangle. *DEPRECATED* use `size`
61             to define the dimensions of the rectangle on initialization. If
62             `size` is specified the values of `width` and `height` are
63             ignored. This is to provide legacy compatibility for existing
64             applications.
65         size : array_like, float or int
66             Width and height of the rectangle as (w, h) or [w, h]. If a single
67             value is provided, the width and height will be set to the same
68             specified value. If `None` is specified, the `size` will be set
69             with values passed to `width` and `height`.
70 
71         """
72         # width and height attributes, these are later aliased with `size`
73         self.__dict__['width'] = float(width)
74         self.__dict__['height'] = float(height)
75 
76         # If the size argument was specified, override values of width and
77         # height, this is to maintain legacy compatibility. Args width and
78         # height should be deprecated in later releases.
79         if size is None:
80             size = (self.__dict__['width'],
81                     self.__dict__['height'])
82 
83         # vertices for rectangle, CCW winding order
84         vertices = np.array([[-.5,  .5],
85                              [ .5,  .5],
86                              [ .5, -.5],
87                              [-.5, -.5]])
88 
89         super(Rect, self).__init__(
90             win,
91             units=units,
92             lineWidth=lineWidth,
93             lineColor=lineColor,
94             lineColorSpace=lineColorSpace,
95             fillColor=fillColor,
96             fillColorSpace=fillColorSpace,
97             vertices=vertices,
98             closeShape=True,
99             pos=pos,
100             size=size,
101             ori=ori,
102             opacity=opacity,
103             contrast=contrast,
104             depth=depth,
105             interpolate=interpolate,
106             name=name,
107             autoLog=autoLog,
108             autoDraw=autoDraw)
109 
110     @attributeSetter
111     def size(self, value):
112         """array-like.
113         Size of the rectangle (`width` and `height`).
114         """
115         # Needed to override `size` to ensure `width` and `height` attrs
116         # are updated when it changes.
117         self.__dict__['size'] = np.array(value, float)
118 
119         width, height = self.__dict__['size']
120         self.__dict__['width'] = width
121         self.__dict__['height'] = height
122 
123     def setSize(self, size, operation='', log=None):
124         """Usually you can use 'stim.attribute = value' syntax instead,
125         but use this method if you need to suppress the log message
126 
127         :ref:`Operations <attrib-operations>` supported.
128         """
129         setAttribute(self, 'size', size, log, operation)
130 
131     @attributeSetter
132     def width(self, value):
133         """int or float.
134         Width of the Rectangle (in its respective units, if specified).
135 
136         :ref:`Operations <attrib-operations>` supported.
137         """
138         self.__dict__['width'] = float(value)
139         self.size = (self.__dict__['width'], self.size[1])
140 
141     def setWidth(self, width, operation='', log=None):
142         """Usually you can use 'stim.attribute = value' syntax instead,
143         but use this method if you need to suppress the log message
144         """
145         setAttribute(self, 'width', width, log, operation)
146 
147     @attributeSetter
148     def height(self, value):
149         """int or float.
150         Height of the Rectangle (in its respective units, if specified).
151 
152         :ref:`Operations <attrib-operations>` supported.
153         """
154         self.__dict__['height'] = float(value)
155         self.size = (self.size[0], self.__dict__['height'])
156 
157     def setHeight(self, height, operation='', log=None):
158         """Usually you can use 'stim.attribute = value' syntax instead,
159         but use this method if you need to suppress the log message
160         """
161         setAttribute(self, 'height', height, log, operation)
162
```
--- 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/psychopy/visual/rect.py b/psychopy/visual/rect.py
--- a/psychopy/visual/rect.py
+++ b/psychopy/visual/rect.py
@@ -120,6 +120,8 @@
         self.__dict__['width'] = width
         self.__dict__['height'] = height
 
+        self._needVertexUpdate = True
+
     def setSize(self, size, operation='', log=None):
         """Usually you can use 'stim.attribute = value' syntax instead,
         but use this method if you need to suppress the log message

{"golden_diff": "diff --git a/psychopy/visual/rect.py b/psychopy/visual/rect.py\n--- a/psychopy/visual/rect.py\n+++ b/psychopy/visual/rect.py\n@@ -120,6 +120,8 @@\n         self.__dict__['width'] = width\n         self.__dict__['height'] = height\n \n+        self._needVertexUpdate = True\n+\n     def setSize(self, size, operation='', log=None):\n         \"\"\"Usually you can use 'stim.attribute = value' syntax instead,\n         but use this method if you need to suppress the log message\n", "issue": "[bug] visual.Rect component does not recalculate vertices after change of size, width and height properties\nWhich results in inability to update width and height of Rect during main loop. I have noticed that Rect class was updated (commit from 14 october), but this update made it unusable. Fix is simple, update vertices after setting size and set self._needVertexUpdate to True to enable redrawing updated shape.\r\n \n", "before_files": [{"content": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\n\"\"\"Creates a rectangle of given width and height as a special case of a\n:class:`~psychopy.visual.ShapeStim`\"\"\"\n\n# Part of the PsychoPy library\n# Copyright (C) 2002-2018 Jonathan Peirce (C) 2019 Open Science Tools Ltd.\n# Distributed under the terms of the GNU General Public License (GPL).\n\nfrom __future__ import absolute_import, print_function\n\nimport numpy as np\n\nimport psychopy  # so we can get the __path__\nfrom psychopy.visual.shape import BaseShapeStim\nfrom psychopy.tools.attributetools import attributeSetter, setAttribute\n\n\nclass Rect(BaseShapeStim):\n    \"\"\"Creates a rectangle of given width and height as a special case of a\n    :class:`~psychopy.visual.ShapeStim`\n\n    (New in version 1.72.00)\n\n    Attributes\n    ----------\n    width, height : float or int\n        The width and height of the rectangle. Values are aliased with fields\n        in the `size` attribute. Use these values to adjust the size of the\n        rectangle in a single dimension after initialization.\n\n    \"\"\"\n    def __init__(self,\n                 win,\n                 width=.5,\n                 height=.5,\n                 autoLog=None,\n                 units='',\n                 lineWidth=1.5,\n                 lineColor='white',\n                 lineColorSpace='rgb',\n                 fillColor=None,\n                 fillColorSpace='rgb',\n                 pos=(0, 0),\n                 size=None,\n                 ori=0.0,\n                 opacity=1.0,\n                 contrast=1.0,\n                 depth=0,\n                 interpolate=True,\n                 name=None,\n                 autoDraw=False):\n        \"\"\"\n        Parameters\n        ----------\n        win : `~psychopy.visual.Window`\n            Window object to be associated with this stimuli.\n        width, height : float or int\n            The width and height of the rectangle. *DEPRECATED* use `size`\n            to define the dimensions of the rectangle on initialization. If\n            `size` is specified the values of `width` and `height` are\n            ignored. This is to provide legacy compatibility for existing\n            applications.\n        size : array_like, float or int\n            Width and height of the rectangle as (w, h) or [w, h]. If a single\n            value is provided, the width and height will be set to the same\n            specified value. If `None` is specified, the `size` will be set\n            with values passed to `width` and `height`.\n\n        \"\"\"\n        # width and height attributes, these are later aliased with `size`\n        self.__dict__['width'] = float(width)\n        self.__dict__['height'] = float(height)\n\n        # If the size argument was specified, override values of width and\n        # height, this is to maintain legacy compatibility. Args width and\n        # height should be deprecated in later releases.\n        if size is None:\n            size = (self.__dict__['width'],\n                    self.__dict__['height'])\n\n        # vertices for rectangle, CCW winding order\n        vertices = np.array([[-.5,  .5],\n                             [ .5,  .5],\n                             [ .5, -.5],\n                             [-.5, -.5]])\n\n        super(Rect, self).__init__(\n            win,\n            units=units,\n            lineWidth=lineWidth,\n            lineColor=lineColor,\n            lineColorSpace=lineColorSpace,\n            fillColor=fillColor,\n            fillColorSpace=fillColorSpace,\n            vertices=vertices,\n            closeShape=True,\n            pos=pos,\n            size=size,\n            ori=ori,\n            opacity=opacity,\n            contrast=contrast,\n            depth=depth,\n            interpolate=interpolate,\n            name=name,\n            autoLog=autoLog,\n            autoDraw=autoDraw)\n\n    @attributeSetter\n    def size(self, value):\n        \"\"\"array-like.\n        Size of the rectangle (`width` and `height`).\n        \"\"\"\n        # Needed to override `size` to ensure `width` and `height` attrs\n        # are updated when it changes.\n        self.__dict__['size'] = np.array(value, float)\n\n        width, height = self.__dict__['size']\n        self.__dict__['width'] = width\n        self.__dict__['height'] = height\n\n    def setSize(self, size, operation='', log=None):\n        \"\"\"Usually you can use 'stim.attribute = value' syntax instead,\n        but use this method if you need to suppress the log message\n\n        :ref:`Operations <attrib-operations>` supported.\n        \"\"\"\n        setAttribute(self, 'size', size, log, operation)\n\n    @attributeSetter\n    def width(self, value):\n        \"\"\"int or float.\n        Width of the Rectangle (in its respective units, if specified).\n\n        :ref:`Operations <attrib-operations>` supported.\n        \"\"\"\n        self.__dict__['width'] = float(value)\n        self.size = (self.__dict__['width'], self.size[1])\n\n    def setWidth(self, width, operation='', log=None):\n        \"\"\"Usually you can use 'stim.attribute = value' syntax instead,\n        but use this method if you need to suppress the log message\n        \"\"\"\n        setAttribute(self, 'width', width, log, operation)\n\n    @attributeSetter\n    def height(self, value):\n        \"\"\"int or float.\n        Height of the Rectangle (in its respective units, if specified).\n\n        :ref:`Operations <attrib-operations>` supported.\n        \"\"\"\n        self.__dict__['height'] = float(value)\n        self.size = (self.size[0], self.__dict__['height'])\n\n    def setHeight(self, height, operation='', log=None):\n        \"\"\"Usually you can use 'stim.attribute = value' syntax instead,\n        but use this method if you need to suppress the log message\n        \"\"\"\n        setAttribute(self, 'height', height, log, operation)\n", "path": "psychopy/visual/rect.py"}], "after_files": [{"content": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\n\"\"\"Creates a rectangle of given width and height as a special case of a\n:class:`~psychopy.visual.ShapeStim`\"\"\"\n\n# Part of the PsychoPy library\n# Copyright (C) 2002-2018 Jonathan Peirce (C) 2019 Open Science Tools Ltd.\n# Distributed under the terms of the GNU General Public License (GPL).\n\nfrom __future__ import absolute_import, print_function\n\nimport numpy as np\n\nimport psychopy  # so we can get the __path__\nfrom psychopy.visual.shape import BaseShapeStim\nfrom psychopy.tools.attributetools import attributeSetter, setAttribute\n\n\nclass Rect(BaseShapeStim):\n    \"\"\"Creates a rectangle of given width and height as a special case of a\n    :class:`~psychopy.visual.ShapeStim`\n\n    (New in version 1.72.00)\n\n    Attributes\n    ----------\n    width, height : float or int\n        The width and height of the rectangle. Values are aliased with fields\n        in the `size` attribute. Use these values to adjust the size of the\n        rectangle in a single dimension after initialization.\n\n    \"\"\"\n    def __init__(self,\n                 win,\n                 width=.5,\n                 height=.5,\n                 autoLog=None,\n                 units='',\n                 lineWidth=1.5,\n                 lineColor='white',\n                 lineColorSpace='rgb',\n                 fillColor=None,\n                 fillColorSpace='rgb',\n                 pos=(0, 0),\n                 size=None,\n                 ori=0.0,\n                 opacity=1.0,\n                 contrast=1.0,\n                 depth=0,\n                 interpolate=True,\n                 name=None,\n                 autoDraw=False):\n        \"\"\"\n        Parameters\n        ----------\n        win : `~psychopy.visual.Window`\n            Window object to be associated with this stimuli.\n        width, height : float or int\n            The width and height of the rectangle. *DEPRECATED* use `size`\n            to define the dimensions of the rectangle on initialization. If\n            `size` is specified the values of `width` and `height` are\n            ignored. This is to provide legacy compatibility for existing\n            applications.\n        size : array_like, float or int\n            Width and height of the rectangle as (w, h) or [w, h]. If a single\n            value is provided, the width and height will be set to the same\n            specified value. If `None` is specified, the `size` will be set\n            with values passed to `width` and `height`.\n\n        \"\"\"\n        # width and height attributes, these are later aliased with `size`\n        self.__dict__['width'] = float(width)\n        self.__dict__['height'] = float(height)\n\n        # If the size argument was specified, override values of width and\n        # height, this is to maintain legacy compatibility. Args width and\n        # height should be deprecated in later releases.\n        if size is None:\n            size = (self.__dict__['width'],\n                    self.__dict__['height'])\n\n        # vertices for rectangle, CCW winding order\n        vertices = np.array([[-.5,  .5],\n                             [ .5,  .5],\n                             [ .5, -.5],\n                             [-.5, -.5]])\n\n        super(Rect, self).__init__(\n            win,\n            units=units,\n            lineWidth=lineWidth,\n            lineColor=lineColor,\n            lineColorSpace=lineColorSpace,\n            fillColor=fillColor,\n            fillColorSpace=fillColorSpace,\n            vertices=vertices,\n            closeShape=True,\n            pos=pos,\n            size=size,\n            ori=ori,\n            opacity=opacity,\n            contrast=contrast,\n            depth=depth,\n            interpolate=interpolate,\n            name=name,\n            autoLog=autoLog,\n            autoDraw=autoDraw)\n\n    @attributeSetter\n    def size(self, value):\n        \"\"\"array-like.\n        Size of the rectangle (`width` and `height`).\n        \"\"\"\n        # Needed to override `size` to ensure `width` and `height` attrs\n        # are updated when it changes.\n        self.__dict__['size'] = np.array(value, float)\n\n        width, height = self.__dict__['size']\n        self.__dict__['width'] = width\n        self.__dict__['height'] = height\n\n        self._needVertexUpdate = True\n\n    def setSize(self, size, operation='', log=None):\n        \"\"\"Usually you can use 'stim.attribute = value' syntax instead,\n        but use this method if you need to suppress the log message\n\n        :ref:`Operations <attrib-operations>` supported.\n        \"\"\"\n        setAttribute(self, 'size', size, log, operation)\n\n    @attributeSetter\n    def width(self, value):\n        \"\"\"int or float.\n        Width of the Rectangle (in its respective units, if specified).\n\n        :ref:`Operations <attrib-operations>` supported.\n        \"\"\"\n        self.__dict__['width'] = float(value)\n        self.size = (self.__dict__['width'], self.size[1])\n\n    def setWidth(self, width, operation='', log=None):\n        \"\"\"Usually you can use 'stim.attribute = value' syntax instead,\n        but use this method if you need to suppress the log message\n        \"\"\"\n        setAttribute(self, 'width', width, log, operation)\n\n    @attributeSetter\n    def height(self, value):\n        \"\"\"int or float.\n        Height of the Rectangle (in its respective units, if specified).\n\n        :ref:`Operations <attrib-operations>` supported.\n        \"\"\"\n        self.__dict__['height'] = float(value)\n        self.size = (self.size[0], self.__dict__['height'])\n\n    def setHeight(self, height, operation='', log=None):\n        \"\"\"Usually you can use 'stim.attribute = value' syntax instead,\n        but use this method if you need to suppress the log message\n        \"\"\"\n        setAttribute(self, 'height', height, log, operation)\n", "path": "psychopy/visual/rect.py"}]}