Skip to content

Commit

Permalink
feat: Support typing_extensions.overload
Browse files Browse the repository at this point in the history
Co-authored-by: Timothée Mazzucotelli <pawamoy@pm.me>
PR #108: #108
  • Loading branch information
BlueGlassBlock committed Oct 26, 2022
1 parent 568ff60 commit c29fad5
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/griffe/agents/visitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
"functools.lru_cache": {"cached"},
"dataclasses.dataclass": {"dataclass"},
}
typing_overload = {"typing.overload", "typing_extensions.overload"}


def visit(
Expand Down Expand Up @@ -319,9 +320,9 @@ def handle_function(self, node: ast.AsyncFunctionDef | ast.FunctionDef, labels:
for decorator_node in node.decorator_list:
decorator_value = safe_get_value(decorator_node, self.filepath)
overload = (
decorator_value == "typing.overload"
decorator_value in typing_overload
or decorator_value == "overload"
and self.current.resolve("overload") == "typing.overload"
and self.current.resolve("overload") in typing_overload
)
decorators.append(
Decorator(
Expand Down

0 comments on commit c29fad5

Please sign in to comment.