Skip to content

Commit 842b95e

Browse files
authored
Manage black version using requirement file (#207)
* chore: Manage black version in dev.txt * chore: Update appveyor, use black in pip * chore: Add pre-commit-config * chore: Format with black 20.8b1 * chore: Add make pr2.7 for Python 2 that does not run black
1 parent 3bc7a25 commit 842b95e

File tree

6 files changed

+24
-10
lines changed

6 files changed

+24
-10
lines changed

.appveyor.yml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,6 @@ for:
103103
- sh: "sudo unzip -d /opt/gradle /tmp/gradle-*.zip"
104104
- sh: "PATH=/opt/gradle/gradle-5.5/bin:$PATH"
105105

106-
# Install black
107-
- sh: "wget -O /tmp/black https://github.com/python/black/releases/download/19.10b0/black"
108-
- sh: "chmod +x /tmp/black"
109-
- sh: "/tmp/black --version"
110-
111106
build_script:
112107
- "python -c \"import sys; print(sys.executable)\""
113108
- "LAMBDA_BUILDERS_DEV=1 pip install -e \".[dev]\""
@@ -119,5 +114,5 @@ for:
119114
# Runs only in Linux
120115
- "LAMBDA_BUILDERS_DEV=1 pytest -vv tests/integration"
121116

122-
# Validate Code was formatted with Black
123-
- "/tmp/black --check setup.py tests aws_lambda_builders"
117+
# Validate Code was formatted with Black, black is only supported in Python 3
118+
- if [[ $PYTHON_VERSION = "3"* ]]; then black --check setup.py tests aws_lambda_builders; fi

.pre-commit-config.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# black is in dev.txt, so local repo is used here.
2+
repos:
3+
- repo: local
4+
hooks:
5+
- id: black
6+
name: black
7+
entry: black
8+
language: system
9+
types: [python]

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,6 @@ black-check:
2828

2929
# Verifications to run before sending a pull request
3030
pr: init dev black-check
31+
32+
# Verifications to run before sending a pull request, skipping black check because black requires Python 3.6+
33+
pr2.7: init dev

requirements/dev.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,7 @@ futures==3.2.0; python_version<"3.2.3"
2020

2121
# tempfile backport for < 3.6
2222
backports.tempfile==1.0; python_version<"3.7"
23+
24+
25+
# formatter
26+
black==20.8b1; python_version >= '3.6'

tests/functional/workflows/provided_make/test_utils.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,11 @@ def test_popen_can_accept_cwd_and_env(self):
3030
env.update({"SOME_ENV": "SOME_VALUE"})
3131

3232
p = self.osutils.popen(
33-
[sys.executable, "cwd.py"], stdout=self.osutils.pipe, stderr=self.osutils.pipe, env=env, cwd=testdata_dir,
33+
[sys.executable, "cwd.py"],
34+
stdout=self.osutils.pipe,
35+
stderr=self.osutils.pipe,
36+
env=env,
37+
cwd=testdata_dir,
3438
)
3539

3640
out, err = p.communicate()

tests/unit/test_builder.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,7 @@ def test_must_not_load_any_workflows(self, get_workflow_mock, importlib_mock):
6262
importlib_mock.import_module.assert_not_called()
6363

6464
def test_with_real_workflow_class(self):
65-
"""Define a real workflow class and try to fetch it. This ensures the workflow registration actually works.
66-
"""
65+
"""Define a real workflow class and try to fetch it. This ensures the workflow registration actually works."""
6766

6867
# Declare my test workflow.
6968
class MyWorkflow(BaseWorkflow):

0 commit comments

Comments
 (0)