Skip to content

Commit 6561ad8

Browse files
committed
drop python2 code; upgrade mypy; format with 'black'
1 parent efb40a8 commit 6561ad8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

97 files changed

+9390
-6979
lines changed

.travis.yml

-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ install:
2020
- pip install tox-travis
2121
jobs:
2222
include:
23-
- python: "2.7"
2423
- python: "3.5"
2524
- python: "3.6"
2625
- python: "3.7"

CONTRIBUTING.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Style guide:
22
- PEP-8
3-
-Python 2.7 + Python 3.5+ compatible code
4-
- PEP-484 type hints, in comments for Python 2.7 compatability
3+
-Python 3.5+ compatible code
4+
- PEP-484 type hints; variable types in comments for Python 3.5 compatability
55
- Vertically align the type hints in function definitions
66

77
In order to contribute to the development of ``cwltool``, you need to install cwltool from source (preferably in a virtual environment):

Makefile

+20-40
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@
1515
#
1616
1717

18-
# make pycodestyle to check for basic Python code compliance
19-
# make autopep8 to fix most pep8 errors
18+
# make format to fix most python formatting errors
2019
# make pylint to check Python code for enhanced compliance including naming
2120
# and documentation
2221
# make coverage-report to check coverage of the python scripts by the tests
@@ -26,11 +25,11 @@ MODULE=cwltool
2625
# `SHELL=bash` doesn't work for some, so don't use BASH-isms like
2726
# `[[` conditional expressions.
2827
PYSOURCES=$(wildcard ${MODULE}/**.py tests/*.py) setup.py
29-
DEVPKGS=pycodestyle diff_cover autopep8 pylint coverage pydocstyle flake8 \
28+
DEVPKGS=diff_cover black pylint coverage pep257 pydocstyle flake8 mypy\
3029
pytest-xdist==1.27.0 isort wheel -rtest-requirements.txt
3130
DEBDEVPKGS=pep8 python-autopep8 pylint python-coverage pydocstyle sloccount \
3231
python-flake8 python-mock shellcheck
33-
VERSION=1.0.$(shell TZ=UTC git log --first-parent --max-count=1 \
32+
VERSION=2.0.$(shell TZ=UTC git log --first-parent --max-count=1 \
3433
--format=format:%cd --date=format-local:%Y%m%d%H%M%S)
3534
mkfile_dir := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
3635
UNAME_S=$(shell uname -s)
@@ -44,8 +43,11 @@ help: Makefile
4443
@sed -n 's/^##//p' $<
4544

4645
## install-dep : install most of the development dependencies via pip
47-
install-dep:
46+
install-dep: install-dependencies
47+
48+
install-dependencies:
4849
pip install --upgrade $(DEVPKGS)
50+
pip install -r requirements.txt
4951

5052
## install-deb-dep: install most of the dev dependencies via apt-get
5153
install-deb-dep:
@@ -78,19 +80,6 @@ clean: FORCE
7880
sort_imports:
7981
isort ${MODULE}/*.py tests/*.py setup.py
8082

81-
pep8: pycodestyle
82-
## pycodestyle : check Python code style
83-
pycodestyle: $(PYSOURCES)
84-
pycodestyle --exclude=_version.py --show-source --show-pep8 $^ || true
85-
86-
pep8_report.txt: pycodestyle_report.txt
87-
pycodestyle_report.txt: $(PYSOURCES)
88-
pycodestyle --exclude=_version.py $^ > $@ || true
89-
90-
diff_pep8_report: diff_pycodestyle_report
91-
diff_pycodestyle_report: pycodestyle_report.txt
92-
diff-quality --violations=pycodestyle $^
93-
9483
pep257: pydocstyle
9584
## pydocstyle : check Python code style
9685
pydocstyle: $(PYSOURCES)
@@ -102,14 +91,9 @@ pydocstyle_report.txt: $(PYSOURCES)
10291
diff_pydocstyle_report: pydocstyle_report.txt
10392
diff-quality --violations=pycodestyle --fail-under=100 $^
10493

105-
## autopep8 : fix most Python code indentation and formatting
106-
autopep8: $(PYSOURCES)
107-
autopep8 --recursive --in-place --ignore E309 $^
108-
109-
# A command to automatically run astyle and autopep8 on appropriate files
110-
## format : check/fix all code indentation and formatting (runs autopep8)
111-
format: autopep8
112-
# Do nothing
94+
## format : check/fix all code indentation and formatting (runs black)
95+
format:
96+
black --exclude cwltool/schemas setup.py cwltool.py cwltool tests
11397

11498
## pylint : run static code analysis on Python code
11599
pylint: $(PYSOURCES)
@@ -143,8 +127,8 @@ coverage-report: .coverage
143127
diff-cover: coverage.xml
144128
diff-cover $^
145129

146-
diff-cover.html: coverage.xml
147-
diff-cover $^ --html-report diff-cover.html
130+
diff-cover.html: coverage.xml
131+
diff-cover $^ --html-report $@
148132

149133
## test : run the ${MODULE} test suite
150134
test: $(pysources)
@@ -165,18 +149,14 @@ list-author-emails:
165149
@echo 'name, E-Mail Address'
166150
@git log --format='%aN,%aE' | sort -u | grep -v 'root'
167151

168-
mypy2: ${PYSOURCES}
169-
rm -Rf typeshed/2and3/ruamel/yaml
170-
ln -s $(shell python -c 'from __future__ import print_function; import ruamel.yaml; import os.path; print(os.path.dirname(ruamel.yaml.__file__))') \
171-
typeshed/2and3/ruamel/yaml
172-
MYPYPATH=$$MYPYPATH:typeshed/2.7:typeshed/2and3 mypy --py2 --disallow-untyped-calls \
173-
--warn-redundant-casts \
174-
cwltool
175-
176-
mypy3: ${PYSOURCES}
177-
rm -Rf typeshed/2and3/ruamel/yaml
178-
ln -s $(shell python3 -c 'from __future__ import print_function; import ruamel.yaml; import os.path; print(os.path.dirname(ruamel.yaml.__file__))') \
179-
typeshed/2and3/ruamel/yaml
152+
mypy3: mypy
153+
mypy: ${PYSOURCES}
154+
if ! test -f $(shell python3 -c 'import ruamel.yaml; import os.path; print(os.path.dirname(ruamel.yaml.__file__))')/py.typed ; \
155+
then \
156+
rm -Rf typeshed/2and3/ruamel/yaml ; \
157+
ln -s $(shell python3 -c 'import ruamel.yaml; import os.path; print(os.path.dirname(ruamel.yaml.__file__))') \
158+
typeshed/2and3/ruamel/ ; \
159+
fi # if minimally required ruamel.yaml version is 0.15.99 or greater, than the above can be removed
180160
MYPYPATH=$$MYPYPATH:typeshed/3:typeshed/2and3 mypy --disallow-untyped-calls \
181161
--warn-redundant-casts \
182162
cwltool

README.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ intended to be feature complete and provide comprehensive validation of CWL
7575
files as well as provide other tools related to working with CWL.
7676

7777
This is written and tested for
78-
`Python <https://www.python.org/>`_ ``2.7 and 3.x {x = 5, 6, 7, 8}``
78+
`Python <https://www.python.org/>`_ ``3.x {x = 5, 6, 7, 8}``
7979

8080
The reference implementation consists of two packages. The ``cwltool`` package
8181
is the primary Python module containing the reference implementation in the
@@ -100,7 +100,7 @@ it is recommended to do the following:
100100

101101
.. code:: bash
102102
103-
virtualenv -p python2 venv # Create a virtual environment, can use `python3` as well
103+
virtualenv -p python3 venv # Create a virtual environment
104104
source venv/bin/activate # Activate environment before installing `cwltool`
105105
106106
Installing the official package from PyPi (will install "cwltool" package as

appveyor.yml

-4
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,6 @@ environment:
88
SYSTEMROOT: "C:\\WINDOWS"
99

1010
matrix:
11-
- PYTHON: "C:\\Python27-x64"
12-
PYTHON_VERSION: "2.7.x"
13-
PYTHON_ARCH: "64"
14-
1511
- PYTHON: "C:\\Python35-x64"
1612
PYTHON_VERSION: "3.5.x"
1713
PYTHON_ARCH: "64"

cwlref-runner/setup.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#!/usr/bin/env python
2-
from __future__ import absolute_import
32
import os
43

54
from setuptools import setup, find_packages

cwltool.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
#!/usr/bin/env python
2-
from __future__ import absolute_import
1+
#!/usr/bin/env python3
32
"""Convenience entry point for cwltool.
43
54
This can be used instead of the recommended method of `./setup.py install`

cwltool/__init__.py

+2-14
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,5 @@
11
"""Reference implementation of the CWL standards."""
2-
from __future__ import absolute_import
3-
import warnings
42
import sys
5-
__author__ = '[email protected]'
6-
7-
class CWLToolDeprecationWarning(Warning):
8-
pass
3+
import warnings
94

10-
# Hate this?
11-
# set PYTHONWARNINGS=ignore:DEPRECATION::cwltool.__init__
12-
if sys.version_info < (3, 0):
13-
warnings.warn("""
14-
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020.
15-
Please upgrade your Python as the Python 2.7 version of cwltool won't be
16-
maintained after that date.
17-
""", category=CWLToolDeprecationWarning)
5+
__author__ = "[email protected]"

cwltool/__main__.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
"""Default entrypoint for the cwltool module."""
2-
from __future__ import absolute_import
32

43
from . import main
54

0 commit comments

Comments
 (0)