Skip to content

Commit

Permalink
Add pre-commit configuration (#1710)
Browse files Browse the repository at this point in the history
  • Loading branch information
JelleZijlstra committed Apr 11, 2024
1 parent 30283a1 commit e45e1bf
Show file tree
Hide file tree
Showing 25 changed files with 28 additions and 31 deletions.
24 changes: 24 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: trailing-whitespace
exclude: conformance/results/.*/.*\.toml
- id: end-of-file-fixer
- id: check-yaml
- id: check-toml
- id: check-merge-conflict
- id: mixed-line-ending
args: [--fix=lf]
exclude: docs/make\.bat
- id: check-case-conflict
- repo: meta
hooks:
- id: check-hooks-apply

ci:
autofix_commit_msg: "[pre-commit.ci] auto fixes from pre-commit.com hooks"
autofix_prs: true
autoupdate_commit_msg: "[pre-commit.ci] pre-commit autoupdate"
autoupdate_schedule: quarterly
submodules: false
1 change: 0 additions & 1 deletion conformance/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@ pyright
mypy
pyre-check
pytype; platform_system != "Windows"

2 changes: 1 addition & 1 deletion conformance/results/results.html
Original file line number Diff line number Diff line change
Expand Up @@ -936,4 +936,4 @@ <h4>Mypy 1.8.0</h4>
</div>
</body>

</html>
</html>
2 changes: 1 addition & 1 deletion conformance/src/results_template.html
Original file line number Diff line number Diff line change
Expand Up @@ -173,4 +173,4 @@ <h4>Mypy 1.8.0</h4>
</div>
</body>

</html>
</html>
1 change: 0 additions & 1 deletion conformance/tests/aliases_implicit.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,4 +133,3 @@ def bad_type_aliases(
x3 = ListOrSetAlias() # E: cannot instantiate union

x4: ListOrSetAlias[int] # E: already specialized

1 change: 0 additions & 1 deletion conformance/tests/aliases_recursive.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,3 @@ def func1(j1: Json) -> Json2:

# On one line because different type checkers report the error on different lines
MutualReference1: TypeAlias = Union["MutualReference2", int]; MutualReference2: TypeAlias = Union["MutualReference1", str] # E: cyclical reference

1 change: 0 additions & 1 deletion conformance/tests/aliases_type_statement.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,3 @@ def func3():

type RecursiveTypeAlias6 = RecursiveTypeAlias7 # E: circular definition
type RecursiveTypeAlias7 = RecursiveTypeAlias6

1 change: 0 additions & 1 deletion conformance/tests/callables_kwargs.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,3 @@ def func5(v1: int, **kwargs: Unpack[TD2]) -> None: # E: parameter v1 overlaps w

def func6(**kwargs: Unpack[T]) -> None: # E: unpacked value must be a TypedDict, not a TypeVar bound to TypedDict.
...

1 change: 0 additions & 1 deletion conformance/tests/dataclasses_frozen.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,3 @@ class DC1Child(DC1):
# This should be allowed because attributes within a frozen
# dataclass are covariant rather than invariant.
a: int

1 change: 0 additions & 1 deletion conformance/tests/dataclasses_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,3 @@ class DC2:

if dc1_1 != dc2_1:
pass

1 change: 0 additions & 1 deletion conformance/tests/directives_type_checking.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,3 @@
b: list[str] = ["a", "b", "c"]

assert_type(b, list[int])

1 change: 0 additions & 1 deletion conformance/tests/generics_self_advanced.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,3 @@ def method3(cls) -> None:
assert_type(cls.a, list[Self])
assert_type(cls.a[0], Self)
assert_type(cls.method1(), Self)

2 changes: 0 additions & 2 deletions conformance/tests/generics_self_attributes.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,3 @@ def ordinal_value(self) -> str:

# This should result in a type error.
xs.next = LinkedList[int](value=3, next=None) # E


1 change: 0 additions & 1 deletion conformance/tests/generics_self_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,3 @@ def object_with_generic_type(
val = container.set_value(value)
assert_type(val, Container[T])
return val

2 changes: 0 additions & 2 deletions conformance/tests/literals_semantics.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,3 @@ def func3(a: L[3, 4, 5]):
def func4(a: L[None, 3] | L[3, "foo", b"bar", True]):
x1: Literal[3, b"bar", True, "foo", None] = a
a = x1


2 changes: 0 additions & 2 deletions conformance/tests/specialtypes_any.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,5 +86,3 @@ def method1(self) -> int:
assert_type(a.method1(), int)
assert_type(a.method2(), Any)
assert_type(ClassA.method3(), Any)


2 changes: 0 additions & 2 deletions conformance/tests/typeddicts_class_syntax.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,5 +75,3 @@ class MovieTotal(TypedDict, total=True):

class MovieOptional(TypedDict, total=False):
name: str


1 change: 0 additions & 1 deletion conformance/tests/typeddicts_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,3 @@ class MovieOptional(TypedDict, total=False):
movie_optional.clear() # E: clear not allowed

del movie_optional["name"]

2 changes: 0 additions & 2 deletions conformance/tests/typeddicts_required.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,3 @@ class TD7(TypedDict):
)

movie: RecursiveMovie = {"title": "Beethoven 3", "predecessor": {"title": "Beethoven 2"}}


2 changes: 0 additions & 2 deletions conformance/tests/typeddicts_usage.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,3 @@ def record_movie(movie: Movie) -> None:

# TypedDict should not be allowed as a bound for a TypeVar.
T = TypeVar("T", bound=TypedDict) # E


2 changes: 1 addition & 1 deletion docs/source/unreachable.rst
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ finds the lowest unused street number in a street:
def is_used(street: str, number: int) -> bool:
...
def lowest_unused(street: str) -> int:
for i in itertools.count(1):
if not is_used(street, i):
Expand Down
2 changes: 0 additions & 2 deletions docs/spec/constructors.rst
Original file line number Diff line number Diff line change
Expand Up @@ -489,5 +489,3 @@ callable.
def __init__[V](self, x: T, y: list[V], z: V) -> None: ...

reveal_type(accepts_callable(MyClass)) # ``def [T, V] (x: T, y: list[V], z: V) -> MyClass[T]``


2 changes: 1 addition & 1 deletion docs/spec/namedtuples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ specifies default values for the fields. Type checkers may support this::
Named Tuple Usage
-----------------

The fields within a named tuple instance can be accessed by name using an
The fields within a named tuple instance can be accessed by name using an
attribute access (``.``) operator. Type checkers should support this::

p = Point(1, 2)
Expand Down
1 change: 0 additions & 1 deletion docs/spec/narrowing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -226,4 +226,3 @@ This code fails at runtime, because the narrower returns ``False`` (1 is not a `
and the ``else`` branch is taken in ``takes_narrower()``.
If the call ``takes_narrower(1, is_bool)`` was allowed, type checkers would fail to
detect this error.

1 change: 0 additions & 1 deletion docs/spec/typeddict.rst
Original file line number Diff line number Diff line change
Expand Up @@ -820,4 +820,3 @@ As discussed in the section :ref:`unpack-kwargs`, an unpacked ``TypedDict`` can
kwargs["key1"] = 3 # Type check error: key1 is readonly

fn: Function = impl # Accepted by type checker: function signatures are identical

0 comments on commit e45e1bf

Please sign in to comment.