Skip to content

Add pre-commit: pretter, black, pyupgrade, and misc #1381

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# flake8 is a Python linting tool run by pre-commit as declared by our
# pre-commit-config.yaml file.
#
# This configuration is compatible with the autoformatter tool black, and
# further relaxed to not bug us with too small details.
#
# flake8 configuration reference:
# https://flake8.pycqa.org/en/latest/user/configuration.html
#
[flake8]
max-line-length = 88
extend-ignore = C, E, W

# Adjustments to linting the binderhub repo
builtins = c, load_subconfig
exclude = versioneer.py,binderhub/_version.py
65 changes: 65 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# pre-commit is a tool to perform a predefined set of tasks manually and/or
# automatically before git commits are made.
#
# Config reference: https://pre-commit.com/#pre-commit-configyaml---top-level
#
# Common tasks
#
# - Run on all files: pre-commit run --all-files
# - Register git hooks: pre-commit install --install-hooks
#
repos:
# Autoformat: Python code, syntax patterns are modernized
- repo: https://github.com/asottile/pyupgrade
rev: v2.31.0
hooks:
- id: pyupgrade
args:
- --py37-plus

# Autoformat: Python code
- repo: https://github.com/psf/black
rev: 22.1.0
hooks:
- id: black
args: [--target-version=py37]

# Autoformat: Python code
- repo: https://github.com/asottile/reorder_python_imports
rev: v3.0.1
hooks:
- id: reorder-python-imports

# Autoformat: js, html, markdown, yaml, json
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v2.6.1
hooks:
- id: prettier
exclude_types:
# These are excluded initially as pre-commit was added but can
# absolutely be enabled later. If so, we should consider having a
# separate run of pre-commit where we configure a line spacing of 4
# for these file formats.
- html
- javascript
- css

# Misc autoformatting and linting
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.1.0
hooks:
- id: end-of-file-fixer
exclude_types: [svg]
- id: check-case-conflict
- id: check-executables-have-shebangs
- id: requirements-txt-fixer

# Lint: Python code
- repo: https://github.com/PyCQA/flake8
rev: "4.0.1"
hooks:
- id: flake8

# versioneer.py is excluded for being an imported dependency we opt to not
# modify ourselves. This is also set in .flake8 for consistency.
exclude: versioneer.py|binderhub/_version.py
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
helm-chart/binderhub/templates/
http-record.doi.org.json
2 changes: 1 addition & 1 deletion binderhub/launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ def _cancel_ready_event(f=None):
else:
ready_event_future.cancel()
try:
resp = await self.api_request(
await self.api_request(
'users/{}/servers/{}'.format(escaped_username, server_name),
method='POST',
body=json.dumps(data).encode('utf8'),
Expand Down