Skip to content

Commit

Permalink
fix: use deep copying instead of just making a shallow copy
Browse files Browse the repository at this point in the history
  • Loading branch information
hearot committed Jun 12, 2020
1 parent 18bdd9c commit 2c98a3c
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Expand Up @@ -16,7 +16,7 @@

- Add `callback_query_id` as a special key for parameters ([7222fcc6eb3c2a037c2b71109c9163028ef4eea4](https://github.com/hearot/pyrubrum/commit/7222fcc6eb3c2a037c2b71109c9163028ef4eea4))
- Add a code of conduct ([95694f93986ede7545a782e6b34b8ec7ca2a2c93](https://github.com/hearot/pyrubrum/commit/95694f93986ede7545a782e6b34b8ec7ca2a2c93))
- Add a notice about the keys starting with `page_`
- Add a notice about the keys starting with `page_` ([18bdd9c336fb41a89984e97ee39f81b33c5809a2](https://github.com/hearot/pyrubrum/commit/18bdd9c336fb41a89984e97ee39f81b33c5809a2))
- Add a security policy ([ba507a8b2a6a386d7ad2d561d9b805d341e8b284](https://github.com/hearot/pyrubrum/commit/ba507a8b2a6a386d7ad2d561d9b805d341e8b284))
- Add a statement about the return value of `Node.__hash__()` ([5a9a257ef122bd47f0a010dc5e1ebcb5e1cb1b90](https://github.com/hearot/pyrubrum/commit/5a9a257ef122bd47f0a010dc5e1ebcb5e1cb1b90))
- Add disclaimer notice ([a7a6060a7243a1ed7857b2b78649d573cbe7feab](https://github.com/hearot/pyrubrum/commit/a7a6060a7243a1ed7857b2b78649d573cbe7feab))
Expand Down Expand Up @@ -56,6 +56,7 @@
- Make `Element` docstrings consistent with `Button` ones ([9a035a35439077a9f12371bc96e6508020f3ecd6](https://github.com/hearot/pyrubrum/commit/9a035a35439077a9f12371bc96e6508020f3ecd6))
- Make databases consistent with the documentation ([d5debbfa52eb16e012ad8e022a5b3d8a06051a59](https://github.com/hearot/pyrubrum/commit/d5debbfa52eb16e012ad8e022a5b3d8a06051a59))
- Menus are now collected using sets instead of unhashable lists ([46755e471bb94efd963af3bd7b9da95de39bdbed](https://github.com/hearot/pyrubrum/commit/46755e471bb94efd963af3bd7b9da95de39bdbed))
- Use deep copying instead of just making a shallow copy

### New features

Expand Down
3 changes: 2 additions & 1 deletion FEATURES.md
Expand Up @@ -2,7 +2,7 @@

- Add `callback_query_id` as a special key for parameters ([7222fcc6eb3c2a037c2b71109c9163028ef4eea4](https://github.com/hearot/pyrubrum/commit/7222fcc6eb3c2a037c2b71109c9163028ef4eea4))
- Add a code of conduct ([95694f93986ede7545a782e6b34b8ec7ca2a2c93](https://github.com/hearot/pyrubrum/commit/95694f93986ede7545a782e6b34b8ec7ca2a2c93))
- Add a notice about the keys starting with `page_`
- Add a notice about the keys starting with `page_` ([18bdd9c336fb41a89984e97ee39f81b33c5809a2](https://github.com/hearot/pyrubrum/commit/18bdd9c336fb41a89984e97ee39f81b33c5809a2))
- Add a security policy ([ba507a8b2a6a386d7ad2d561d9b805d341e8b284](https://github.com/hearot/pyrubrum/commit/ba507a8b2a6a386d7ad2d561d9b805d341e8b284))
- Add a statement about the return value of `Node.__hash__()` ([5a9a257ef122bd47f0a010dc5e1ebcb5e1cb1b90](https://github.com/hearot/pyrubrum/commit/5a9a257ef122bd47f0a010dc5e1ebcb5e1cb1b90))
- Add disclaimer notice ([a7a6060a7243a1ed7857b2b78649d573cbe7feab](https://github.com/hearot/pyrubrum/commit/a7a6060a7243a1ed7857b2b78649d573cbe7feab))
Expand Down Expand Up @@ -42,6 +42,7 @@
- Make `Element` docstrings consistent with `Button` ones ([9a035a35439077a9f12371bc96e6508020f3ecd6](https://github.com/hearot/pyrubrum/commit/9a035a35439077a9f12371bc96e6508020f3ecd6))
- Make databases consistent with the documentation ([d5debbfa52eb16e012ad8e022a5b3d8a06051a59](https://github.com/hearot/pyrubrum/commit/d5debbfa52eb16e012ad8e022a5b3d8a06051a59))
- Menus are now collected using sets instead of unhashable lists ([46755e471bb94efd963af3bd7b9da95de39bdbed](https://github.com/hearot/pyrubrum/commit/46755e471bb94efd963af3bd7b9da95de39bdbed))
- Use deep copying instead of just making a shallow copy

### New features

Expand Down
7 changes: 4 additions & 3 deletions pyrubrum/button.py
Expand Up @@ -16,6 +16,7 @@
# You should have received a copy of the GNU Lesser General Public License
# along with Pyrubrum. If not, see <http://www.gnu.org/licenses/>.

from copy import deepcopy
from dataclasses import dataclass
from typing import Any
from typing import Optional
Expand Down Expand Up @@ -66,8 +67,8 @@ def __init__(
same_menu: Optional[bool] = False,
**kwargs
):
"""Initialize the button by setting the attributes of this object and copying
the dictionary of parameters.
"""Initialize the button by setting the attributes of this object and deep
copying the dictionary of parameters.
Args:
name (str): The name which is displayed inside the text field of
Expand All @@ -88,7 +89,7 @@ def __init__(
self.button_id = button_id
self.element_id = element_id
self.name = name
self.parameters = parameters.copy()
self.parameters = deepcopy(parameters)
self.parameters.update(kwargs)

self.parameters["button_id"] = button_id
Expand Down
4 changes: 2 additions & 2 deletions pyrubrum/page_menu.py
Expand Up @@ -245,7 +245,7 @@ def keyboard(
previous_page_button = Button(
self.previous_page_button_text,
self.menu_id,
parameters.copy(),
parameters,
parameters[page_id] - 1,
True,
)
Expand All @@ -261,7 +261,7 @@ def keyboard(
next_page_button = Button(
self.next_page_button_text,
self.menu_id,
parameters.copy(),
parameters,
parameters[page_id] + 1,
True,
)
Expand Down

0 comments on commit 2c98a3c

Please sign in to comment.