Skip to content

Commit fef0226

Browse files
author
Michele Simionato
committed
Removed the need for getfullargspec and added test for forward references
1 parent e5cd261 commit fef0226

2 files changed

Lines changed: 9 additions & 5 deletions

File tree

src/decorator/__init__.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@
3939
import itertools
4040
import functools
4141
from contextlib import _GeneratorContextManager
42-
from inspect import getfullargspec, iscoroutinefunction, isgeneratorfunction
42+
from inspect import (
43+
getfullargspec, Parameter, iscoroutinefunction, isgeneratorfunction)
4344
from typing import Any, Dict, List, Optional
4445
try:
4546
import annotationlib # in Python 3.14+
@@ -56,7 +57,6 @@ def inspect_sig(func):
5657
DEF = re.compile(r'\s*def\s*([_\w][_\w\d]*)\s*\(')
5758
POS = inspect.Parameter.POSITIONAL_OR_KEYWORD
5859
EMPTY = inspect.Parameter.empty
59-
import inspect
6060

6161

6262
def get_args(func):
@@ -65,9 +65,8 @@ def get_args(func):
6565
Extracts positional-only and positional-or-keyword parameter names.
6666
"""
6767
args = [name for name, param in inspect_sig(func).parameters.items()
68-
if param.kind in (
69-
inspect.Parameter.POSITIONAL_ONLY,
70-
inspect.Parameter.POSITIONAL_OR_KEYWORD)]
68+
if param.kind in (Parameter.POSITIONAL_ONLY,
69+
Parameter.POSITIONAL_OR_KEYWORD)]
7170
return args
7271

7372

src/decorator/__init__.pyi

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ def inspect_sig(
2222
) -> Tuple: ...
2323

2424

25+
def get_args(
26+
func: _Func
27+
) -> Tuple: ...
28+
29+
2530
class FunctionMaker:
2631
args: list[str]
2732
varargs: str | None

0 commit comments

Comments
 (0)