diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e863bf7..6e42aa4 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -2,7 +2,7 @@ default_language_version: python: python3 repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v5.0.0 + rev: v6.0.0 hooks: - id: check-added-large-files - id: check-case-conflict @@ -20,18 +20,18 @@ repos: - id: sort-simple-yaml - id: trailing-whitespace - repo: https://github.com/codespell-project/codespell - rev: v2.4.1 + rev: v2.4.3 hooks: - id: codespell additional_dependencies: ["tomli"] - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.11.8 + rev: v0.16.0 hooks: - id: ruff args: [ --fix ] - id: ruff-format - repo: https://github.com/executablebooks/mdformat - rev: 0.7.22 + rev: 1.0.0 hooks: - id: mdformat args: ["--wrap=80"] diff --git a/znfields/__init__.py b/znfields/__init__.py index 85a7b0d..90a0d45 100644 --- a/znfields/__init__.py +++ b/znfields/__init__.py @@ -1,19 +1,16 @@ import dataclasses import functools -from typing import Any, Callable, Optional +from collections.abc import Callable +from typing import Any, Optional class _ZNFIELDS_GETTER_TYPE: """Sentinel class to identify the getter type.""" - pass - class _ZNFIELDS_SETTER_TYPE: """Sentinel class used to identify the setter type.""" - pass - # Sentinels to identify the getter and setter types ZNFIELDS_GETTER_TYPE = _ZNFIELDS_GETTER_TYPE() @@ -85,8 +82,8 @@ def __setattr__(self, name: str, value: Any) -> None: @functools.wraps(dataclasses.field) def field( *, - getter: Optional[Callable[[Any, str], Any]] = None, - setter: Optional[Callable[[Any, str, Any], None]] = None, + getter: Callable[[Any, str], Any] | None = None, + setter: Callable[[Any, str, Any], None] | None = None, **kwargs, ) -> dataclasses.Field: """Wrapper around `dataclasses.field` to allow for defining custom