diff --git a/.travis.yml b/.travis.yml index 91b611a..42df128 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,7 +2,7 @@ cache: false _tox: &tox install: - - pip3 install tox + - pip3 install tox tox-travis script: - tox @@ -17,6 +17,11 @@ jobs: script: - cd editors/emacs && emacs -batch -l ert -l gersemi.el -l gersemi-tests.el -f ert-run-tests-batch-and-exit + - language: python + os: linux + python: "3.6" + <<: *tox + - language: python os: linux python: "3.7" diff --git a/CHANGELOG.md b/CHANGELOG.md index 1af70b2..73139fd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,16 @@ # Changelog +## [0.5.0] 2020-08-25 + +### Added +- minor performance improvements +- support for Python 3.6 + +### Changed +- files are taken as input only once even if provided multiple times +- files are no longer overwritten if reformatting wouldn't lead to change of content +- dependency to `packaging` + ## [0.4.0] 2020-08-05 ### Added diff --git a/gersemi/__version__.py b/gersemi/__version__.py index 8895fd1..9946b73 100644 --- a/gersemi/__version__.py +++ b/gersemi/__version__.py @@ -4,4 +4,4 @@ __license__ = "MPL 2.0" __title__ = "gersemi" __url__ = "https://github.com/BlankSpruce/gersemi" -__version__ = "0.4.0" +__version__ = "0.5.0" diff --git a/setup.py b/setup.py index 9c9cac0..392d9ba 100644 --- a/setup.py +++ b/setup.py @@ -22,9 +22,9 @@ url=about["__url__"], packages=find_packages(include=["gersemi", "gersemi.*"]), package_data={"gersemi": ["cmake.lark", "builtin_commands"]}, - install_requires=["lark-parser>=0.8,<0.10", "pyyaml>=5,<6"], + install_requires=["dataclasses", "lark-parser>=0.8,<0.10", "pyyaml>=5,<6"], extras_requires=["colorama>=0.4"], - python_requires=">=3.7", + python_requires=">=3.6", entry_points={"console_scripts": ["gersemi = gersemi.__main__:main"]}, license=about["__license__"], classifiers=[ diff --git a/tests/test_executable.py b/tests/test_executable.py index fd6be0d..768d335 100644 --- a/tests/test_executable.py +++ b/tests/test_executable.py @@ -13,6 +13,9 @@ def gersemi(*gersemi_args, **subprocess_kwargs): return subprocess.run( [sys.executable, "-m", "gersemi", *gersemi_args], check=False, + encoding="utf8", + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, **subprocess_kwargs, ) @@ -161,18 +164,18 @@ def test_format_file_in_place(): def test_check_formatted_input_from_stdin(): inp = """set(FOO BAR) """ - assert_success("--check", "-", input=inp, text=True) + assert_success("--check", "-", input=inp) def test_check_not_formatted_input_from_stdin(): inp = """set(FOO BAR)""" # missing newline at the end - assert_fail("--check", "-", input=inp, text=True) + assert_fail("--check", "-", input=inp) def test_format_formatted_input_from_stdin(): inp = """set(FOO BAR) """ - completed_process = gersemi("-", input=inp, text=True, capture_output=True) + completed_process = gersemi("-", input=inp) assert completed_process.returncode == 0 assert completed_process.stdout == inp assert completed_process.stderr == "" @@ -181,7 +184,7 @@ def test_format_formatted_input_from_stdin(): def test_format_not_formatted_input_from_stdin(): inp = "set(FOO BAR)" # missing newline at the end - completed_process = gersemi("-", input=inp, text=True, capture_output=True) + completed_process = gersemi("-", input=inp) assert completed_process.returncode == 0 assert completed_process.stdout == inp + "\n" assert completed_process.stderr == "" @@ -302,7 +305,7 @@ def test_format_with_default_line_length(): inp = "set(FOO long_argument__________________________________________________________)" outp = inp + "\n" assert len(inp) == 80 - completed_process = gersemi("-", input=inp + "\n", text=True, capture_output=True) + completed_process = gersemi("-", input=inp + "\n") assert completed_process.returncode == 0 assert completed_process.stdout == outp assert completed_process.stderr == "" @@ -313,7 +316,7 @@ def test_format_with_default_line_length(): ) """ assert len(inp2) > 80 - completed_process = gersemi("-", input=inp2 + "\n", text=True, capture_output=True) + completed_process = gersemi("-", input=inp2 + "\n") assert completed_process.returncode == 0 assert completed_process.stdout == outp2 assert completed_process.stderr == "" @@ -329,8 +332,7 @@ def test_format_with_non_default_line_length(): str(line_length), "-", input=inp + "\n", - text=True, - capture_output=True, + universal_newlines=True, ) assert completed_process.returncode == 0 assert completed_process.stdout == outp @@ -347,8 +349,7 @@ def test_format_with_non_default_line_length(): str(line_length), "-", input=inp2 + "\n", - text=True, - capture_output=True, + universal_newlines=True, ) assert completed_process.returncode == 0 assert completed_process.stdout == outp2 @@ -400,9 +401,7 @@ def test_format_project_with_custom_commands_but_without_definitions(): def test_non_empty_stderr_when_files_are_not_formatted(): - completed_process = gersemi( - "--check", case("custom_project/not_formatted"), text=True, capture_output=True, - ) + completed_process = gersemi("--check", case("custom_project/not_formatted")) assert completed_process.returncode == 1 assert completed_process.stderr != "" @@ -412,8 +411,7 @@ def test_empty_stderr_when_files_are_not_formatted_but_quiet_is_supplied(): "--check", case("custom_project/not_formatted"), "--quiet", - text=True, - capture_output=True, + universal_newlines=True, ) assert completed_process.returncode == 1 assert completed_process.stderr == "" @@ -594,9 +592,7 @@ def test_use_configuration_file_from_current_directory_when_input_is_from_stdin( assert len(inp) > line_length with create_dot_gersemirc(where=".", line_length=30): - completed_process = gersemi( - "-", input=inp + "\n", text=True, capture_output=True, - ) + completed_process = gersemi("-", input=inp + "\n") assert completed_process.returncode == 0 assert completed_process.stdout == outp assert completed_process.stderr == "" diff --git a/tox.ini b/tox.ini index 85bfceb..4c47236 100644 --- a/tox.ini +++ b/tox.ini @@ -1,7 +1,14 @@ [tox] -envlist = tests, lint, format, mypy +envlist = py36, py37, py38, lint, format, mypy +skip_missing_interpreters=true -[testenv:tests] +[travis] +python = + 3.6: py36 + 3.7: py37 + 3.8: py38, lint, format, mypy + +[testenv] deps = pytest pytest-clarity @@ -9,6 +16,8 @@ deps = commands = pytest {posargs:-n auto} +[testenv:tests] + [testenv:lint] deps = pylint