Skip to content

Commit 23cbd6b

Browse files
committed
Add functions to inspect variants
1 parent b039f4e commit 23cbd6b

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

src/variants/inspect.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# -*- coding: utf-8 -*-
2+
"""
3+
Provides inspection tools for extracting metadata from function groups.
4+
"""
5+
from ._variants import VariantFunction, VariantMethod
6+
7+
if False: # pragma: nocover
8+
from typing import Any # NOQA
9+
10+
11+
def is_primary(f):
12+
# type: (Any) -> bool
13+
"""
14+
Detect if a function is a primary function in a variant group
15+
"""
16+
return isinstance(f, (VariantFunction, VariantMethod))
17+
18+
19+
def is_primary_method(f):
20+
# type: (Any) -> bool
21+
"""
22+
Detect if a function is a primary method in a variant group
23+
"""
24+
return isinstance(f, VariantMethod)
25+

0 commit comments

Comments
 (0)