Skip to content

Commit

Permalink
Use Black to format Python parameters for versions >= 3.6 (#455)
Browse files Browse the repository at this point in the history
Use black for Python >= 3.6
  • Loading branch information
petebachant authored and MSeal committed Dec 29, 2019
1 parent 3d73487 commit 876ba9f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions papermill/translators.py
Expand Up @@ -135,6 +135,16 @@ def translate_list(cls, val):
def comment(cls, cmt_str):
return '# {}'.format(cmt_str).strip()

@classmethod
def codify(cls, parameters):
content = super(PythonTranslator, cls).codify(parameters)
if sys.version_info >= (3, 6):
# Put content through the Black Python code formatter
import black
fm = black.FileMode(string_normalization=False)
content = black.format_str(content, mode=fm)
return content


class RTranslator(Translator):
@classmethod
Expand Down
1 change: 0 additions & 1 deletion requirements-dev.txt
Expand Up @@ -9,7 +9,6 @@ pytest-env>=0.6.2
ipython>=5.0
moto
check-manifest
black; python_version >= '3.6'
attrs>=17.4.0
pre-commit
boto3
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Expand Up @@ -12,3 +12,4 @@ jupyter_client
requests
entrypoints
tenacity
black; python_version >= '3.6'

0 comments on commit 876ba9f

Please sign in to comment.