From b6f9a54ebb9f1f4d835ed4cc06e439efd7bcc59f Mon Sep 17 00:00:00 2001 From: Sam Liu Date: Wed, 28 Oct 2020 13:17:17 -0700 Subject: [PATCH 1/5] chore: Manage black version in dev.txt --- requirements/dev.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/requirements/dev.txt b/requirements/dev.txt index 86f7affde..c4ca79eef 100644 --- a/requirements/dev.txt +++ b/requirements/dev.txt @@ -20,3 +20,7 @@ futures==3.2.0; python_version<"3.2.3" # tempfile backport for < 3.6 backports.tempfile==1.0; python_version<"3.7" + + +# formatter +black==20.8b1; python_version >= '3.6' \ No newline at end of file From 66450ff4c5deaaa2044f116fa06dbfb7a3528aa4 Mon Sep 17 00:00:00 2001 From: Sam Liu Date: Wed, 28 Oct 2020 13:17:43 -0700 Subject: [PATCH 2/5] chore: Update appveyor, use black in pip --- .appveyor.yml | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index 5e1b18f48..1f3a0023b 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -103,11 +103,6 @@ for: - sh: "sudo unzip -d /opt/gradle /tmp/gradle-*.zip" - sh: "PATH=/opt/gradle/gradle-5.5/bin:$PATH" - # Install black - - sh: "wget -O /tmp/black https://github.com/python/black/releases/download/19.10b0/black" - - sh: "chmod +x /tmp/black" - - sh: "/tmp/black --version" - build_script: - "python -c \"import sys; print(sys.executable)\"" - "LAMBDA_BUILDERS_DEV=1 pip install -e \".[dev]\"" @@ -119,5 +114,5 @@ for: # Runs only in Linux - "LAMBDA_BUILDERS_DEV=1 pytest -vv tests/integration" - # Validate Code was formatted with Black - - "/tmp/black --check setup.py tests aws_lambda_builders" + # Validate Code was formatted with Black, black is only supported in Python 3 + - if [[ $PYTHON_VERSION = "3"* ]]; then black --check setup.py tests aws_lambda_builders; fi From a8781dd81ca086aee4d2cd62bc3960e56567ca43 Mon Sep 17 00:00:00 2001 From: Sam Liu Date: Wed, 28 Oct 2020 13:17:55 -0700 Subject: [PATCH 3/5] chore: Add pre-commit-config --- .pre-commit-config.yaml | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 .pre-commit-config.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 000000000..ba9847ef0 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,9 @@ +# black is in dev.txt, so local repo is used here. +repos: +- repo: local + hooks: + - id: black + name: black + entry: black + language: system + types: [python] From 377490a34662a7de5abb17dcf89df09f882b11d4 Mon Sep 17 00:00:00 2001 From: Sam Liu Date: Wed, 28 Oct 2020 13:19:32 -0700 Subject: [PATCH 4/5] chore: Format with black 20.8b1 --- tests/functional/workflows/provided_make/test_utils.py | 6 +++++- tests/unit/test_builder.py | 3 +-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/functional/workflows/provided_make/test_utils.py b/tests/functional/workflows/provided_make/test_utils.py index 103a244ff..ad78e8d44 100644 --- a/tests/functional/workflows/provided_make/test_utils.py +++ b/tests/functional/workflows/provided_make/test_utils.py @@ -30,7 +30,11 @@ def test_popen_can_accept_cwd_and_env(self): env.update({"SOME_ENV": "SOME_VALUE"}) p = self.osutils.popen( - [sys.executable, "cwd.py"], stdout=self.osutils.pipe, stderr=self.osutils.pipe, env=env, cwd=testdata_dir, + [sys.executable, "cwd.py"], + stdout=self.osutils.pipe, + stderr=self.osutils.pipe, + env=env, + cwd=testdata_dir, ) out, err = p.communicate() diff --git a/tests/unit/test_builder.py b/tests/unit/test_builder.py index 15ca779a0..08148158c 100644 --- a/tests/unit/test_builder.py +++ b/tests/unit/test_builder.py @@ -62,8 +62,7 @@ def test_must_not_load_any_workflows(self, get_workflow_mock, importlib_mock): importlib_mock.import_module.assert_not_called() def test_with_real_workflow_class(self): - """Define a real workflow class and try to fetch it. This ensures the workflow registration actually works. - """ + """Define a real workflow class and try to fetch it. This ensures the workflow registration actually works.""" # Declare my test workflow. class MyWorkflow(BaseWorkflow): From f7dfa1adacfbefbf039d9c98c02ca207e26cdccb Mon Sep 17 00:00:00 2001 From: Sam Liu Date: Wed, 28 Oct 2020 14:41:25 -0700 Subject: [PATCH 5/5] chore: Add make pr2.7 for Python 2 that does not run black --- Makefile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Makefile b/Makefile index 883aba1b1..30721f517 100644 --- a/Makefile +++ b/Makefile @@ -28,3 +28,6 @@ black-check: # Verifications to run before sending a pull request pr: init dev black-check + +# Verifications to run before sending a pull request, skipping black check because black requires Python 3.6+ +pr2.7: init dev