From 2fe5f2d6df2396c5fb61e064f6b3ecc883db45b5 Mon Sep 17 00:00:00 2001 From: Art Chaidarun Date: Mon, 4 May 2026 18:17:03 -0400 Subject: [PATCH] Update `duolingo` pre-commit hook to 1.15.0 (TOOLS-592) --- .pre-commit-config.yaml | 2 +- minject/__init__.py | 4 ++-- minject/inject.py | 8 ++++---- minject/inject_attrs.py | 4 ++-- minject/metadata.py | 2 +- minject/registry.py | 20 ++++++++++++++++---- pyproject.toml | 2 +- tests/test_start_close.py | 8 ++------ 8 files changed, 29 insertions(+), 21 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 01b08f6..5bd2f02 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -7,6 +7,6 @@ repos: language: system files: ^minject/.* - repo: https://github.com/duolingo/pre-commit-hooks.git - rev: 1.8.0 + rev: 1.15.0 hooks: - id: duolingo diff --git a/minject/__init__.py b/minject/__init__.py index 8f3d3d3..4ba4301 100644 --- a/minject/__init__.py +++ b/minject/__init__.py @@ -51,9 +51,9 @@ def __init__(self, api, path): ... from .registry import Registry, initialize __all__ = [ + "Registry", "define", "field", - "inject", "initialize", - "Registry", + "inject", ] diff --git a/minject/inject.py b/minject/inject.py index 873c45a..35c5604 100644 --- a/minject/inject.py +++ b/minject/inject.py @@ -523,14 +523,14 @@ async def aresolve(self, registry_impl: Resolver) -> Resolver: # compatability to a legacy system __all__ = [ "_get_meta", + "async_context", "bind", + "close_method", # deprecated "config", - "nested_config", "define", "function", + "nested_config", "reference", "self_tag", - "start_method", # deprecated - "close_method", # deprecated - "async_context", + "start_method", # deprecated ] diff --git a/minject/inject_attrs.py b/minject/inject_attrs.py index 04817b0..56dc76c 100644 --- a/minject/inject_attrs.py +++ b/minject/inject_attrs.py @@ -56,7 +56,7 @@ def __init__( def _get_compatible_attrs_define_kwargs() -> Dict[str, bool]: """ - get kwargs compatible with current running version of attrs + Get kwargs compatible with current running version of attrs """ from importlib.metadata import version as importlib_version @@ -78,7 +78,7 @@ def _get_compatible_attrs_define_kwargs() -> Dict[str, bool]: @dataclass(frozen=True) class _BindingKey: - __slots__ = ("filename", "class_lineno") + __slots__ = ("class_lineno", "filename") filename: str class_lineno: int # The line containing the "class" keyword. diff --git a/minject/metadata.py b/minject/metadata.py index d84f12b..cd77963 100644 --- a/minject/metadata.py +++ b/minject/metadata.py @@ -208,7 +208,7 @@ def _init_object(self, obj: T_co, registry_impl: "Registry") -> None: # type: i async def _ainit_object(self, obj: T_co, registry_impl: "Registry") -> None: # type: ignore[misc] """ - asynchronous version of _init_object. Calls _aresolve instead + Asynchronous version of _init_object. Calls _aresolve instead of _resolve. """ init_kwargs = {} diff --git a/minject/registry.py b/minject/registry.py index 39d896a..7b2d6b0 100644 --- a/minject/registry.py +++ b/minject/registry.py @@ -7,7 +7,19 @@ from contextlib import AsyncExitStack from textwrap import dedent from threading import RLock -from typing import Any, Callable, Dict, Generic, Iterable, List, Mapping, Optional, TypeVar, Union, cast +from typing import ( + Any, + Callable, + Dict, + Generic, + Iterable, + List, + Mapping, + Optional, + TypeVar, + Union, + cast, +) from typing_extensions import Concatenate, ParamSpec @@ -258,7 +270,7 @@ def _register_by_metadata(self, meta: RegistryMetadata[T]) -> _RegistryWrapper[T async def _aregister_by_metadata(self, meta: RegistryMetadata[T]) -> _RegistryWrapper[T]: """ - async version of _register_by_metadata. Calls _ainit_object instead of _init_object. + Async version of _register_by_metadata. Calls _ainit_object instead of _init_object. """ LOG.debug("registering %s", meta) @@ -315,7 +327,7 @@ def _get_by_metadata( async def _aget_by_metadata(self, meta: RegistryMetadata[T]) -> Optional[_RegistryWrapper[T]]: """ - async version of _get_by_metadata. The default argument has been removed + Async version of _get_by_metadata. The default argument has been removed from the signature, as there is no use case for it at the time of writing. Please make a feature request if you need this functionality. """ @@ -328,7 +340,7 @@ async def _aget_by_metadata(self, meta: RegistryMetadata[T]) -> Optional[_Regist def __len__(self) -> int: return len(self._objects) - def __contains__(self, key : object) -> bool: + def __contains__(self, key: object) -> bool: """Check if an object is contained in the registry. Note that this method returns True if the object has already been registered. It is possible that the key provides enough information diff --git a/pyproject.toml b/pyproject.toml index 443271b..1efec27 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -14,8 +14,8 @@ requires-python = ">=3.9" dependencies = ["attrs>=17.4", "packaging", "typing_extensions>=4.1"] [build-system] -requires = ["hatchling>=1.26.1"] build-backend = "hatchling.build" +requires = ["hatchling>=1.26.1"] [tool.hatch.version] path = "minject/__init__.py" diff --git a/tests/test_start_close.py b/tests/test_start_close.py index e7b3e0e..706b104 100644 --- a/tests/test_start_close.py +++ b/tests/test_start_close.py @@ -104,11 +104,9 @@ def close_func(obj: TestClass) -> None: def test_start_method_decorator_duplicate(self) -> None: """Test that start_method decorator correctly sets up a start function.""" - def start_func(obj : "TestClass") -> None: - ... + def start_func(obj: "TestClass") -> None: ... - def close_func(obj : "TestClass") -> None: - ... + def close_func(obj: "TestClass") -> None: ... @inject.bind(_start=start_func, _close=close_func) class TestClass: @@ -127,5 +125,3 @@ def noop(self) -> None: with self.assertRaises(ValueError): close_method(TestClass, lambda x: x.noop()) - -