Skip to content

Commit

Permalink
Updated pre-commit modules
Browse files Browse the repository at this point in the history
  • Loading branch information
agronholm committed Jul 27, 2023
1 parent 53525e1 commit 1950db1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 35 deletions.
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,19 @@ repos:
- id: trailing-whitespace

- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.0.272
rev: v0.0.280
hooks:
- id: ruff
args: [--fix, --show-fixes]

- repo: https://github.com/psf/black
rev: 23.3.0
rev: 23.7.0
hooks:
- id: black
exclude: "^tests/mypy/negative.py"

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.3.0
rev: v1.4.1
hooks:
- id: mypy
additional_dependencies: [ "typing_extensions" ]
Expand Down
40 changes: 8 additions & 32 deletions src/typeguard/_importhook.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,17 @@
from inspect import isclass
from os import PathLike
from types import CodeType, ModuleType, TracebackType
from typing import TYPE_CHECKING, Any, Sequence, TypeVar
from typing import Sequence, TypeVar
from unittest.mock import patch

from ._config import global_config
from ._transformer import TypeguardTransformer

if sys.version_info >= (3, 12):
from collections.abc import Buffer
else:
from typing_extensions import Buffer

if sys.version_info >= (3, 11):
from typing import ParamSpec
else:
Expand All @@ -26,17 +31,6 @@
else:
from importlib_metadata import PackageNotFoundError, version

if TYPE_CHECKING:
from array import array
from mmap import mmap
from pickle import PickleBuffer

# This is guarded because sphinx-autodoc-typehints tries to import these
try:
from ctypes import _CData
except ImportError:
pass

try:
OPTIMIZATION = "typeguard" + "".join(version("typeguard").split(".")[:3])
except PackageNotFoundError:
Expand All @@ -60,26 +54,8 @@ def optimized_cache_from_source(path: str, debug_override: bool | None = None) -
class TypeguardLoader(SourceFileLoader):
@staticmethod
def source_to_code(
data: bytes
| bytearray
| memoryview
| array[Any]
| mmap
| _CData
| PickleBuffer
| str
| ast.Module
| ast.Expression
| ast.Interactive,
path: bytes
| bytearray
| memoryview
| array[Any]
| mmap
| _CData
| PickleBuffer
| str
| PathLike[str] = "<string>",
data: Buffer | str | ast.Module | ast.Expression | ast.Interactive,
path: Buffer | str | PathLike[str] = "<string>",
) -> CodeType:
if isinstance(data, (ast.Module, ast.Expression, ast.Interactive)):
tree = data
Expand Down

0 comments on commit 1950db1

Please sign in to comment.