Skip to content

Commit

Permalink
[pre-commit.ci] pre-commit autoupdate (#434)
Browse files Browse the repository at this point in the history
* [pre-commit.ci] pre-commit autoupdate

updates:
- [github.com/psf/black: 23.12.1 → 24.1.1](psf/black@23.12.1...24.1.1)

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
pre-commit-ci[bot] authored Jan 29, 2024
1 parent 7c2460e commit 57585c2
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 29 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ repos:
args: [--fix, --show-fixes]

- repo: https://github.com/psf/black
rev: 23.12.1
rev: 24.1.1
hooks:
- id: black
exclude: "^tests/mypy/negative.py"
Expand Down
12 changes: 5 additions & 7 deletions src/typeguard/_decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,11 @@ def typechecked(
typecheck_fail_callback: TypeCheckFailCallback | Unset = unset,
collection_check_strategy: CollectionCheckStrategy | Unset = unset,
debug_instrumentation: bool | Unset = unset,
) -> Callable[[T_CallableOrType], T_CallableOrType]:
...
) -> Callable[[T_CallableOrType], T_CallableOrType]: ...


@overload
def typechecked(target: T_CallableOrType) -> T_CallableOrType:
...
def typechecked(target: T_CallableOrType) -> T_CallableOrType: ...


def typechecked(
Expand Down Expand Up @@ -215,9 +213,9 @@ def typechecked(
return target

# Find either the first Python wrapper or the actual function
wrapper_class: type[classmethod[Any, Any, Any]] | type[
staticmethod[Any, Any]
] | None = None
wrapper_class: (
type[classmethod[Any, Any, Any]] | type[staticmethod[Any, Any]] | None
) = None
if isinstance(target, (classmethod, staticmethod)):
wrapper_class = target.__class__
target = target.__func__
Expand Down
8 changes: 3 additions & 5 deletions src/typeguard/_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ def check_type(
forward_ref_policy: ForwardRefPolicy = ...,
typecheck_fail_callback: TypeCheckFailCallback | None = ...,
collection_check_strategy: CollectionCheckStrategy = ...,
) -> T:
...
) -> T: ...


@overload
Expand All @@ -44,16 +43,15 @@ def check_type(
forward_ref_policy: ForwardRefPolicy = ...,
typecheck_fail_callback: TypeCheckFailCallback | None = ...,
collection_check_strategy: CollectionCheckStrategy = ...,
) -> Any:
...
) -> Any: ...


def check_type(
value: object,
expected_type: Any,
*,
forward_ref_policy: ForwardRefPolicy = TypeCheckConfiguration().forward_ref_policy,
typecheck_fail_callback: (TypeCheckFailCallback | None) = (
typecheck_fail_callback: TypeCheckFailCallback | None = (
TypeCheckConfiguration().typecheck_fail_callback
),
collection_check_strategy: CollectionCheckStrategy = (
Expand Down
6 changes: 2 additions & 4 deletions src/typeguard/_suppression.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,11 @@


@overload
def suppress_type_checks(func: Callable[P, T]) -> Callable[P, T]:
...
def suppress_type_checks(func: Callable[P, T]) -> Callable[P, T]: ...


@overload
def suppress_type_checks() -> ContextManager[None]:
...
def suppress_type_checks() -> ContextManager[None]: ...


def suppress_type_checks(
Expand Down
6 changes: 2 additions & 4 deletions src/typeguard/_transformer.py
Original file line number Diff line number Diff line change
Expand Up @@ -589,12 +589,10 @@ def _get_import(self, module: str, name: str) -> Name:
return memo.get_import(module, name)

@overload
def _convert_annotation(self, annotation: None) -> None:
...
def _convert_annotation(self, annotation: None) -> None: ...

@overload
def _convert_annotation(self, annotation: expr) -> expr:
...
def _convert_annotation(self, annotation: expr) -> expr: ...

def _convert_annotation(self, annotation: expr | None) -> expr | None:
if annotation is None:
Expand Down
1 change: 1 addition & 0 deletions src/typeguard/_union_transformer.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Transforms lazily evaluated PEP 604 unions into typing.Unions, for compatibility with
Python versions older than 3.10.
"""

from __future__ import annotations

from ast import (
Expand Down
6 changes: 2 additions & 4 deletions tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,11 @@ def method(self, a: int) -> None:


class StaticProtocol(Protocol):
def meth(self) -> None:
...
def meth(self) -> None: ...


@runtime_checkable
class RuntimeProtocol(Protocol):
member: int

def meth(self) -> None:
...
def meth(self) -> None: ...
7 changes: 3 additions & 4 deletions tests/dummymodule.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Module docstring."""

import sys
from contextlib import contextmanager
from typing import (
Expand Down Expand Up @@ -132,13 +133,11 @@ def dummy_context_manager() -> Generator[int, None, None]:


@overload
def overloaded_func(a: int) -> int:
...
def overloaded_func(a: int) -> int: ...


@overload
def overloaded_func(a: str) -> str:
...
def overloaded_func(a: str) -> str: ...


@typechecked
Expand Down

0 comments on commit 57585c2

Please sign in to comment.