-
-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Recursively evaluate guarded code (#393)
* Add test for nested guarded imports * Handle nested type guards * Refactor --------- Co-authored-by: Bernát Gábor <[email protected]>
- Loading branch information
1 parent
5eb0fcf
commit 3eeb664
Showing
3 changed files
with
62 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
tests/roots/test-resolve-typing-guard/demo_typing_guard_dummy.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,13 @@ | ||
from __future__ import annotations | ||
|
||
from typing import TYPE_CHECKING | ||
|
||
from viktor import AI # module part of autodoc_mock_imports # noqa: F401 | ||
|
||
if TYPE_CHECKING: | ||
# Nested type guard | ||
from typing import Literal # noqa: F401 | ||
|
||
|
||
class AnotherClass: | ||
"""Another class is here""" |