-
-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add failing test * Pass test * Alternate solution * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Pre-commit --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
- Loading branch information
1 parent
ee0c649
commit 09197b8
Showing
5 changed files
with
85 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import pathlib | ||
import sys | ||
|
||
master_doc = "index" | ||
sys.path.insert(0, str(pathlib.Path(__file__).parent)) | ||
extensions = [ | ||
"sphinx.ext.autodoc", | ||
"sphinx_autodoc_typehints", | ||
] |
59 changes: 59 additions & 0 deletions
59
tests/roots/test-resolve-typing-guard-tmp/demo_typing_guard.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 |
---|---|---|
@@ -0,0 +1,59 @@ | ||
"""Module demonstrating imports that are type guarded""" | ||
from __future__ import annotations | ||
|
||
from typing import TYPE_CHECKING | ||
|
||
from attrs import define | ||
|
||
if TYPE_CHECKING: | ||
import datetime | ||
|
||
|
||
@define() | ||
class SomeClass: | ||
"""This class does something.""" | ||
|
||
date: datetime.date | ||
"""Date to handle""" | ||
|
||
@classmethod | ||
def from_str(cls, input_value: str) -> SomeClass: | ||
""" | ||
Initialise from string | ||
:param input_value: Input | ||
:return: result | ||
""" | ||
return cls(input_value) | ||
|
||
@classmethod | ||
def from_date(cls, input_value: datetime.date) -> SomeClass: | ||
""" | ||
Initialise from date | ||
:param input_value: Input | ||
:return: result | ||
""" | ||
return cls(input_value) | ||
|
||
@classmethod | ||
def from_time(cls, input_value: datetime.time) -> SomeClass: | ||
""" | ||
Initialise from time | ||
:param input_value: Input | ||
:return: result | ||
""" | ||
return cls(input_value) | ||
|
||
def calculate_thing(self, number: float) -> datetime.timedelta: | ||
""" | ||
Calculate a thing | ||
:param number: Input | ||
:return: result | ||
""" | ||
return datetime.timedelta(number) | ||
|
||
|
||
__all__ = ["SomeClass"] |
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.. automodule:: demo_typing_guard | ||
:members: |
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