Skip to content

Commit 86ea445

Browse files
committed
Switch from attr syntax to attrs.
1 parent ba0fd4b commit 86ea445

File tree

2 files changed

+11
-14
lines changed

2 files changed

+11
-14
lines changed

formate/classes.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
from typing import Any, Callable, Dict, Iterator, List, Mapping, Optional, Sequence, Union
3131

3232
# 3rd party
33-
import attr
33+
import attrs
3434
from attr_utils.pprinter import pretty_repr
3535
from attr_utils.serialise import serde
3636
from domdf_python_tools.typing import PathLike
@@ -78,7 +78,7 @@ class ExpandedHookDict(_BaseExpandedHookDict):
7878

7979
@pretty_repr
8080
@serde
81-
@attr.s
81+
@attrs.define
8282
class Hook:
8383
"""
8484
Represents a ``formate`` reformatting hook.
@@ -87,21 +87,21 @@ class Hook:
8787
"""
8888

8989
#: The name of the hook. The name is normalized into lowercase, with underscores replaced by hyphens.
90-
name: str = attr.ib()
90+
name: str = attrs.field()
9191

9292
#: The priority of the hook.
93-
priority: int = attr.ib(default=10)
93+
priority: int = attrs.field(default=10)
9494

9595
#: The positional arguments passed to the hook function.
96-
args: Sequence[Any] = attr.ib(default=(), converter=tuple)
96+
args: Sequence[Any] = attrs.field(default=(), converter=tuple)
9797

9898
#: The keyword arguments passed to the hook function.
99-
kwargs: Dict[str, Any] = attr.ib(default={})
99+
kwargs: Dict[str, Any] = attrs.field(default={})
100100

101-
entry_point: Optional["EntryPoint"] = attr.ib(default=None)
101+
entry_point: Optional["EntryPoint"] = attrs.field(default=None)
102102

103103
#: A read-only view on the global configuration mapping, for hooks to do with as they wish.
104-
global_config: Mapping[str, Any] = attr.ib(factory=dict)
104+
global_config: Mapping[str, Any] = attrs.field(factory=dict)
105105

106106
@name.validator
107107
def _normalize(self, attribute, value): # noqa: MAN001,MAN002
@@ -154,17 +154,17 @@ def __call__(self, source: str, filename: PathLike) -> str:
154154

155155

156156
@serde
157-
@attr.s
157+
@attrs.define
158158
class EntryPoint:
159159
"""
160160
Represents an entry point for a hook.
161161
"""
162162

163163
#: The name of the entry point. The name is normalized into lowercase, with underscores replaced by hyphens.
164-
name: str = attr.ib()
164+
name: str = attrs.field()
165165

166166
#: The object the entry point refers to.
167-
obj: Callable[..., str] = attr.ib()
167+
obj: Callable[..., str] = attrs.field()
168168

169169
@name.validator
170170
def _normalize(self, attribute, value): # noqa: MAN001,MAN002

pyproject.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,6 @@ extras = "all"
5555
[tool.dep_checker]
5656
allowed_unused = [ "prettyprinter",]
5757

58-
[tool.dep_checker.name_mapping]
59-
attrs = "attr"
60-
6158
[tool.sphinx-pyproject]
6259
github_username = "python-formate"
6360
github_repository = "formate"

0 commit comments

Comments
 (0)