Skip to content

(🎁) Adopt Black and isort as code formatters #12424

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 2 commits into from
Jul 27, 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
1 change: 1 addition & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<insert format ref here>
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ jobs:
arch: x64
os: windows-latest
toxenv: type
- name: Code style with flake8
- name: Formatting with Black + isort and code style with flake8
python: '3.7'
arch: x64
os: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ docs/source/_build
mypyc/doc/_build
*.iml
/out/
.venv
.venv*
venv/
.mypy_cache/
.incremental_checker_cache.json
Expand Down
9 changes: 9 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
repos:
- repo: https://github.com/psf/black
rev: 22.6.0 # must match test-requirements.txt
hooks:
- id: black
- repo: https://github.com/pycqa/isort
rev: 5.10.1 # must match test-requirements.txt
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we have a small test that reads both both files and tests for consistency? I could see it being easy to miss this, especially because the comments aren't duplicated in test-requirements.txt which is the first place someone will look.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I might need a hand with that...

Copy link
Contributor Author

@KotlinIsland KotlinIsland Jul 20, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment is in both now. And typeshed seems fine without.

hooks:
- id: isort
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ Mypy: Static Typing for Python
[![Documentation Status](https://readthedocs.org/projects/mypy/badge/?version=latest)](https://mypy.readthedocs.io/en/latest/?badge=latest)
[![Chat at https://gitter.im/python/typing](https://badges.gitter.im/python/typing.svg)](https://gitter.im/python/typing?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![Checked with mypy](http://www.mypy-lang.org/static/mypy_badge.svg)](http://mypy-lang.org/)

[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg")](https://github.com/psf/black)
[![Imports: isort](https://img.shields.io/badge/%20imports-isort-%231674b1?style=flat&labelColor=ef8336)](https://pycqa.github.io/isort/)

Got a question?
---------------
Expand Down
9 changes: 4 additions & 5 deletions conftest.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import os.path

pytest_plugins = [
'mypy.test.data',
]
pytest_plugins = ["mypy.test.data"]


def pytest_configure(config):
Expand All @@ -14,5 +12,6 @@ def pytest_configure(config):
# This function name is special to pytest. See
# http://doc.pytest.org/en/latest/writing_plugins.html#initialization-command-line-and-configuration-hooks
def pytest_addoption(parser) -> None:
parser.addoption('--bench', action='store_true', default=False,
help='Enable the benchmark test runs')
parser.addoption(
"--bench", action="store_true", default=False, help="Enable the benchmark test runs"
)
Loading