Skip to content

Commit f43c843

Browse files
committed
Fix pylint/mypy
* minimal `setup.py` unification * fix build-wheels.sh Signed-off-by: Aleksei Stepanov <penguinolog@gmail.com>
1 parent fd6937a commit f43c843

File tree

9 files changed

+60
-57
lines changed

9 files changed

+60
-57
lines changed

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
/assets/*
66
.cache/*
77
.pytest_cache/*
8-
/pip-wheel-metadata
9-
### Versioning
8+
9+
### Generated version
1010
/exec_helpers/_version.py
1111

1212
### Generated code

.travis.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
sudo: false
21
language: python
32
os: linux
3+
dist: xenial
4+
sudo: true
5+
46
install:
57
- &upgrade_python_toolset pip install --upgrade pip setuptools wheel
68
- &install_test_deps pip install --upgrade asynctest mock pytest pytest-mock pytest-asyncio pytest-sugar
@@ -14,8 +16,6 @@ _python:
1416
- &python37
1517
name: "Python 3.7"
1618
python: "3.7"
17-
dist: xenial
18-
sudo: true
1919

2020
_helpers:
2121
- &install_cython pip install --upgrade Cython

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@
186186
same "printed page" as the copyright notice for easier
187187
identification within third-party archives.
188188

189-
Copyright {yyyy} {name of copyright owner}
189+
Copyright 2016-2019 Alexey Stepanov aka penguinolog
190190

191191
Licensed under the Apache License, Version 2.0 (the "License");
192192
you may not use this file except in compliance with the License.

MANIFEST.in

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
include *.rst LICENSE requirements.txt pyproject.toml
1+
include *.rst LICENSE requirements.txt
2+
global-include *.pyx *.pxd
23
global-exclude *.c
34
exclude Makefile
45
prune tools

doc/source/conf.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
release = pkg_resources.get_distribution("exec-helpers").version
1919
version = '.'.join(release.split('.')[:2])
2020

21-
2221
# If extensions (or modules to document with autodoc) are in another directory,
2322
# add these directories to sys.path here. If the directory is relative to the
2423
# documentation root, use os.path.abspath to make it absolute, like shown here.

setup.cfg

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ project_urls =
44
Bug Tracker = https://github.com/python-useful-helpers/exec-helpers/issues
55
Documentation = https://exec-helpers.readthedocs.io/
66

7+
long_description = file: README.rst
78

89
[options]
910
zip_safe = False
@@ -23,9 +24,6 @@ all_files = 1
2324
build-dir = doc/build
2425
source-dir = doc/source
2526

26-
[upload_sphinx]
27-
upload-dir = doc/build/html
28-
2927
[flake8]
3028
exclude =
3129
.venv,

setup.py

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,8 @@
1616

1717
"""Execution helpers for simplified usage of subprocess and ssh."""
1818

19-
from __future__ import absolute_import
20-
from __future__ import division
21-
from __future__ import print_function
22-
from __future__ import unicode_literals
23-
2419
# Standard Library
2520
import ast
26-
import collections
2721
import distutils.errors
2822
import os.path
2923
import shutil
@@ -33,13 +27,22 @@
3327
# External Dependencies
3428
import setuptools
3529

30+
try:
31+
import typing
32+
except ImportError:
33+
typing = None
34+
35+
3636
try:
3737
# noinspection PyPackageRequirements
3838
from Cython.Build import cythonize
3939
except ImportError:
4040
cythonize = None
4141

42-
with open(os.path.join(os.path.dirname(__file__), "exec_helpers", "__init__.py")) as f:
42+
43+
PACKAGE_NAME = "exec_helpers"
44+
45+
with open(os.path.join(os.path.dirname(__file__), PACKAGE_NAME, "__init__.py")) as f:
4346
SOURCE = f.read()
4447

4548
with open("requirements.txt") as f:
@@ -111,14 +114,13 @@ def run(self):
111114
root_dir = os.path.abspath(os.path.join(__file__, ".."))
112115
target_dir = build_dir if not self.inplace else root_dir
113116

114-
src_files = (os.path.join("exec_helpers", "__init__.py"),)
117+
src_file = os.path.join(PACKAGE_NAME, "__init__.py")
115118

116-
for src_file in src_files:
117-
src = os.path.join(root_dir, src_file)
118-
dst = os.path.join(target_dir, src_file)
119+
src = os.path.join(root_dir, src_file)
120+
dst = os.path.join(target_dir, src_file)
119121

120-
if src != dst:
121-
shutil.copyfile(src, dst)
122+
if src != dst:
123+
shutil.copyfile(src, dst)
122124
except (
123125
distutils.errors.DistutilsPlatformError,
124126
getattr(globals()["__builtins__"], "FileNotFoundError", OSError),
@@ -142,7 +144,9 @@ def build_extension(self, ext):
142144

143145

144146
# noinspection PyUnresolvedReferences
145-
def get_simple_vars_from_src(src):
147+
def get_simple_vars_from_src(
148+
src: str
149+
) -> "typing.Dict[str, typing.Union[str, bytes, int, float, complex, list, set, dict, tuple, None, bool, Ellipsis]]":
146150
"""Get simple (string/number/boolean and None) assigned values from source.
147151
148152
:param src: Source code
@@ -167,26 +171,24 @@ def get_simple_vars_from_src(src):
167171
168172
>>> string_sample = "a = '1'"
169173
>>> get_simple_vars_from_src(string_sample)
170-
OrderedDict([('a', '1')])
174+
{'a': '1'}
171175
172176
>>> int_sample = "b = 1"
173177
>>> get_simple_vars_from_src(int_sample)
174-
OrderedDict([('b', 1)])
178+
{'b': 1}
175179
176180
>>> list_sample = "c = [u'1', b'1', 1, 1.0, 1j, None]"
177181
>>> result = get_simple_vars_from_src(list_sample)
178-
>>> result == collections.OrderedDict(
179-
... [('c', [u'1', b'1', 1, 1.0, 1j, None])]
180-
... )
182+
>>> result == {'c': [u'1', b'1', 1, 1.0, 1j, None]}
181183
True
182184
183185
>>> iterable_sample = "d = ([1], {1: 1}, {1})"
184186
>>> get_simple_vars_from_src(iterable_sample)
185-
OrderedDict([('d', ([1], {1: 1}, {1}))])
187+
{'d': ([1], {1: 1}, {1})}
186188
187189
>>> multiple_assign = "e = f = g = 1"
188190
>>> get_simple_vars_from_src(multiple_assign)
189-
OrderedDict([('e', 1), ('f', 1), ('g', 1)])
191+
{'e': 1, 'f': 1, 'g': 1}
190192
"""
191193
if sys.version_info[:2] < (3, 8):
192194
ast_data = (ast.Str, ast.Num, ast.List, ast.Set, ast.Dict, ast.Tuple, ast.Bytes, ast.NameConstant, ast.Ellipsis)
@@ -195,7 +197,7 @@ def get_simple_vars_from_src(src):
195197

196198
tree = ast.parse(src)
197199

198-
result = collections.OrderedDict()
200+
result = {}
199201

200202
for node in ast.iter_child_nodes(tree):
201203
if not isinstance(node, ast.Assign): # We parse assigns only
@@ -247,7 +249,7 @@ def get_simple_vars_from_src(src):
247249
long_description=LONG_DESCRIPTION,
248250
classifiers=CLASSIFIERS,
249251
keywords=KEYWORDS,
250-
python_requires=">=3.6",
252+
python_requires=">=3.6.0",
251253
# While setuptools cannot deal with pre-installed incompatible versions,
252254
# setting a lower bound is not harmful - it makes error messages cleaner. DO
253255
# NOT set an upper bound on setuptools, as that will lead to uninstallable
@@ -269,7 +271,7 @@ def get_simple_vars_from_src(src):
269271
"all_formats": XML_DEPS + LXML_DEPS + YAML_DEPS,
270272
"all-formats": XML_DEPS + LXML_DEPS + YAML_DEPS,
271273
},
272-
package_data={"exec_helpers": ["py.typed"]},
274+
package_data={PACKAGE_NAME: ["py.typed"]},
273275
)
274276
if cythonize is not None:
275277
SETUP_ARGS["ext_modules"] = EXT_MODULES

tools/build-wheels.sh

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,24 @@ then
1212
exit 1
1313
fi
1414

15-
arch=`uname -m`
15+
arch=$(uname -m)
1616

1717
# Clean-up
1818
rm -rf /io/.tox
1919
rm -rf /io/*.egg-info
2020
rm -rf /io/.pytest_cache
21-
find -name *.py[co] -delete
21+
find /io/ -noleaf -name *.py[co] -delete
2222

2323
echo
2424
echo
2525
echo "Compile wheels"
2626
for PYTHON in ${PYTHON_VERSIONS}; do
27-
/opt/python/${PYTHON}/bin/pip install -U pip setuptools wheel
28-
/opt/python/${PYTHON}/bin/pip install -r /io/build_requirements.txt
29-
/opt/python/${PYTHON}/bin/pip wheel /io/ -w /io/dist/
27+
/opt/python/"${PYTHON}"/bin/pip install -U pip setuptools wheel
28+
/opt/python/"${PYTHON}"/bin/pip install -r /io/build_requirements.txt
29+
/opt/python/"${PYTHON}"/bin/pip wheel /io/ -w /io/dist/
3030
cd /io
31-
/opt/python/${PYTHON}/bin/python setup.py bdist_wheel
32-
/opt/python/${PYTHON}/bin/python setup.py clean
31+
/opt/python/"${PYTHON}"/bin/python setup.py bdist_wheel
32+
/opt/python/"${PYTHON}"/bin/python setup.py clean
3333
done
3434

3535
echo
@@ -52,22 +52,22 @@ ls /io/dist
5252
for PYTHON in ${PYTHON_VERSIONS}; do
5353
echo
5454
echo -n "Test $PYTHON: $package_name "
55-
/opt/python/${PYTHON}/bin/python -c "import platform;print(platform.platform())"
56-
/opt/python/${PYTHON}/bin/pip install "$package_name" --no-index -f file:///io/dist
57-
/opt/python/${PYTHON}/bin/pip install asynctest pytest pytest-asyncio pytest-mock
58-
/opt/python/${PYTHON}/bin/py.test -vvv /io/test
55+
/opt/python/"${PYTHON}"/bin/python -c "import platform;print(platform.platform())"
56+
/opt/python/"${PYTHON}"/bin/pip install "$package_name" --no-index -f file:///io/dist
57+
/opt/python/"${PYTHON}"/bin/pip install pytest
58+
/opt/python/"${PYTHON}"/bin/py.test -vvv /io/test
5959
done
6060

61-
find /io/dist/ -type f -not -name "*$package_name*" -delete
61+
find /io/dist/ -noleaf -type f -not -name "*$package_name*" -delete
6262
rm -rf /io/.eggs
6363
rm -rf /io/build
6464
rm -rf /io/*.egg-info
6565
rm -rf /io/.pytest_cache
6666
rm -rf /io/.tox
6767
rm -f /io/.coverage
6868
# Clean caches and cythonized
69-
find -name *.py[co] -delete
70-
find -name *.c -delete
69+
find /io/ -noleaf -name *.py[co] -delete
70+
find /io/ -noleaf -name *.c -delete
7171
# Reset permissions
7272
chmod -v a+rwx /io/dist
7373
chmod -v a+rw /io/dist/*

tox.ini

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ commands = {posargs:}
5757
deps =
5858
flake8
5959
flake8-bugbear
60-
6160
commands = flake8
6261

6362
[testenv:pep257]
@@ -89,22 +88,27 @@ deps =
8988
sphinx
9089
commands = python setup.py build_sphinx
9190

91+
[testenv:readme]
92+
deps =
93+
readme-renderer
94+
commands = python setup.py check -r -s
95+
9296
[testenv:bandit]
9397
deps = bandit
9498
commands = bandit -r exec_helpers
9599

96-
[testenv:black]
97-
deps =
98-
black
99-
commands =
100-
black exec_helpers
101-
102100
[testenv:dep-graph]
103101
deps =
104102
.
105103
pipdeptree
106104
commands = pipdeptree
107105

106+
[testenv:black]
107+
deps =
108+
black
109+
commands =
110+
black exec_helpers
111+
108112
[testenv:mypy]
109113
deps =
110114
mypy>=0.720
@@ -113,7 +117,6 @@ commands =
113117
python setup.py --version
114118
mypy --strict --xslt-html-report mypy_report -p exec_helpers
115119

116-
117120
[testenv:isort]
118121
deps =
119122
isort[pyproject,requirements]

0 commit comments

Comments
 (0)