Skip to content

Commit

Permalink
Modernize docstring, imports
Browse files Browse the repository at this point in the history
  • Loading branch information
Tinche committed Jan 28, 2025
1 parent 09a242a commit c19836b
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions src/attrs/custom_fields.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
from __future__ import annotations

import typing

from typing_extensions import Protocol
from typing import Protocol, TypeVar

from attr._make import _make_attr_tuple_class
from attrs import Attribute, AttrsInstance, fields
Expand All @@ -11,7 +9,7 @@

__all__ = ["custom_fields"]

T = typing.TypeVar("T")
T = TypeVar("T")


class AttributeModel(Protocol[T]):
Expand All @@ -35,17 +33,20 @@ def custom_fields(
"""
Return the attrs fields tuple for cls with the provided attribute model.
:param type cls: Class to introspect.
:param attribute_model: The attribute model to use.
:param resolve_types: Whether to resolve the class types first.
Args:
cls: Class to introspect.
attribute_model: The attribute model to use.
resolve_types: Whether to resolve the class types first.
:raise TypeError: If *cls* is not a class.
:raise attrs.exceptions.NotAnAttrsClassError: If *cls* is not an *attrs*
class.
Raises:
TypeError: If *cls* is not a class.
attrs.exceptions.NotAnAttrsClassError: If *cls* is not an *attrs*
class.
:rtype: tuple (with name accessors) of `attribute_model`.
Returns:
tuple (with name accessors) of `attribute_model`.
.. versionadded:: 23.2.0
.. versionadded:: 25.1.0
"""
attrs = getattr(cls, f"__attrs_{id(attribute_model)}__", None)

Expand Down

0 comments on commit c19836b

Please sign in to comment.