Skip to content

Commit

Permalink
Correct lookup of issuetypes when calling create_issue (#978)
Browse files Browse the repository at this point in the history
* correct lookup of issuetypes when calling create_issue

* Fixed syntax error for issue 978
  • Loading branch information
soerenbe authored May 15, 2021
1 parent 6e51395 commit ca9f178
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions jira/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1375,7 +1375,7 @@ def create_issues(
p = issue_data["fields"]["issuetype"]
if isinstance(p, int):
issue_data["fields"]["issuetype"] = {"id": p}
if isinstance(p, str) or isinstance(p, int):
if isinstance(p, str):
issue_data["fields"]["issuetype"] = {
"id": self.issue_type_by_name(str(p)).id
}
Expand Down Expand Up @@ -2238,12 +2238,13 @@ def issue_type_by_name(self, name: str) -> IssueType:
Returns:
IssueType
"""
issue_types = self.issue_types()
try:
issue_type = [it for it in issue_types if it.name == name][0]
except IndexError:
matching_issue_types = [it for it in self.issue_types() if it.name == name]
if len(matching_issue_types) == 1:
return matching_issue_types[0]
elif len(matching_issue_types) == 0:
raise KeyError("Issue type '%s' is unknown." % name)
return issue_type
else:
raise KeyError("Issue type '%s' appears more than once." % name)

def request_types(self, service_desk: ServiceDesk) -> List[RequestType]:
"""Returns request types supported by a service desk instance.
Expand Down

0 comments on commit ca9f178

Please sign in to comment.