From 4f071a4a546f0229dbe822b760ba8432377aaa84 Mon Sep 17 00:00:00 2001 From: "Ezequiel (Ezekiel) Brizuela" Date: Fri, 3 Jan 2020 21:36:13 -0300 Subject: [PATCH 1/4] Moving all config that we can to pyproject.toml --- bandit.yml | 399 ------------------------------------------- ci/templates/tox.ini | 5 +- pyproject.toml | 3 +- pytest.ini | 26 +++ requirements-dev.txt | 14 +- setup.cfg | 44 ----- tox.ini | 3 - 7 files changed, 37 insertions(+), 457 deletions(-) delete mode 100644 bandit.yml create mode 100644 pytest.ini diff --git a/bandit.yml b/bandit.yml deleted file mode 100644 index 67e95e5..0000000 --- a/bandit.yml +++ /dev/null @@ -1,399 +0,0 @@ - -### Bandit config file generated from: -# '/home/qlixed/srced/python-memwiper/bin/bandit-config-generator -o bandit.yml' - -### This config may optionally select a subset of tests to run or skip by -### filling out the 'tests' and 'skips' lists given below. If no tests are -### specified for inclusion then it is assumed all tests are desired. The skips -### set will remove specific tests from the include set. This can be controlled -### using the -t/-s CLI options. Note that the same test ID should not appear -### in both 'tests' and 'skips', this would be nonsensical and is detected by -### Bandit at runtime. - -# Available tests: -# B101 : assert_used -# B102 : exec_used -# B103 : set_bad_file_permissions -# B104 : hardcoded_bind_all_interfaces -# B105 : hardcoded_password_string -# B106 : hardcoded_password_funcarg -# B107 : hardcoded_password_default -# B108 : hardcoded_tmp_directory -# B110 : try_except_pass -# B112 : try_except_continue -# B201 : flask_debug_true -# B301 : pickle -# B302 : marshal -# B303 : md5 -# B304 : ciphers -# B305 : cipher_modes -# B306 : mktemp_q -# B307 : eval -# B308 : mark_safe -# B309 : httpsconnection -# B310 : urllib_urlopen -# B311 : random -# B312 : telnetlib -# B313 : xml_bad_cElementTree -# B314 : xml_bad_ElementTree -# B315 : xml_bad_expatreader -# B316 : xml_bad_expatbuilder -# B317 : xml_bad_sax -# B318 : xml_bad_minidom -# B319 : xml_bad_pulldom -# B320 : xml_bad_etree -# B321 : ftplib -# B322 : input -# B323 : unverified_context -# B324 : hashlib_new_insecure_functions -# B325 : tempnam -# B401 : import_telnetlib -# B402 : import_ftplib -# B403 : import_pickle -# B404 : import_subprocess -# B405 : import_xml_etree -# B406 : import_xml_sax -# B407 : import_xml_expat -# B408 : import_xml_minidom -# B409 : import_xml_pulldom -# B410 : import_lxml -# B411 : import_xmlrpclib -# B412 : import_httpoxy -# B413 : import_pycrypto -# B501 : request_with_no_cert_validation -# B502 : ssl_with_bad_version -# B503 : ssl_with_bad_defaults -# B504 : ssl_with_no_version -# B505 : weak_cryptographic_key -# B506 : yaml_load -# B507 : ssh_no_host_key_verification -# B601 : paramiko_calls -# B602 : subprocess_popen_with_shell_equals_true -# B603 : subprocess_without_shell_equals_true -# B604 : any_other_function_with_shell_equals_true -# B605 : start_process_with_a_shell -# B606 : start_process_with_no_shell -# B607 : start_process_with_partial_path -# B608 : hardcoded_sql_expressions -# B609 : linux_commands_wildcard_injection -# B610 : django_extra_used -# B611 : django_rawsql_used -# B701 : jinja2_autoescape_false -# B702 : use_of_mako_templates -# B703 : django_mark_safe - -# (optional) list included test IDs here, eg '[B101, B406]': -tests: - -# (optional) list skipped test IDs here, eg '[B101, B406]': -# B404:blacklist - subprocess -# B603:subprocess_without_shell_equals_true -skips: ['B404', 'B603'] - -### (optional) plugin settings - some test plugins require configuration data -### that may be given here, per-plugin. All bandit test plugins have a built in -### set of sensible defaults and these will be used if no configuration is -### provided. It is not necessary to provide settings for every (or any) plugin -### if the defaults are acceptable. - -any_other_function_with_shell_equals_true: - no_shell: - - os.execl - - os.execle - - os.execlp - - os.execlpe - - os.execv - - os.execve - - os.execvp - - os.execvpe - - os.spawnl - - os.spawnle - - os.spawnlp - - os.spawnlpe - - os.spawnv - - os.spawnve - - os.spawnvp - - os.spawnvpe - - os.startfile - shell: - - os.system - - os.popen - - os.popen2 - - os.popen3 - - os.popen4 - - popen2.popen2 - - popen2.popen3 - - popen2.popen4 - - popen2.Popen3 - - popen2.Popen4 - - commands.getoutput - - commands.getstatusoutput - subprocess: - - subprocess.Popen - - subprocess.call - - subprocess.check_call - - subprocess.check_output - - subprocess.run -hardcoded_tmp_directory: - tmp_dirs: - - /tmp - - /var/tmp - - /dev/shm -linux_commands_wildcard_injection: - no_shell: - - os.execl - - os.execle - - os.execlp - - os.execlpe - - os.execv - - os.execve - - os.execvp - - os.execvpe - - os.spawnl - - os.spawnle - - os.spawnlp - - os.spawnlpe - - os.spawnv - - os.spawnve - - os.spawnvp - - os.spawnvpe - - os.startfile - shell: - - os.system - - os.popen - - os.popen2 - - os.popen3 - - os.popen4 - - popen2.popen2 - - popen2.popen3 - - popen2.popen4 - - popen2.Popen3 - - popen2.Popen4 - - commands.getoutput - - commands.getstatusoutput - subprocess: - - subprocess.Popen - - subprocess.call - - subprocess.check_call - - subprocess.check_output - - subprocess.run -ssl_with_bad_defaults: - bad_protocol_versions: - - PROTOCOL_SSLv2 - - SSLv2_METHOD - - SSLv23_METHOD - - PROTOCOL_SSLv3 - - PROTOCOL_TLSv1 - - SSLv3_METHOD - - TLSv1_METHOD -ssl_with_bad_version: - bad_protocol_versions: - - PROTOCOL_SSLv2 - - SSLv2_METHOD - - SSLv23_METHOD - - PROTOCOL_SSLv3 - - PROTOCOL_TLSv1 - - SSLv3_METHOD - - TLSv1_METHOD -start_process_with_a_shell: - no_shell: - - os.execl - - os.execle - - os.execlp - - os.execlpe - - os.execv - - os.execve - - os.execvp - - os.execvpe - - os.spawnl - - os.spawnle - - os.spawnlp - - os.spawnlpe - - os.spawnv - - os.spawnve - - os.spawnvp - - os.spawnvpe - - os.startfile - shell: - - os.system - - os.popen - - os.popen2 - - os.popen3 - - os.popen4 - - popen2.popen2 - - popen2.popen3 - - popen2.popen4 - - popen2.Popen3 - - popen2.Popen4 - - commands.getoutput - - commands.getstatusoutput - subprocess: - - subprocess.Popen - - subprocess.call - - subprocess.check_call - - subprocess.check_output - - subprocess.run -start_process_with_no_shell: - no_shell: - - os.execl - - os.execle - - os.execlp - - os.execlpe - - os.execv - - os.execve - - os.execvp - - os.execvpe - - os.spawnl - - os.spawnle - - os.spawnlp - - os.spawnlpe - - os.spawnv - - os.spawnve - - os.spawnvp - - os.spawnvpe - - os.startfile - shell: - - os.system - - os.popen - - os.popen2 - - os.popen3 - - os.popen4 - - popen2.popen2 - - popen2.popen3 - - popen2.popen4 - - popen2.Popen3 - - popen2.Popen4 - - commands.getoutput - - commands.getstatusoutput - subprocess: - - subprocess.Popen - - subprocess.call - - subprocess.check_call - - subprocess.check_output - - subprocess.run -start_process_with_partial_path: - no_shell: - - os.execl - - os.execle - - os.execlp - - os.execlpe - - os.execv - - os.execve - - os.execvp - - os.execvpe - - os.spawnl - - os.spawnle - - os.spawnlp - - os.spawnlpe - - os.spawnv - - os.spawnve - - os.spawnvp - - os.spawnvpe - - os.startfile - shell: - - os.system - - os.popen - - os.popen2 - - os.popen3 - - os.popen4 - - popen2.popen2 - - popen2.popen3 - - popen2.popen4 - - popen2.Popen3 - - popen2.Popen4 - - commands.getoutput - - commands.getstatusoutput - subprocess: - - subprocess.Popen - - subprocess.call - - subprocess.check_call - - subprocess.check_output - - subprocess.run -subprocess_popen_with_shell_equals_true: - no_shell: - - os.execl - - os.execle - - os.execlp - - os.execlpe - - os.execv - - os.execve - - os.execvp - - os.execvpe - - os.spawnl - - os.spawnle - - os.spawnlp - - os.spawnlpe - - os.spawnv - - os.spawnve - - os.spawnvp - - os.spawnvpe - - os.startfile - shell: - - os.system - - os.popen - - os.popen2 - - os.popen3 - - os.popen4 - - popen2.popen2 - - popen2.popen3 - - popen2.popen4 - - popen2.Popen3 - - popen2.Popen4 - - commands.getoutput - - commands.getstatusoutput - subprocess: - - subprocess.Popen - - subprocess.call - - subprocess.check_call - - subprocess.check_output - - subprocess.run -subprocess_without_shell_equals_true: - no_shell: - - os.execl - - os.execle - - os.execlp - - os.execlpe - - os.execv - - os.execve - - os.execvp - - os.execvpe - - os.spawnl - - os.spawnle - - os.spawnlp - - os.spawnlpe - - os.spawnv - - os.spawnve - - os.spawnvp - - os.spawnvpe - - os.startfile - shell: - - os.system - - os.popen - - os.popen2 - - os.popen3 - - os.popen4 - - popen2.popen2 - - popen2.popen3 - - popen2.popen4 - - popen2.Popen3 - - popen2.Popen4 - - commands.getoutput - - commands.getstatusoutput - subprocess: - - subprocess.Popen - - subprocess.call - - subprocess.check_call - - subprocess.check_output - - subprocess.run -try_except_continue: - check_typed_exception: false -try_except_pass: - check_typed_exception: false -weak_cryptographic_key: - weak_key_size_dsa_high: 1024 - weak_key_size_dsa_medium: 2048 - weak_key_size_ec_high: 160 - weak_key_size_ec_medium: 224 - weak_key_size_rsa_high: 1024 - weak_key_size_rsa_medium: 2048 - diff --git a/ci/templates/tox.ini b/ci/templates/tox.ini index 5d0bb3c..a01b456 100644 --- a/ci/templates/tox.ini +++ b/ci/templates/tox.ini @@ -8,9 +8,6 @@ envlist = {% endfor %} report -[pytest] -testpaths = tests - [testenv] basepython = docs: {env:TOXPYTHON:python3} @@ -52,7 +49,7 @@ commands = black src tests setup.py flake8 src tests setup.py isort --verbose --check-only --diff --recursive src tests setup.py - bandit -c bandit.yml -r src + bandit [testenv:docs] usedevelop = true diff --git a/pyproject.toml b/pyproject.toml index 9ec322b..63429ac 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -43,7 +43,8 @@ classifiers = [ requires = ["setuptools", "wheel"] # PEP 508 specifications. [tool.black] -line-length = 79 +line-length = 88 +target-version= ['py36', 'py37', 'py38', ] include = '\.pyi?$' exclude = ''' /( diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 0000000..b31688c --- /dev/null +++ b/pytest.ini @@ -0,0 +1,26 @@ +[pytest] +norecursedirs = + .git + .tox + .env + .ropeproject + dist + build + migrations +python_files = + test_*.py + *_test.py + tests.py +addopts = + -ra + --strict + --ignore=docs/conf.py + --ignore=setup.py + --ignore=ci + --ignore=.eggs + --doctest-modules + --doctest-glob=\*.rst + --tb=short +testpaths = + tests + diff --git a/requirements-dev.txt b/requirements-dev.txt index 4077b2e..9561eb0 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,11 +1,13 @@ +bandit +black bumpversion +codacy-coverage +coveralls +codecov pytest +pytest-bandit +pytest-black pytest-cov pytest-faulthandler -tox requires.io -jedi -black -codacy-coverage -coveralls -codecov +tox diff --git a/setup.cfg b/setup.cfg index 8e9b528..e1bdfea 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,7 +1,3 @@ -[flake8] -max-line-length = 140 -exclude = */migrations/* - [options] # tests_require is a list of dependencies that are *absolutely required* # to run the tests. tests_require is used when running tests from your @@ -27,46 +23,6 @@ tests_require = pytest # Alias `setup.py test` to `setup.py pytest` test = pytest -[tool:pytest] -# If a pytest section is found in one of the possible config files -# (pytest.ini, tox.ini or setup.cfg), then pytest will not look for any others, -# so if you add a pytest config section elsewhere, -# you will need to delete this section from setup.cfg. -norecursedirs = - .git - .tox - .env - .ropeproject - dist - build - migrations - -python_files = - test_*.py - *_test.py - tests.py -addopts = - -ra - --strict - --ignore=docs/conf.py - --ignore=setup.py - --ignore=ci - --ignore=.eggs - --doctest-modules - --doctest-glob=\*.rst - --tb=short -testpaths = - tests - -[tool:isort] -force_single_line = True -line_length = 120 -known_first_party = memwiper -default_section = THIRDPARTY -forced_separate = test_memwiper -not_skip = __init__.py -skip = migrations - [matrix] # This is the configuration for the `./bootstrap.py` script. # It generates `.travis.yml`, `tox.ini` and `.appveyor.yml`. diff --git a/tox.ini b/tox.ini index 3d03b8e..f17a410 100644 --- a/tox.ini +++ b/tox.ini @@ -13,9 +13,6 @@ envlist = py38-nocov, report -[pytest] -testpaths = tests - [testenv] basepython = docs: {env:TOXPYTHON:python3} From e8201f9c0cea3e2d44b6ad4f3fcd1d3f8567e69c Mon Sep 17 00:00:00 2001 From: "Ezequiel (Ezekiel) Brizuela" Date: Sat, 4 Jan 2020 01:39:51 -0300 Subject: [PATCH 2/4] Moving more config stuff around --- .coveragerc | 15 --------------- .readthedocs.yml | 4 ---- MANIFEST.in | 8 +++----- ci/templates/tox.ini | 1 + flake8.ini | 1 + pyproject.toml | 15 +++++++++++++++ readthedocs.yml | 5 +++++ setup.py | 20 +++++--------------- src/memwiper/utils/__init__.py | 4 +--- src/memwiper/utils/_coretest.py | 8 ++------ tests/test_memwiper.py | 3 +-- tests/test_memwiper_utils.py | 4 +--- tox.ini | 3 ++- 13 files changed, 37 insertions(+), 54 deletions(-) delete mode 100644 .coveragerc delete mode 100644 .readthedocs.yml create mode 120000 flake8.ini create mode 100644 readthedocs.yml diff --git a/.coveragerc b/.coveragerc deleted file mode 100644 index cc97ba4..0000000 --- a/.coveragerc +++ /dev/null @@ -1,15 +0,0 @@ -[paths] -source = src - -[run] -branch = true -source = - src - tests -parallel = true -omit = src/memwiper/utils/_coretest.py - -[report] -show_missing = true -precision = 2 -omit = *migrations* diff --git a/.readthedocs.yml b/.readthedocs.yml deleted file mode 100644 index 13d27cc..0000000 --- a/.readthedocs.yml +++ /dev/null @@ -1,4 +0,0 @@ -requirements_file: docs/requirements.txt -python: - version: 3.5 - diff --git a/MANIFEST.in b/MANIFEST.in index 237feb0..6483adc 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -4,15 +4,13 @@ graft ci graft tests include .bumpversion.cfg -include .coveragerc include .cookiecutterrc include .editorconfig -include .isort.cfg -include .readthedocs.yml include .flake8 -include bandit.yml -include pyproject.toml include codecov.yml +include pytest.ini +include pyproject.toml +include readthedocs.yml include AUTHORS.rst diff --git a/ci/templates/tox.ini b/ci/templates/tox.ini index a01b456..5be337d 100644 --- a/ci/templates/tox.ini +++ b/ci/templates/tox.ini @@ -20,6 +20,7 @@ passenv = deps = pytest pytest-travis-fold + coverage[toml] commands = python setup.py clean --all build_ext --force --inplace {posargs:pytest -vv --ignore=src} diff --git a/flake8.ini b/flake8.ini new file mode 120000 index 0000000..75610e8 --- /dev/null +++ b/flake8.ini @@ -0,0 +1 @@ +.flake8 \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 63429ac..5c7fbc7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -59,3 +59,18 @@ exclude = ''' | dist )/ ''' + +[tool.coverage.paths] +source = ['src'] + +[tool.coverage.run] +branch = true +source = ['src', 'tests'] +parallel = true +omit = ['src/memwiper/utils/_coretest.py'] + +[tool.coverage.report] +show_missing = true +precision = 2 +omit = ['*migrations*'] + diff --git a/readthedocs.yml b/readthedocs.yml new file mode 100644 index 0000000..27794c0 --- /dev/null +++ b/readthedocs.yml @@ -0,0 +1,5 @@ +version: 2 +formats: all +python: + install: + - requirements: docs/requirements.txt diff --git a/setup.py b/setup.py index eb218ce..e639c4d 100644 --- a/setup.py +++ b/setup.py @@ -1,27 +1,19 @@ #!/usr/bin/env python # -*- encoding: utf-8 -*- -from __future__ import absolute_import -from __future__ import print_function +from __future__ import absolute_import, print_function import io import os import re from glob import glob -from os.path import basename -from os.path import dirname -from os.path import join -from os.path import relpath -from os.path import splitext +from os.path import basename, dirname, join, relpath, splitext -from setuptools import Extension -from setuptools import find_packages -from setuptools import setup +from setuptools import Extension, find_packages, setup def read(*names, **kwargs): with io.open( - join(dirname(__file__), *names), - encoding=kwargs.get("encoding", "utf8"), + join(dirname(__file__), *names), encoding=kwargs.get("encoding", "utf8"), ) as fh: return fh.read() @@ -33,9 +25,7 @@ def read(*names, **kwargs): os.environ["CFLAGS"] = os.environ["SETUPPY_CFLAGS"] if "CFLAGS" in os.environ: - os.environ["CFLAGS"] = " ".join( - (os.environ["CFLAGS"], "-DMEMWIPER_DEBUG=1") - ) + os.environ["CFLAGS"] = " ".join((os.environ["CFLAGS"], "-DMEMWIPER_DEBUG=1")) else: os.environ["CFLAGS"] = "-DMEMWIPER_DEBUG=1" diff --git a/src/memwiper/utils/__init__.py b/src/memwiper/utils/__init__.py index 3963dbd..d80144c 100644 --- a/src/memwiper/utils/__init__.py +++ b/src/memwiper/utils/__init__.py @@ -1,6 +1,4 @@ -from memwiper.c_src.memwiper_utils import codepoints -from memwiper.c_src.memwiper_utils import kind -from memwiper.c_src.memwiper_utils import size +from memwiper.c_src.memwiper_utils import codepoints, kind, size __all__ = [ "kind", diff --git a/src/memwiper/utils/_coretest.py b/src/memwiper/utils/_coretest.py index 84f9090..2df52dc 100644 --- a/src/memwiper/utils/_coretest.py +++ b/src/memwiper/utils/_coretest.py @@ -67,9 +67,7 @@ def main(): # "Decoding" the file: s1 = codecs.encode(sfromfile, "rot_13") # Generating pre-core - print( - "Generating {f}.{pid}:".format(f=corefn.format(when="pre"), pid=mypid) - ) + print("Generating {f}.{pid}:".format(f=corefn.format(when="pre"), pid=mypid)) cmd = gdb_cmds corename = corefn.format(when="pre") print(cmd.format(filename=corename, pid=mypid)) @@ -77,9 +75,7 @@ def main(): print("Now we're going to overwrite the memory,") memwiper.wipeit(s1) # Generating pos-core - print( - "Generating {f}.{pid}:".format(f=corefn.format(when="pos"), pid=mypid) - ) + print("Generating {f}.{pid}:".format(f=corefn.format(when="pos"), pid=mypid)) corename = corefn.format(when="pos") print(cmd.format(filename=corename, pid=mypid)) subprocess.run(shlex.split(cmd.format(filename=corename, pid=mypid))) diff --git a/tests/test_memwiper.py b/tests/test_memwiper.py index b8567bd..0626d5e 100644 --- a/tests/test_memwiper.py +++ b/tests/test_memwiper.py @@ -1,6 +1,5 @@ -import pytest # noqa: F401 - import memwiper +import pytest def make_str(the_char, length): diff --git a/tests/test_memwiper_utils.py b/tests/test_memwiper_utils.py index 900814d..fc9717c 100644 --- a/tests/test_memwiper_utils.py +++ b/tests/test_memwiper_utils.py @@ -1,9 +1,7 @@ -import pytest # noqa: F401 - import memwiper.utils as mwutils +import pytest UNICODE_KIND = ["Wide Char", "1 Byte", "2 Byte", "4 Byte"] - UNICODE_WIDTH = {"1 Byte": 1, "2 Byte": 2, "4 Byte": 4} # AFAIK the Wide Char is only used as representation on diff --git a/tox.ini b/tox.ini index f17a410..4d3bd64 100644 --- a/tox.ini +++ b/tox.ini @@ -25,6 +25,7 @@ passenv = deps = pytest pytest-travis-fold + coverage[toml] commands = python setup.py clean --all build_ext --force --inplace {posargs:pytest -vv --ignore=src} @@ -54,7 +55,7 @@ commands = black src tests setup.py flake8 src tests setup.py isort --verbose --check-only --diff --recursive src tests setup.py - bandit -c bandit.yml -r src + bandit [testenv:docs] usedevelop = true From 6cb9b0b50218e045b28557ea8fffffe659196917 Mon Sep 17 00:00:00 2001 From: "Ezequiel (Ezekiel) Brizuela" Date: Sat, 4 Jan 2020 01:53:57 -0300 Subject: [PATCH 3/4] Changing flake8 filename config --- .flake8 | 5 ----- MANIFEST.in | 20 ++++++++++---------- ci/templates/tox.ini | 4 ++-- flake8.ini | 6 +++++- 4 files changed, 17 insertions(+), 18 deletions(-) delete mode 100644 .flake8 mode change 120000 => 100644 flake8.ini diff --git a/.flake8 b/.flake8 deleted file mode 100644 index a565cdf..0000000 --- a/.flake8 +++ /dev/null @@ -1,5 +0,0 @@ -[flake8] -ignore = E203, E231, E266, E501, W503, F403, F401 -max-line-length = 79 -max-complexity = 18 -select = B,C,E,F,W,T4,B9 diff --git a/MANIFEST.in b/MANIFEST.in index 6483adc..bca1421 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -3,26 +3,26 @@ graft src graft ci graft tests +include AUTHORS.rst include .bumpversion.cfg +include CHANGELOG.rst +include codecov.yml +include CONTRIBUTING.rst include .cookiecutterrc include .editorconfig include .flake8 -include codecov.yml +include flake8.ini +include LICENSE include pytest.ini include pyproject.toml -include readthedocs.yml - - -include AUTHORS.rst -include CHANGELOG.rst -include CONTRIBUTING.rst -include LICENSE include README.rst -include TODO.rst +include readthedocs.yml include requirements.txt include requirements-dev.txt +include TODO.rst +include tox.ini +include .travis.yml -include tox.ini .travis.yml prune __pycache__ prune .ropeproject diff --git a/ci/templates/tox.ini b/ci/templates/tox.ini index 5be337d..d7940e2 100644 --- a/ci/templates/tox.ini +++ b/ci/templates/tox.ini @@ -48,9 +48,9 @@ commands = python setup.py check --strict --metadata --restructuredtext check-manifest {toxinidir} black src tests setup.py - flake8 src tests setup.py + flake8 --config flake8.ini src tests setup.py isort --verbose --check-only --diff --recursive src tests setup.py - bandit + bandit src [testenv:docs] usedevelop = true diff --git a/flake8.ini b/flake8.ini deleted file mode 120000 index 75610e8..0000000 --- a/flake8.ini +++ /dev/null @@ -1 +0,0 @@ -.flake8 \ No newline at end of file diff --git a/flake8.ini b/flake8.ini new file mode 100644 index 0000000..a565cdf --- /dev/null +++ b/flake8.ini @@ -0,0 +1,5 @@ +[flake8] +ignore = E203, E231, E266, E501, W503, F403, F401 +max-line-length = 79 +max-complexity = 18 +select = B,C,E,F,W,T4,B9 From 91165bccf5faeb6ba19f32d377abb04003c9825d Mon Sep 17 00:00:00 2001 From: "Ezequiel (Ezekiel) Brizuela" Date: Sun, 5 Jan 2020 19:43:17 -0300 Subject: [PATCH 4/4] Cosmetic changes and more consolidation over pyproject.toml --- ci/appveyor-bootstrap.py | 1 + ci/appveyor-download.py | 2 +- ci/bootstrap.py | 10 ++------- ci/templates/tox.ini | 2 +- pyproject.toml | 40 +++++++++++++++++++++++---------- setup.py | 6 ++--- src/memwiper/utils/__init__.py | 2 +- src/memwiper/utils/_coretest.py | 8 +++---- tests/test_memwiper.py | 2 +- tests/test_memwiper_utils.py | 2 +- tox.ini | 4 ++-- 11 files changed, 45 insertions(+), 34 deletions(-) diff --git a/ci/appveyor-bootstrap.py b/ci/appveyor-bootstrap.py index d4d09dc..a82e7df 100644 --- a/ci/appveyor-bootstrap.py +++ b/ci/appveyor-bootstrap.py @@ -5,6 +5,7 @@ with various fixes and improvements that just weren't feasible to implement in PowerShell. """ from __future__ import print_function + from os import environ from os.path import exists from subprocess import check_call diff --git a/ci/appveyor-download.py b/ci/appveyor-download.py index c67ba4e..484674b 100755 --- a/ci/appveyor-download.py +++ b/ci/appveyor-download.py @@ -8,9 +8,9 @@ """ from __future__ import unicode_literals -import argparse import os import zipfile +import argparse import requests diff --git a/ci/bootstrap.py b/ci/bootstrap.py index 2d14d54..a2075c9 100755 --- a/ci/bootstrap.py +++ b/ci/bootstrap.py @@ -1,15 +1,10 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -from __future__ import absolute_import -from __future__ import print_function -from __future__ import unicode_literals +from __future__ import print_function, absolute_import, unicode_literals import os import sys -from os.path import abspath -from os.path import dirname -from os.path import exists -from os.path import join +from os.path import join, exists, abspath, dirname base_path = dirname(dirname(abspath(__file__))) @@ -90,4 +85,3 @@ def main(): else: print("Unexpected arguments {0}".format(args), file=sys.stderr) sys.exit(1) - diff --git a/ci/templates/tox.ini b/ci/templates/tox.ini index d7940e2..4804b12 100644 --- a/ci/templates/tox.ini +++ b/ci/templates/tox.ini @@ -50,7 +50,7 @@ commands = black src tests setup.py flake8 --config flake8.ini src tests setup.py isort --verbose --check-only --diff --recursive src tests setup.py - bandit src + bandit -r src [testenv:docs] usedevelop = true diff --git a/pyproject.toml b/pyproject.toml index 5c7fbc7..d6bd3fa 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -42,8 +42,16 @@ classifiers = [ [build-system] requires = ["setuptools", "wheel"] # PEP 508 specifications. + +# Tools: +# Enabled so far: +# - Black +# - coverage +# - isort +# + [tool.black] -line-length = 88 +line-length = 90 target-version= ['py36', 'py37', 'py38', ] include = '\.pyi?$' exclude = ''' @@ -60,17 +68,25 @@ exclude = ''' )/ ''' -[tool.coverage.paths] -source = ['src'] +[tool.coverage] + [[tool.coverage.paths]] + source = ['src'] -[tool.coverage.run] -branch = true -source = ['src', 'tests'] -parallel = true -omit = ['src/memwiper/utils/_coretest.py'] + [[tool.coverage.run]] + branch = true + source = ['src', 'tests'] + parallel = true + omit = ['src/memwiper/utils/_coretest.py'] -[tool.coverage.report] -show_missing = true -precision = 2 -omit = ['*migrations*'] + [[tool.coverage.report]] + show_missing = true + precision = 2 + omit = ['*migrations*'] +[tool.isort] +line_length = 120 +indent = ' ' +multi_line_output = 6 +length_sort = true +balanced_wrapping = true +known_first_party = ['memwiper'] diff --git a/setup.py b/setup.py index e639c4d..7c82d3d 100644 --- a/setup.py +++ b/setup.py @@ -1,14 +1,14 @@ #!/usr/bin/env python # -*- encoding: utf-8 -*- -from __future__ import absolute_import, print_function +from __future__ import print_function, absolute_import import io import os import re from glob import glob -from os.path import basename, dirname, join, relpath, splitext +from os.path import join, dirname, relpath, basename, splitext -from setuptools import Extension, find_packages, setup +from setuptools import Extension, setup, find_packages def read(*names, **kwargs): diff --git a/src/memwiper/utils/__init__.py b/src/memwiper/utils/__init__.py index d80144c..f8618fa 100644 --- a/src/memwiper/utils/__init__.py +++ b/src/memwiper/utils/__init__.py @@ -1,4 +1,4 @@ -from memwiper.c_src.memwiper_utils import codepoints, kind, size +from memwiper.c_src.memwiper_utils import kind, size, codepoints __all__ = [ "kind", diff --git a/src/memwiper/utils/_coretest.py b/src/memwiper/utils/_coretest.py index 2df52dc..21ae1d5 100644 --- a/src/memwiper/utils/_coretest.py +++ b/src/memwiper/utils/_coretest.py @@ -1,11 +1,11 @@ -import codecs -import getpass -import multiprocessing import os -import platform import shlex +import codecs import shutil +import getpass +import platform import subprocess +import multiprocessing from sys import exit as sysexit import memwiper diff --git a/tests/test_memwiper.py b/tests/test_memwiper.py index 0626d5e..9d9ee9d 100644 --- a/tests/test_memwiper.py +++ b/tests/test_memwiper.py @@ -1,5 +1,5 @@ -import memwiper import pytest +import memwiper def make_str(the_char, length): diff --git a/tests/test_memwiper_utils.py b/tests/test_memwiper_utils.py index fc9717c..b7eda8c 100644 --- a/tests/test_memwiper_utils.py +++ b/tests/test_memwiper_utils.py @@ -1,5 +1,5 @@ -import memwiper.utils as mwutils import pytest +import memwiper.utils as mwutils UNICODE_KIND = ["Wide Char", "1 Byte", "2 Byte", "4 Byte"] UNICODE_WIDTH = {"1 Byte": 1, "2 Byte": 2, "4 Byte": 4} diff --git a/tox.ini b/tox.ini index 4d3bd64..8768d98 100644 --- a/tox.ini +++ b/tox.ini @@ -53,9 +53,9 @@ commands = python setup.py check --strict --metadata --restructuredtext check-manifest {toxinidir} black src tests setup.py - flake8 src tests setup.py + flake8 --config flake8.ini src tests setup.py isort --verbose --check-only --diff --recursive src tests setup.py - bandit + bandit -r src [testenv:docs] usedevelop = true