pycontribs / jira

Python Jira library. Development chat available on https://matrix.to/#/#pycontribs:matrix.org
https://jira.readthedocs.io
BSD 2-Clause "Simplified" License
1.96k stars 870 forks source link

`jira.client.JIRA.create_issue` mutates passed `fields` instead working on a copy. #822

Open WloHu opened 5 years ago

WloHu commented 5 years ago

Describe the bug Title.

According to good programming practices function shouldn't mutate passed arguments unless it says so (its name or documentation states that). This is especially wrong if function returns something else than None, 100% of the time (read: "has expicit return"). E.g.:

and both return None.

To Reproduce Steps to reproduce the behavior:

import jira
payload = {'project': 'ABC', 'issuetype': {'name': 'Task'}}
p_before = dict(payload)
jira.create_issue(jira.JIRA(...), fields=payload)  # Assume it works.
p_after = payload
assert p_after == p_before  # AssertionError

Expected behavior payload is not mutated after create_issue is run.

Stack Trace N/A

Version Information Python Interpreter: 3.6.6 jira-python: 2.0.0 OS: Arch Linux IPython (Optional): N/A Other Dependencies: Doesn't matter.

Additional context Not necessary?

stale[bot] commented 5 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

WloHu commented 5 years ago

LoL whut. Add some additional conditions to your bot for closing issues.