diff --git a/.github/workflows/codestyle.yml b/.github/workflows/codestyle.yml index 525f979..05a565e 100644 --- a/.github/workflows/codestyle.yml +++ b/.github/workflows/codestyle.yml @@ -18,8 +18,8 @@ jobs: - name: Install Dependencies run: make install - - name: black - run: make black + - name: ruff + run: make ruff-check - name: isort run: make isort-check diff --git a/.gitignore b/.gitignore index c8b72e6..5fd3efc 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,11 @@ +__pycache__ *.egg-info *.pyc /.coverage /.mxmake/ /.mypy_cache/ /.pytest_cache/ +/.ruff_cache/ /.vscode/ /build/ /constraints-mxdev.txt @@ -11,4 +13,3 @@ /docs/html/ /requirements-mxdev.txt /venv/ -__pycache__ diff --git a/src/mxmake/tests/test_hook.py b/src/mxmake/tests/test_hook.py index 485b3a9..0fef7ab 100644 --- a/src/mxmake/tests/test_hook.py +++ b/src/mxmake/tests/test_hook.py @@ -4,22 +4,23 @@ import io import mxdev import os +import pathlib import unittest class TestHook(unittest.TestCase): @testing.template_directory() def test_Hook(self, tempdir): - config_file = io.StringIO() - config_file.write( - "[settings]\n" "mxmake-templates = run-tests run-coverage inexistent" - ) - config_file.seek(0) + mxini = pathlib.Path(tempdir, "mx.ini") + with mxini.open("w") as fd: + fd.write( + "[settings]\n" "mxmake-templates = run-tests run-coverage inexistent" + ) hook_ = hook.Hook() - configuration = mxdev.Configuration(config_file, hooks=[hook_]) + configuration = mxdev.Configuration(mxini, hooks=[hook_]) state = mxdev.State(configuration=configuration) hook_.write(state) self.assertEqual( - sorted(os.listdir(tempdir)), ["run-coverage.sh", "run-tests.sh"] + sorted(os.listdir(tempdir)), ["mx.ini", "run-coverage.sh", "run-tests.sh"] ) diff --git a/src/mxmake/tests/test_templates.py b/src/mxmake/tests/test_templates.py index 74821c9..409c17a 100644 --- a/src/mxmake/tests/test_templates.py +++ b/src/mxmake/tests/test_templates.py @@ -9,6 +9,7 @@ import io import mxdev import os +import pathlib import typing @@ -116,22 +117,22 @@ class Template(templates.EnvironmentTemplate): @testing.template_directory() def test_TestScript(self, tempdir): - config_file = io.StringIO() - config_file.write( - "[settings]\n" - "mxmake-test-path = src\n" - "mxmake-test-runner = zope-testrunner\n" - "[mxmake-env]\n" - "ENV_PARAM = env_value\n" - "[mxmake-run-tests]\n" - "environment = env\n" - "[package]\n" - "url = https://github.com/org/package\n" - "mxmake-test-path = src\n" - ) - config_file.seek(0) + mxini = pathlib.Path(tempdir, "mx.ini") + with mxini.open("w") as fd: + fd.write( + "[settings]\n" + "mxmake-test-path = src\n" + "mxmake-test-runner = zope-testrunner\n" + "[mxmake-env]\n" + "ENV_PARAM = env_value\n" + "[mxmake-run-tests]\n" + "environment = env\n" + "[package]\n" + "url = https://github.com/org/package\n" + "mxmake-test-path = src\n" + ) - configuration = mxdev.Configuration(config_file, hooks=[hook.Hook()]) + configuration = mxdev.Configuration(mxini, hooks=[hook.Hook()]) factory = templates.template.lookup("run-tests") template = factory(configuration, templates.get_template_environment()) @@ -190,17 +191,16 @@ def test_TestScript(self, tempdir): f.read(), ) - config_file = io.StringIO() - config_file.write( - "[settings]\n" - "mxmake-test-runner = zope-testrunner\n" - "[package]\n" - "url = https://github.com/org/package\n" - "mxmake-test-path = src\n" - ) - config_file.seek(0) + with mxini.open("w") as fd: + fd.write( + "[settings]\n" + "mxmake-test-runner = zope-testrunner\n" + "[package]\n" + "url = https://github.com/org/package\n" + "mxmake-test-path = src\n" + ) - configuration = mxdev.Configuration(config_file, hooks=[hook.Hook()]) + configuration = mxdev.Configuration(mxini, hooks=[hook.Hook()]) template = factory(configuration, templates.get_template_environment()) template.write() with open(os.path.join(tempdir, "run-tests.sh")) as f: @@ -223,17 +223,16 @@ def test_TestScript(self, tempdir): f.read(), ) - config_file = io.StringIO() - config_file.write( - "[settings]\n" - "mxmake-test-runner = pytest\n" - "[package]\n" - "url = https://github.com/org/package\n" - "mxmake-test-path = src\n" - ) - config_file.seek(0) + with mxini.open("w") as fd: + fd.write( + "[settings]\n" + "mxmake-test-runner = pytest\n" + "[package]\n" + "url = https://github.com/org/package\n" + "mxmake-test-path = src\n" + ) - configuration = mxdev.Configuration(config_file, hooks=[hook.Hook()]) + configuration = mxdev.Configuration(mxini, hooks=[hook.Hook()]) template = factory(configuration, templates.get_template_environment()) template.write() with open(os.path.join(tempdir, "run-tests.sh")) as f: @@ -257,30 +256,30 @@ def test_TestScript(self, tempdir): @testing.template_directory() def test_CoverageScript(self, tempdir): - config_file = io.StringIO() - config_file.write( - "[settings]\n" - "mxmake-test-runner = zope-testrunner\n" - "mxmake-test-path = src\n" - "mxmake-source-path = src/local\n" - "mxmake-omit-path =\n" - " src/local/file1.py\n" - " src/local/file2.py\n" - "[mxmake-env]\n" - "ENV_PARAM = env_value\n" - "[mxmake-run-coverage]\n" - "environment = env\n" - "[package]\n" - "url = https://github.com/org/package\n" - "mxmake-test-path = src\n" - "mxmake-source-path = src/package\n" - "mxmake-omit-path =\n" - " src/package/file1.py\n" - " src/package/file2.py\n" - ) - config_file.seek(0) + mxini = pathlib.Path(tempdir, "mx.ini") + with mxini.open("w") as fd: + fd.write( + "[settings]\n" + "mxmake-test-runner = zope-testrunner\n" + "mxmake-test-path = src\n" + "mxmake-source-path = src/local\n" + "mxmake-omit-path =\n" + " src/local/file1.py\n" + " src/local/file2.py\n" + "[mxmake-env]\n" + "ENV_PARAM = env_value\n" + "[mxmake-run-coverage]\n" + "environment = env\n" + "[package]\n" + "url = https://github.com/org/package\n" + "mxmake-test-path = src\n" + "mxmake-source-path = src/package\n" + "mxmake-omit-path =\n" + " src/package/file1.py\n" + " src/package/file2.py\n" + ) - configuration = mxdev.Configuration(config_file, hooks=[hook.Hook()]) + configuration = mxdev.Configuration(mxini, hooks=[hook.Hook()]) factory = templates.template.lookup("run-coverage") template = factory(configuration, templates.get_template_environment()) @@ -382,18 +381,17 @@ def test_CoverageScript(self, tempdir): f.read(), ) - config_file = io.StringIO() - config_file.write( - "[settings]\n" - "mxmake-test-runner = zope-testrunner\n" - "[package]\n" - "url = https://github.com/org/package\n" - "mxmake-test-path = src\n" - "mxmake-source-path = src/package\n" - ) - config_file.seek(0) + with mxini.open("w") as fd: + fd.write( + "[settings]\n" + "mxmake-test-runner = zope-testrunner\n" + "[package]\n" + "url = https://github.com/org/package\n" + "mxmake-test-path = src\n" + "mxmake-source-path = src/package\n" + ) - configuration = mxdev.Configuration(config_file, hooks=[hook.Hook()]) + configuration = mxdev.Configuration(mxini, hooks=[hook.Hook()]) template = factory(configuration, templates.get_template_environment()) template.write() with open(os.path.join(tempdir, "run-coverage.sh")) as f: @@ -427,18 +425,17 @@ def test_CoverageScript(self, tempdir): f.read(), ) - config_file = io.StringIO() - config_file.write( - "[settings]\n" - "mxmake-test-runner = pytest\n" - "[package]\n" - "url = https://github.com/org/package\n" - "mxmake-test-path = src\n" - "mxmake-source-path = src/package\n" - ) - config_file.seek(0) + with mxini.open("w") as fd: + fd.write( + "[settings]\n" + "mxmake-test-runner = pytest\n" + "[package]\n" + "url = https://github.com/org/package\n" + "mxmake-test-path = src\n" + "mxmake-source-path = src/package\n" + ) - configuration = mxdev.Configuration(config_file, hooks=[hook.Hook()]) + configuration = mxdev.Configuration(mxini, hooks=[hook.Hook()]) template = factory(configuration, templates.get_template_environment()) template.write() with open(os.path.join(tempdir, "run-coverage.sh")) as f: @@ -474,18 +471,18 @@ def test_CoverageScript(self, tempdir): @testing.template_directory() def test_PipConf(self, tempdir): - config_file = io.StringIO() - config_file.write( - "[settings]\n" - "\n" - "[mxmake-pip-conf]\n" - "find-links =\n" - " file:///path/to/folder\n" - " https://tld.com/\n" - ) - config_file.seek(0) + mxini = pathlib.Path(tempdir, "mx.ini") + with mxini.open("w") as fd: + fd.write( + "[settings]\n" + "\n" + "[mxmake-pip-conf]\n" + "find-links =\n" + " file:///path/to/folder\n" + " https://tld.com/\n" + ) - configuration = mxdev.Configuration(config_file, hooks=[hook.Hook()]) + configuration = mxdev.Configuration(mxini, hooks=[hook.Hook()]) factory = templates.template.lookup("pip-conf") template = factory(configuration, templates.get_template_environment()) diff --git a/src/mxmake/topics/qa/black.mk b/src/mxmake/topics/qa/black.mk index a7b5f78..3dceca7 100644 --- a/src/mxmake/topics/qa/black.mk +++ b/src/mxmake/topics/qa/black.mk @@ -15,7 +15,6 @@ #: #:[target.black-clean] #:description = Uninstall black. -#: ############################################################################## # black diff --git a/src/mxmake/topics/qa/isort.mk b/src/mxmake/topics/qa/isort.mk index 7c3fcff..dcfeb33 100644 --- a/src/mxmake/topics/qa/isort.mk +++ b/src/mxmake/topics/qa/isort.mk @@ -15,7 +15,6 @@ #: #:[target.isort-clean] #:description = Uninstall isort. -#: ############################################################################## # isort diff --git a/src/mxmake/topics/qa/mypy.mk b/src/mxmake/topics/qa/mypy.mk index 0f985c5..4004682 100644 --- a/src/mxmake/topics/qa/mypy.mk +++ b/src/mxmake/topics/qa/mypy.mk @@ -19,7 +19,6 @@ #: #:[target.mypy-clean] #:description = Uninstall mypy and removes cached data. -#: ############################################################################## # mypy diff --git a/src/mxmake/topics/qa/ruff.mk b/src/mxmake/topics/qa/ruff.mk index 790dd23..b82217b 100644 --- a/src/mxmake/topics/qa/ruff.mk +++ b/src/mxmake/topics/qa/ruff.mk @@ -15,7 +15,6 @@ #: #:[target.ruff-clean] #:description = Uninstall ruff. -#: ############################################################################## # ruff diff --git a/src/mxmake/topics/qa/zpretty.mk b/src/mxmake/topics/qa/zpretty.mk index 219f0d4..5e502da 100644 --- a/src/mxmake/topics/qa/zpretty.mk +++ b/src/mxmake/topics/qa/zpretty.mk @@ -15,7 +15,6 @@ #: #:[target.zpretty-clean] #:description = Uninstall zpretty. -#: ############################################################################## # zpretty