Skip to content

Commit

Permalink
Activated mypy
Browse files Browse the repository at this point in the history
Change-Id: Ibc110b502b6eb1b3cac00b72488c5cafc794bbf9
  • Loading branch information
ssbarnea committed Oct 14, 2019
1 parent fbb9b62 commit b3a1ee5
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 33 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,4 @@ tests/test-reports-*/*
/.pytest_cache
/.vscode
/node_modules
.mypy_cache/
4 changes: 4 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,7 @@ repos:
rev: 0.6.0
hooks:
- id: bashate
- repo: https://github.com/pre-commit/mirrors-mypy.git
rev: v0.730
hooks:
- id: mypy
4 changes: 3 additions & 1 deletion cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,8 @@
"I18NSPHINXOPTS",
"hdost",
"βρέθηκε",
"PYTHONHTTPSVERIFY"
"PYTHONHTTPSVERIFY",
"ptype",
"mypy"
]
}
9 changes: 0 additions & 9 deletions examples/greenhopper.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,3 @@
board_id = 441
print("GreenHopper board: %s (%s)" % (boards[0].name, board_id))
sprints = gh.sprints(board_id)

# List the incomplete issues in each sprint
for sprint in sprints:
sprint_id = sprint.id
print("Sprint: %s" % sprint.name)
incompleted_issues = gh.incompleted_issues(board_id, sprint_id)
print(
"Incomplete issues: %s" % ", ".join(issue.key for issue in incompleted_issues)
)
2 changes: 1 addition & 1 deletion examples/maintenance.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
logging.info("Deleting permission scheme: %s" % s["name"])
try:
j.delete_permissionscheme(s["id"])
except Exception as e:
except JIRAError as e:
logging.error(e.text)
else:
logging.info("Permission scheme: %s" % s["name"])
Expand Down
11 changes: 4 additions & 7 deletions jira/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1447,6 +1447,7 @@ def service_desks(self):
url = self._options["server"] + "/rest/servicedeskapi/servicedesk"
headers = {"X-ExperimentalApi": "opt-in"}
r_json = json_loads(self._session.get(url, headers=headers))
print(r_json)
projects = [
ServiceDesk(self._options, self._session, raw_project_json)
for raw_project_json in r_json["values"]
Expand Down Expand Up @@ -3617,7 +3618,7 @@ def create_project(
key,
name=None,
assignee=None,
type="software",
ptype="software",
template_name=None,
avatarId=None,
issueSecurityScheme=None,
Expand All @@ -3636,7 +3637,7 @@ def create_project(
:param assignee: accountId of the lead, if not specified it will use current user.
:type assignee: Optional[str]
:param type: Determines the type of project should be created.
:type type: Optional[str]
:type ptype: Optional[str]
:param template_name: is used to create a project based on one of the existing project templates.
If `template_name` is not specified, then it should use one of the default values.
:type template_name: Optional[str]
Expand Down Expand Up @@ -3686,10 +3687,6 @@ def create_project(
if not template_name:
template_key = "com.pyxis.greenhopper.jira:gh-simplified-basic"

project_type_key = "software"

# project_type_keys = ["ops", "software", "service_desk", "business"]

# template_keys = [
# "com.pyxis.greenhopper.jira:gh-simplified-agility-kanban",
# "com.pyxis.greenhopper.jira:gh-simplified-agility-scrum",
Expand Down Expand Up @@ -3747,7 +3744,7 @@ def create_project(
payload = {
"name": name,
"key": key,
"projectTypeKey": project_type_key,
"projectTypeKey": ptype,
"projectTemplateKey": template_key,
"leadAccountId": assignee,
"assigneeType": "PROJECT_LEAD",
Expand Down
4 changes: 4 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ test =
docutils>=0.12
flaky
MarkupSafe>=0.23
mypy
oauthlib
pre-commit # MIT
py >= 1.4
Expand Down Expand Up @@ -140,3 +141,6 @@ timeout = 80
# avoid useless warnings related to coverage skips
filterwarnings =
ignore::pytest.PytestWarning

[mypy]
python_version = 3.5
6 changes: 1 addition & 5 deletions tests/test_shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,8 @@
import io
import requests # noqa
import sys
from unittest.mock import patch, MagicMock

try:
# python 3.4+ should use builtin unittest.mock not mock package
from unittest.mock import patch, MagicMock
except ImportError:
from mock import patch, MagicMock

from jira import Role, Issue, JIRA, JIRAError, Project # noqa
import jira.jirashell as jirashell
Expand Down
16 changes: 6 additions & 10 deletions tests/tests.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#!/usr/bin/env python
import getpass
import hashlib
import inspect
import logging
import os
import pickle
Expand All @@ -15,18 +14,13 @@
import py
import pytest
import requests
from typing import Dict

import unittest

from unittest import mock


cmd_folder = os.path.abspath(
os.path.join(os.path.split(inspect.getfile(inspect.currentframe()))[0], "..")
)
if cmd_folder not in sys.path:
sys.path.insert(0, cmd_folder)

import jira # noqa
from jira import Role, Issue, JIRA, JIRAError, Project # noqa
from jira.resources import Resource, cls_for_resource, Group, UnknownResource # noqa
Expand Down Expand Up @@ -104,7 +98,7 @@ class JiraTestManager(object):
max_retries (int): number of retries to perform for recoverable HTTP errors.
"""

__shared_state = {}
__shared_state = {} # type: Dict[any, any]

def __init__(self):
self.__dict__ = self.__shared_state
Expand Down Expand Up @@ -2415,8 +2409,6 @@ class JiraServiceDeskTests(unittest.TestCase):
def setUp(self):
self.jira = JiraTestManager().jira_admin
self.test_manager = JiraTestManager()

def test_create_customer_request(self):
if not self.jira.supports_service_desk():
pytest.skip("Skipping Service Desk not enabled")

Expand All @@ -2425,9 +2417,13 @@ def test_create_customer_request(self):
except Exception:
pass

@flaky
def test_create_customer_request(self):

self.jira.create_project(
key=self.test_manager.project_sd,
name=self.test_manager.project_sd_name,
ptype="service_desk",
template_name="IT Service Desk",
)

Expand Down

0 comments on commit b3a1ee5

Please sign in to comment.