Skip to content

Add black formatter precommit hook #196

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
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
19 changes: 12 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
repos:
- repo: git://github.com/pre-commit/pre-commit-hooks
sha: v0.8.0
rev: v1.3.0
hooks:
- id: autopep8-wrapper
args:
- -i
- --ignore=E128,E309,E501
exclude: ^docs/.*$
- id: check-json
- id: check-yaml
- id: debug-statements
- id: end-of-file-fixer
exclude: ^docs/.*$
- id: trailing-whitespace
exclude: README.md
- id: pretty-format-json
args:
- --autofix
- --indent=4
- repo: https://github.com/asottile/pyupgrade
rev: v1.4.0
hooks:
- id: pyupgrade
- repo: https://github.com/ambv/black
rev: 18.6b4
hooks:
- id: black
language_version: python3.6
5 changes: 5 additions & 0 deletions conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,32 @@

try:
import pyannotate_runtime

PYANOTATE_PRESENT = True
except ImportError:
PYANOTATE_PRESENT = False

if PYANOTATE_PRESENT:

def pytest_collection_finish(session):
"""Handle the pytest collection finish hook: configure pyannotate.
Explicitly delay importing `collect_types` until all tests have
been collected. This gives gevent a chance to monkey patch the
world before importing pyannotate.
"""
from pyannotate_runtime import collect_types

collect_types.init_types_collection()

@pytest.fixture(autouse=True)
def collect_types_fixture():
from pyannotate_runtime import collect_types

collect_types.resume()
yield
collect_types.pause()

def pytest_sessionfinish(session, exitstatus):
from pyannotate_runtime import collect_types

collect_types.dump_stats("type_info.json")
Loading