Skip to content

Commit 206f62b

Browse files
authored
api: py37 support and rename async to async_ (#604)
Breaking change as is renames all async parameters to async_ in order to assure python 3.7 compatibility. Fixes: #603 Signed-off-by: Sorin Sbarnea <[email protected]>
1 parent e81f28a commit 206f62b

File tree

9 files changed

+57
-29
lines changed

9 files changed

+57
-29
lines changed

.travis.yml

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ cache:
55
- directories:
66
- "node_modules"
77
- $HOME/.cache
8-
sudo: false
98
os:
109
- linux
1110
stages:
@@ -14,11 +13,20 @@ stages:
1413
- test
1514
- deploy
1615
before_install:
17-
- which tox >/dev/null || if [ -z ${VIRTUAL_ENV+x} ]; then pip install --user tox ; else pip install tox; fi
16+
# begin: workaround to enable support for py37:
17+
# - curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
18+
# - sudo apt-get install -y nodejs
19+
# - curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
20+
# - echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
21+
# - sudo apt-get update && sudo apt-get install yarn
22+
# - if [[ $TRAVIS_PYTHON_VERSION == '3.7-dev' ]]; then sudo add-apt-repository ppa:deadsnakes/ppa -y; fi
23+
# - if [[ $TRAVIS_PYTHON_VERSION == '3.7-dev' ]]; then sudo apt-get update; fi
24+
- nvm install $TRAVIS_NODE_VERSION
25+
# end
26+
- which tox >/dev/null || if [ -z ${VIRTUAL_ENV+x} ]; then pip install --user tox tox-pyenv ; else pip install tox tox-pyenv; fi
1827
notifications:
1928
email:
2029
21-
2230
jobs:
2331
include:
2432
- stage: lint
@@ -59,6 +67,16 @@ jobs:
5967
env: TOXENV=py36 PYTHON='3.6' PYENV_VERSION='system'
6068
after_success:
6169
- bash <(curl -s https://codecov.io/bash) -e TOX_ENV
70+
- stage: test
71+
script: pip install -q tox-travis && python -m tox
72+
python: "3.7"
73+
env: TOXENV=py37 PYTHON='3.7'
74+
after_success:
75+
- bash <(curl -s https://codecov.io/bash) -e TOX_ENV
76+
# begin: workaround to enable support for py37:
77+
sudo: required
78+
dist: xenial
79+
# end
6280
- stage: deploy
6381
script:
6482
- export PACKAGE_NAME=$(python setup.py --name)
@@ -92,3 +110,4 @@ env:
92110
- secure: fuXwQL+KHQ96XkAFl2uQc8eK8dAjrgkup46tck/UGjVpdv1PT/yHmBKrvpFjDa50ueGbtBwTdKAwhyAmYuiZCk2IYHzdvBylCZBBji2FSpaTM59CVwgkVT6tx3HHO83X0mEX6ih9TJvZD5XhX+YUjopnseRXRq3ey3JZJXWN4RM=
93111
- secure: "pGQGM5YmHvOgaKihOyzb3k6bdqLQnZQ2OXO9QrfXlXwtop3zvZQi80Q+01l230x2psDWlwvqWTknAjAt1w463fYXPwpoSvKVCsLSSbjrf2l56nrDqnoir+n0CBy288+eIdaGEfzcxDiuULeKjlg08zrqjcjLjW0bDbBrlTXsb5U="
94112
- PIP_DISABLE_PIP_VERSION_CHECK=1
113+
- TRAVIS_NODE_VERSION="v8.11.3"

cspell.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@
152152
"workon",
153153
"xargs",
154154
"xdist",
155+
"xenial",
155156
"xfail",
156157
"xscs",
157158
"xsrf",

jira/client.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ class JIRA(object):
291291
as anonymous it will fail to instantiate.
292292
:param get_server_info: If true it will fetch server version info first to determine if some API calls
293293
are available.
294-
:param async: To enable async requests for those actions where we implemented it, like issue update() or delete().
294+
:param async_: To enable asynchronous requests for those actions where we implemented it, like issue update() or delete().
295295
:param timeout: Set a read/connect timeout for the underlying calls to JIRA (default: None)
296296
Obviously this means that you cannot rely on the return code when this is enabled.
297297
"""
@@ -325,7 +325,7 @@ class JIRA(object):
325325
AGILE_BASE_URL = GreenHopperResource.AGILE_BASE_URL
326326

327327
def __init__(self, server=None, options=None, basic_auth=None, oauth=None, jwt=None, kerberos=False, kerberos_options=None,
328-
validate=False, get_server_info=True, async=False, logging=True, max_retries=3, proxies=None,
328+
validate=False, get_server_info=True, async_=False, logging=True, max_retries=3, proxies=None,
329329
timeout=None, auth=None):
330330
"""Construct a JIRA client instance.
331331
@@ -373,7 +373,7 @@ def __init__(self, server=None, options=None, basic_auth=None, oauth=None, jwt=N
373373
as anonymous it will fail to instantiate.
374374
:param get_server_info: If true it will fetch server version info first to determine if some API calls
375375
are available.
376-
:param async: To enable async requests for those actions where we implemented it, like issue update() or delete().
376+
:param async_: To enable async requests for those actions where we implemented it, like issue update() or delete().
377377
:param timeout: Set a read/connect timeout for the underlying calls to JIRA (default: None)
378378
Obviously this means that you cannot rely on the return code when this is enabled.
379379
:param auth: Set a cookie auth token if this is required.
@@ -393,8 +393,8 @@ def __init__(self, server=None, options=None, basic_auth=None, oauth=None, jwt=N
393393

394394
if server:
395395
options['server'] = server
396-
if async:
397-
options['async'] = async
396+
if async_:
397+
options['async'] = async_
398398

399399
self.logging = logging
400400

@@ -657,12 +657,12 @@ def find(self, resource_format, ids=None):
657657
return resource
658658

659659
def async_do(self, size=10):
660-
"""Execute all async jobs and wait for them to finish. By default it will run on 10 threads.
660+
"""Execute all asynchronous jobs and wait for them to finish. By default it will run on 10 threads.
661661
662662
:param size: number of threads to run on.
663663
"""
664664
if hasattr(self._session, '_async_jobs'):
665-
logging.info("Executing async %s jobs found in queue by using %s threads..." % (
665+
logging.info("Executing asynchronous %s jobs found in queue by using %s threads..." % (
666666
len(self._session._async_jobs), size))
667667
threaded_requests.map(self._session._async_jobs, size=size)
668668

@@ -3377,8 +3377,8 @@ def move_to_backlog(self, issue_keys):
33773377

33783378
class GreenHopper(JIRA):
33793379

3380-
def __init__(self, options=None, basic_auth=None, oauth=None, async=None):
3380+
def __init__(self, options=None, basic_auth=None, oauth=None, async_=None):
33813381
warnings.warn(
33823382
"GreenHopper() class is deprecated, just use JIRA() instead.", DeprecationWarning)
33833383
JIRA.__init__(
3384-
self, options=options, basic_auth=basic_auth, oauth=oauth, async=async)
3384+
self, options=options, basic_auth=basic_auth, oauth=oauth, async_=async_)

jira/resources.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -204,17 +204,17 @@ def _get_url(self, path):
204204
options.update({'path': path})
205205
return self._base_url.format(**options)
206206

207-
def update(self, fields=None, async=None, jira=None, notify=True, **kwargs):
207+
def update(self, fields=None, async_=None, jira=None, notify=True, **kwargs):
208208
"""Update this resource on the server.
209209
210210
Keyword arguments are marshalled into a dict before being sent. If this
211211
resource doesn't support ``PUT``, a :py:exc:`.JIRAError` will be raised; subclasses that specialize this method
212212
will only raise errors in case of user error.
213213
214-
:param async: if true the request will be added to the queue so it can be executed later using async_run()
214+
:param async_: if true the request will be added to the queue so it can be executed later using async_run()
215215
"""
216-
if async is None:
217-
async = self._options['async']
216+
if async_ is None:
217+
async_ = self._options['async']
218218

219219
data = {}
220220
if fields is not None:
@@ -282,7 +282,7 @@ def update(self, fields=None, async=None, jira=None, notify=True, **kwargs):
282282
# logging.warning("autofix: setting assignee to '%s' and retrying the update." % self._options['autofix'])
283283
# data['fields']['assignee'] = {'name': self._options['autofix']}
284284
# EXPERIMENTAL --->
285-
if async:
285+
if async_:
286286
if not hasattr(self._session, '_async_jobs'):
287287
self._session._async_jobs = set()
288288
self._session._async_jobs.add(threaded_requests.put(
@@ -431,7 +431,7 @@ def __init__(self, options, session, raw=None):
431431
if raw:
432432
self._parse_raw(raw)
433433

434-
def update(self, fields=None, update=None, async=None, jira=None, notify=True, **fieldargs):
434+
def update(self, fields=None, update=None, async_=None, jira=None, notify=True, **fieldargs):
435435
"""Update this issue on the server.
436436
437437
Each keyword argument (other than the predefined ones) is treated as a field name and the argument's value
@@ -481,7 +481,7 @@ def update(self, fields=None, update=None, async=None, jira=None, notify=True, *
481481
else:
482482
fields_dict[field] = value
483483

484-
super(Issue, self).update(async=async, jira=jira, notify=notify, fields=data)
484+
super(Issue, self).update(async_=async_, jira=jira, notify=notify, fields=data)
485485

486486
def add_field_value(self, field, value):
487487
"""Add a value to a field that supports multiple values, without resetting the existing values.
@@ -526,7 +526,7 @@ def __init__(self, options, session, raw=None):
526526
if raw:
527527
self._parse_raw(raw)
528528

529-
def update(self, fields=None, async=None, jira=None, body='', visibility=None):
529+
def update(self, fields=None, async_=None, jira=None, body='', visibility=None):
530530
data = {}
531531
if body:
532532
data['body'] = body

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"name": "python-jira",
33
"version": "0.0.1",
4+
"license": "SEE LICENSE IN LICENSE",
45
"scripts": {
56
"spell": "npm -s run spell-files && npm -s run spell-commit",
67
"spell-commit": "git log -1 --pretty=%B > .git/commit.msg && cspell .git/commit.msg",
@@ -11,6 +12,7 @@
1112
"url": "https://github.com/pycontribs/jira.git"
1213
},
1314
"dependencies": {
14-
"cspell": "^2.1.12"
15+
"cspell": "^2.1.12",
16+
"npm": "^6.1.0"
1517
}
1618
}

requirements-dev.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ pytest-cov
1313
pytest-instafail
1414
pytest-xdist>=1.14
1515
pytest>=2.9.1
16+
PyYAML>=3.12,<4; python_version<'3.7'
17+
# this file is needed by readthedocs.org so don't move them in another place
18+
PyYAML>=4.2b2; python_version>='3.7'
1619
requires.io
1720
tenacity
1821
tox-pyenv

setup.cfg

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ packages =
4343
#[options.extras_require]
4444
[extras]
4545
cli =
46-
ipython>=4.0.0
46+
ipython>=4.0.0,<6.0.0; python_version<'3.3'
47+
ipython>=4.0.0; python_version>='3.3'
4748
opt =
4849
filemagic>=1.6
4950
PyJWT

tests/tests.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1967,7 +1967,7 @@ class AsyncTests(unittest.TestCase):
19671967

19681968
def setUp(self):
19691969
self.jira = JIRA('https://jira.atlassian.com', logging=False,
1970-
async=True, validate=False, get_server_info=False)
1970+
async_=True, validate=False, get_server_info=False)
19711971

19721972
def test_fetch_pages(self):
19731973
"""Tests that the JIRA._fetch_pages method works as expected. """

tox.ini

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tox]
22
minversion = 2.3.1
3-
envlist = lint,py27,py34,py35,py36,docs
3+
envlist = lint,py27,py37,py36,py35,py34,docs
44
skip_missing_interpreters = true
55

66
[testenv:docs]
@@ -20,11 +20,9 @@ deps =
2020
extras =
2121
cli
2222
opt
23-
# sitepackages is needed in order to make --user work
24-
# see https://github.com/pypa/pip/issues/4141#issuecomment-272907550
25-
sitepackages=True
26-
23+
sitepackages=False
2724
commands=
25+
bash -c 'find . | grep -E "(__pycache__|\.pyc|\.pyo$)" | xargs rm -rf'
2826
python -m pip check
2927
python -m pytest {posargs}
3028
passenv =
@@ -35,10 +33,14 @@ passenv =
3533
TRAVIS_*
3634
XDG_CACHE_HOME
3735
envars =
38-
PIP_DISABLE_PIP_VERSON_CHECK=1
36+
PIP_DISABLE_PIP_VERSION_CHECK=1
3937
PIP_USER=no
4038
whitelist_externals =
4139
bash
40+
find
41+
grep
42+
rm
43+
xargs
4244

4345
[testenv:lint]
4446
commands=

0 commit comments

Comments
 (0)