Skip to content

Commit 62fc0d9

Browse files
committed
fix: update ruff-pre-commit version and refactor WithArgsTypes definition
1 parent e767470 commit 62fc0d9

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ repos:
1010
- id: validate-pyproject
1111

1212
- repo: https://github.com/astral-sh/ruff-pre-commit
13-
rev: v0.14.14
13+
rev: v0.15.2
1414
hooks:
1515
- id: ruff-check
1616
args: [--fix]

src/fieldz/_repr.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ def origin_is_union(tp: type[Any] | None) -> bool:
2626
return tp is typing.Union or tp is types.UnionType # type: ignore
2727

2828

29-
WithArgsTypes = (typing._GenericAlias, types.GenericAlias, types.UnionType) # type: ignore[attr-defined]
29+
_GenericTypes = (typing._GenericAlias, types.GenericAlias) # type: ignore[attr-defined]
30+
WithArgsTypes = (*_GenericTypes, types.UnionType)
3031

3132

3233
def origin_is_literal(tp: type[Any] | None) -> bool:
@@ -102,7 +103,7 @@ def display_as_type(obj: Any, *, modern_union: bool = False) -> str:
102103
args.remove("None")
103104
return f"Optional[{args[0]}]"
104105
return f"Union[{', '.join(args)}]"
105-
elif isinstance(obj, WithArgsTypes):
106+
elif isinstance(obj, _GenericTypes):
106107
argstr = ", ".join(map(display_as_type, typing_extensions.get_args(obj)))
107108
return f"{obj.__qualname__}[{argstr}]"
108109
elif isinstance(obj, type):

0 commit comments

Comments
 (0)