Skip to content

Commit

Permalink
Manage black version using requirement file (#207)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
aahung authored Oct 29, 2020
1 parent 3bc7a25 commit 842b95e
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 10 deletions.
9 changes: 2 additions & 7 deletions .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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]\""
Expand All @@ -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
9 changes: 9 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -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]
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 4 additions & 0 deletions requirements/dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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'
6 changes: 5 additions & 1 deletion tests/functional/workflows/provided_make/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
3 changes: 1 addition & 2 deletions tests/unit/test_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 842b95e

Please sign in to comment.