Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions taskiq_dependencies/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,10 @@ def _build_graph(self) -> None: # noqa: C901
hints = get_type_hints(origin.__init__)
except NameError:
_, src_lineno = inspect.getsourcelines(origin)
src_file = Path(inspect.getfile(origin)).relative_to(
Path.cwd(),
)
src_file = Path(inspect.getfile(origin))
cwd = Path.cwd()
if src_file.is_relative_to(cwd):
src_file = src_file.relative_to(cwd)
warnings.warn(
"Cannot resolve type hints for "
f"a class {origin.__name__} defined "
Expand All @@ -198,9 +199,10 @@ def _build_graph(self) -> None: # noqa: C901
hints = get_type_hints(dep.dependency)
except NameError:
_, src_lineno = inspect.getsourcelines(dep.dependency) # type: ignore
src_file = Path(inspect.getfile(dep.dependency)).relative_to(
Path.cwd(),
)
src_file = Path(inspect.getfile(dep.dependency))
cwd = Path.cwd()
if src_file.is_relative_to(cwd):
src_file = src_file.relative_to(cwd)
warnings.warn(
"Cannot resolve type hints for "
f"a function {dep.dependency.__name__} defined "
Expand All @@ -217,11 +219,10 @@ def _build_graph(self) -> None: # noqa: C901
)
except NameError:
_, src_lineno = inspect.getsourcelines(dep.dependency.__class__)
src_file = Path(
inspect.getfile(dep.dependency.__class__),
).relative_to(
Path.cwd(),
)
src_file = Path(inspect.getfile(dep.dependency.__class__))
cwd = Path.cwd()
if src_file.is_relative_to(cwd):
src_file = src_file.relative_to(cwd)
cls_name = dep.dependency.__class__.__name__
warnings.warn(
"Cannot resolve type hints for "
Expand Down
Loading