Skip to content

Commit

Permalink
Add pre-commit hooks for autofixing trailing whitespace (#15237)
Browse files Browse the repository at this point in the history
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
AlexWaygood and pre-commit-ci[bot] authored May 14, 2023
1 parent 2df6f36 commit 4490525
Show file tree
Hide file tree
Showing 32 changed files with 31 additions and 30 deletions.
2 changes: 1 addition & 1 deletion .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# Adopt black and isort
97c5ee99bc98dc475512e549b252b23a6e7e0997
97c5ee99bc98dc475512e549b252b23a6e7e0997
6 changes: 6 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
exclude: '^(mypyc/external/)|(mypy/typeshed/)' # Exclude all vendored code from lints
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0 # must match test-requirements.txt
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- repo: https://github.com/psf/black
rev: 23.3.0 # must match test-requirements.txt
hooks:
Expand Down
2 changes: 1 addition & 1 deletion mypyc/lib-rt/bytes_ops.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include "CPy.h"

// Returns -1 on error, 0 on inequality, 1 on equality.
//
//
// Falls back to PyObject_RichCompareBool.
int CPyBytes_Compare(PyObject *left, PyObject *right) {
if (PyBytes_CheckExact(left) && PyBytes_CheckExact(right)) {
Expand Down
1 change: 0 additions & 1 deletion mypyc/test-data/irbuild-dict.test
Original file line number Diff line number Diff line change
Expand Up @@ -583,4 +583,3 @@ L2:
L3:
r7 = box(None, 1)
return r7

1 change: 0 additions & 1 deletion mypyc/test-data/irbuild-nested.test
Original file line number Diff line number Diff line change
Expand Up @@ -859,4 +859,3 @@ L2:
r2 = baz(r1)
r3 = CPyTagged_Add(n, r2)
return r3

1 change: 0 additions & 1 deletion mypyc/test-data/irbuild-set.test
Original file line number Diff line number Diff line change
Expand Up @@ -836,4 +836,3 @@ L4:
r11 = CPy_NoErrOccured()
L5:
return 1

1 change: 0 additions & 1 deletion mypyc/test-data/irbuild-strip-asserts.test
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,3 @@ L0:
r0 = object 3
x = r0
return x

2 changes: 1 addition & 1 deletion mypyc/test-data/run-bools.test
Original file line number Diff line number Diff line change
Expand Up @@ -226,4 +226,4 @@ def test_mixed_comparisons_i64() -> None:
y = False
print((y or 0) and True)
[out]
0
0
Original file line number Diff line number Diff line change
@@ -1 +1 @@
bar_var: str
bar_var: str
2 changes: 1 addition & 1 deletion test-data/packages/modulefinder-site-packages/foo/bar.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
bar_var = "bar"
bar_var = "bar"
Original file line number Diff line number Diff line change
@@ -1 +1 @@
a_var = "a"
a_var = "a"
Original file line number Diff line number Diff line change
@@ -1 +1 @@
c_var = "c"
c_var = "c"
Original file line number Diff line number Diff line change
@@ -1 +1 @@
a_var = "a"
a_var = "a"
Original file line number Diff line number Diff line change
@@ -1 +1 @@
c_var = "c"
c_var = "c"
Original file line number Diff line number Diff line change
@@ -1 +1 @@
pkg_typed_var = "pkg_typed"
pkg_typed_var = "pkg_typed"
Original file line number Diff line number Diff line change
@@ -1 +1 @@
a_var = "a"
a_var = "a"
Original file line number Diff line number Diff line change
@@ -1 +1 @@
b_var = "b"
b_var = "b"
Original file line number Diff line number Diff line change
@@ -1 +1 @@
c_var = "c"
c_var = "c"
Original file line number Diff line number Diff line change
@@ -1 +1 @@
pkg_untyped_var = "pkg_untyped"
pkg_untyped_var = "pkg_untyped"
Original file line number Diff line number Diff line change
@@ -1 +1 @@
a_var = "a"
a_var = "a"
Original file line number Diff line number Diff line change
@@ -1 +1 @@
b_var = "b"
b_var = "b"
Original file line number Diff line number Diff line change
@@ -1 +1 @@
c_var = "c"
c_var = "c"
Original file line number Diff line number Diff line change
@@ -1 +1 @@
standalone_var = "standalone"
standalone_var = "standalone"
2 changes: 1 addition & 1 deletion test-data/pybind11_mypy_demo/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ requires = [
"pybind11==2.9.2",
]

build-backend = "setuptools.build_meta"
build-backend = "setuptools.build_meta"
2 changes: 1 addition & 1 deletion test-data/pybind11_mypy_demo/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,4 +167,4 @@ void bind_basics(py::module& basics) {
PYBIND11_MODULE(pybind11_mypy_demo, m) {
auto basics = m.def_submodule("basics");
bind_basics(basics);
}
}
2 changes: 1 addition & 1 deletion test-data/unit/check-assert-type-fail.test
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ class array:
i = 1
def f(si: arr.array[int]):
typing.assert_type(si, int) # E: Expression is of type "array[int]", not "int"
[builtins fixtures/tuple.pyi]
[builtins fixtures/tuple.pyi]
1 change: 0 additions & 1 deletion test-data/unit/check-python39.test
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,3 @@ a = b = c = [1, 2, 3]
for x in *a, *b, *c:
reveal_type(x) # N: Revealed type is "builtins.int"
[builtins fixtures/tuple.pyi]

2 changes: 1 addition & 1 deletion test-data/unit/check-singledispatch.test
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def g(arg: int) -> None:
from functools import singledispatch

@singledispatch
def f(arg) -> None:
def f(arg) -> None:
pass

@f.register(str)
Expand Down
1 change: 0 additions & 1 deletion test-data/unit/envvars.test
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,3 @@ BAR = 0 # type: int
[file subdir/mypy.ini]
\[mypy]
files=$MYPY_CONFIG_FILE_DIR/good.py

2 changes: 1 addition & 1 deletion test-data/unit/pep561.test
Original file line number Diff line number Diff line change
Expand Up @@ -222,4 +222,4 @@ from typedpkg_ns.a.bbb import bf
-- dummy should trigger a second iteration
[file dummy.py.2]
[out]
[out2]
[out2]
2 changes: 1 addition & 1 deletion test-data/unit/plugins/fully_qualified_test_hook.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ def get_method_signature_hook(self, fullname):
if 'FullyQualifiedTest' in fullname:
assert fullname.startswith('__main__.') and not ' of ' in fullname, fullname
return my_hook

return None

def my_hook(ctx: MethodSigContext) -> CallableType:
Expand Down
1 change: 1 addition & 0 deletions test-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ flake8-noqa==1.3.1; python_version >= "3.8" # must match version in .pre-co
isort[colors]==5.12.0; python_version >= "3.8" # must match version in .pre-commit-config.yaml
lxml>=4.9.1; (python_version<'3.11' or sys_platform!='win32') and python_version<'3.12'
pre-commit
pre-commit-hooks==4.4.0
psutil>=4.0
# pytest 6.2.3 does not support Python 3.10
pytest>=6.2.4
Expand Down

0 comments on commit 4490525

Please sign in to comment.